diff options
-rw-r--r-- | jeschli/1systems/brauerei/config.nix | 16 | ||||
-rw-r--r-- | lib/default.nix | 6 | ||||
-rw-r--r-- | lib/types.nix | 8 | ||||
-rw-r--r-- | lib/xml.nix | 88 | ||||
-rw-r--r-- | tv/2configs/bash/default.nix | 3 | ||||
-rw-r--r-- | tv/2configs/default.nix | 7 | ||||
-rw-r--r-- | tv/2configs/gitrepos.nix | 3 | ||||
-rw-r--r-- | tv/2configs/vim.nix | 75 | ||||
-rw-r--r-- | tv/2configs/xserver/default.nix | 19 | ||||
-rw-r--r-- | tv/3modules/iptables.nix | 59 | ||||
-rw-r--r-- | tv/5pkgs/haskell/xmonad-tv/src/main.hs | 6 | ||||
-rw-r--r-- | tv/5pkgs/override/default.nix | 6 | ||||
-rw-r--r-- | tv/5pkgs/override/rxvt_unicode.nix | 9 | ||||
-rw-r--r-- | tv/5pkgs/simple/bash-fzf-history.nix | 102 | ||||
-rw-r--r-- | tv/5pkgs/simple/utsushi.nix | 5 |
15 files changed, 364 insertions, 48 deletions
diff --git a/jeschli/1systems/brauerei/config.nix b/jeschli/1systems/brauerei/config.nix index 7ac4cc2..b9bb021 100644 --- a/jeschli/1systems/brauerei/config.nix +++ b/jeschli/1systems/brauerei/config.nix @@ -103,7 +103,9 @@ in gotools # rust cargo - rustc + rustracer + rustup + vscode # orga tools taskwarrior # xorg @@ -143,19 +145,11 @@ in ''; } ]; -# xmonad = { -# enable = true; -# enableContribAndExtras = true; -# extraPackages = haskellPackages: [ -# haskellPackages.xmonad-contrib -# haskellPackages.xmonad-extras -# haskellPackages.xmonad -# ]; -# } - }; }; + services.xserver.windowManager.i3.enable = true; + users.extraUsers.jeschli = { # TODO: define as krebs.users isNormalUser = true; extraGroups = ["docker" "vboxusers" "audio"]; diff --git a/lib/default.nix b/lib/default.nix index 347830e..8ba55b5 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -9,6 +9,7 @@ let krops = import ../submodules/krops/lib; shell = import ./shell.nix { inherit lib; }; types = nixpkgs-lib.types // import ./types.nix { inherit lib; }; + xml = import ./xml.nix { inherit lib; }; eq = x: y: x == y; ne = x: y: x != y; @@ -145,6 +146,11 @@ let in filter (x: x != []) ([acc.chunk] ++ acc.chunks); + warnOldVersion = oldName: newName: + if compareVersions oldName newName != -1 then + trace "Upstream `${oldName}' gets overridden by `${newName}'." newName + else + newName; }; in diff --git a/lib/types.nix b/lib/types.nix index 17c1688..9001bc7 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -86,6 +86,12 @@ rec { type = nullOr ssh-privkey; default = null; }; + + syncthing.id = mkOption { + # TODO syncthing id type + type = nullOr string; + default = null; + }; }; }); @@ -539,7 +545,7 @@ rec { # POSIX.1‐2013, 3.278 Portable Filename Character Set filename = mkOptionType { name = "POSIX filename"; - check = test "([0-9A-Za-z._])[0-9A-Za-z._-]*"; + check = test "[0-9A-Za-z._][0-9A-Za-z._-]*"; merge = mergeOneOption; }; diff --git a/lib/xml.nix b/lib/xml.nix new file mode 100644 index 0000000..1605244 --- /dev/null +++ b/lib/xml.nix @@ -0,0 +1,88 @@ +{ lib }: +with lib; +with builtins; +rec { + + # Use `term` to construct XML. + # + # Examples: + # + # (term "bool" null null) + # (term "cool" null []) + # (term "fool" { hurr = "durr"; } null) + # (term "hool" null [ + # (term "tool" null null) + # ]) + # + # See `render` for how these get transformed into actuall XML documents. + # + term = name: attrs: content: { + inherit name attrs content; + }; + + empty = term null null null; + + # Ref http://www.w3.org/TR/xml/#syntax + # + # Example: + # + # (quote "<cheez!>") #===> <cheez!> + # + quote = let + sub = { + "&" = "&"; + "<" = "<"; + ">" = ">"; + "'" = "'"; + "\"" = """; + }; + in + stringAsChars (c: sub.${c} or c); + + # Turn an XML element to an XML document string. + doc = t: + "<?xml version='1.0' encoding='UTF-8'?>${render t}"; + + # Render an XML element to a string. + # + # Rendering `empty` yields the empty string. + # + # Examples: + # + # (term "bool" null null) #===> <bool/> + # (term "cool" null []) #===> <cool></cool> + # (term "fool" { hurr = "durr"; } null) #===> <fool hurr="durr"/> + # (term "hool" null [ + # (term "tool" null null) + # ]) #===> <hool><tool/></hool> + # + render = let + render-attrs = attrs: + getAttr (typeOf attrs) { + null = ""; + set = concatStrings (mapAttrsToList (n: v: " ${n}=\"${v}\"") attrs); + }; + + render-content = content: + getAttr (typeOf content) { + bool = toJSON content; + int = toJSON content; + list = concatMapStrings render content; + string = quote content; + }; + in + { name, attrs, content }: + # XXX we're currently encoding too much information with `null`.. + if name == null + then + if content == null + then "" + else content + else let + attrs' = render-attrs attrs; + content' = render-content content; + in + if content == null + then "<${name}${attrs'}/>" + else "<${name}${attrs'}>${content'}</${name}>"; +} diff --git a/tv/2configs/bash/default.nix b/tv/2configs/bash/default.nix index d767393..42914e0 100644 --- a/tv/2configs/bash/default.nix +++ b/tv/2configs/bash/default.nix @@ -8,6 +8,7 @@ with import <stockholm/lib>; HISTCONTROL='erasedups:ignorespace' HISTSIZE=65536 HISTFILESIZE=$HISTSIZE + HISTTIMEFORMAT= shopt -s checkhash shopt -s histappend histreedit histverify @@ -27,6 +28,8 @@ with import <stockholm/lib>; export NIX_PATH="stockholm=$HOME/stockholm:$NIX_PATH" ;; esac + + ${pkgs.bash-fzf-history.bind} ''; promptInit = /* sh */ '' case $UID in diff --git a/tv/2configs/default.nix b/tv/2configs/default.nix index e18ba31..ac0a6af 100644 --- a/tv/2configs/default.nix +++ b/tv/2configs/default.nix @@ -80,13 +80,6 @@ with import <stockholm/lib>; ls = "ls -h --color=auto --group-directories-first"; dmesg = "dmesg -L --reltime"; view = "vim -R"; - - deploy = pkgs.writeDash "deploy" '' - set -eu - cd ~/stockholm - export SYSTEM="$1" - exec nix-shell -I stockholm="$PWD" --run 'deploy --system="$SYSTEM"' - ''; }; environment.variables = { diff --git a/tv/2configs/gitrepos.nix b/tv/2configs/gitrepos.nix index 725ddef..95ab75b 100644 --- a/tv/2configs/gitrepos.nix +++ b/tv/2configs/gitrepos.nix @@ -47,6 +47,9 @@ let { disko = { cgit.desc = "declarative partitioning and formatting tool"; }; + flameshot-once = { + cgit.desc = "flameshot runner that automatically starts/stops the daemon"; + }; fswm = { cgit.desc = "simple full screen window manager"; }; diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix index 3794628..a45e040 100644 --- a/tv/2configs/vim.nix +++ b/tv/2configs/vim.nix @@ -129,15 +129,66 @@ let { command! -n=0 -bar ShowSyntax :call ShowSyntax() ''; }))) + ((rtp: rtp // { inherit rtp; }) (pkgs.write "vim-tv" { + # + # Haskell + # + "/ftplugin/haskell.vim".text = '' + if exists("g:vim_tv_ftplugin_haskell_loaded") + finish + endif + let g:vim_tv_ftplugin_haskell_loaded = 1 + + setlocal iskeyword+=' + ''; + # + # TODO + # + "/ftdetect/todo.vim".text = '' + au BufRead,BufNewFile TODO set ft=todo + ''; + "/ftplugin/todo.vim".text = '' + setlocal foldmethod=syntax + ''; + "/syntax/todo.vim".text = '' + syn match todoComment /#.*/ + + syn match todoDate /^[1-9]\S*/ + \ nextgroup=todoSummary + + syn region todoSummary + \ contained + \ contains=todoTag + \ start="." end="$\n" + \ nextgroup=todoBlock + + syn match todoTag /\[[A-Za-z]\+\]/hs=s+1,he=e-1 + \ contained + + syn region todoBlock + \ contained + \ contains=Comment + \ fold + \ start="^[^1-9]" end="^[1-9]"re=s-1,he=s-1,me=s-1 + + syn sync minlines=1000 + + hi link todoComment Comment + hi todoDate ctermfg=255 + hi todoSummary ctermfg=229 + hi todoBlock ctermfg=248 + hi todoTag ctermfg=217 + ''; + })) ((rtp: rtp // { inherit rtp; }) (pkgs.write "vim-syntax-nix-nested" { - "/syntax/haskell.vim".text = /* vim */ '' + "/syntax/haskell.vim".text = '' syn region String start=+\[[[:alnum:]]*|+ end=+|]+ hi link ConId Identifier hi link VarId Identifier hi link hsDelimiter Delimiter ''; - "/syntax/nix.vim".text = /* vim */ '' + "/syntax/nix.vim".text = '' "" Quit when a (custom) syntax file was already loaded "if exists("b:current_syntax") " finish @@ -250,6 +301,9 @@ let { def = k: ''${k}[ \t\r\n]*=''; writer = k: ''write${k}[^ \t\r\n]*[ \t\r\n]*\("[^"]*"\|[a-z]\+\)''; + writerExt = k: writerName ''[^"]*\.${k}''; + writerName = k: ''write[^ \t\r\n]*[ \t\r\n]*"${k}"''; + in { c = {}; cabal = {}; @@ -257,7 +311,7 @@ let { haskell = {}; jq.extraStart = alts [ (writer "Jq") - ''write[^ \t\r\n]*[ \t\r\n]*"[^"]*\.jq"'' + (writerExt "jq") ]; javascript.extraStart = ''/\* js \*/''; lua = {}; @@ -287,9 +341,13 @@ let { (writer (alts (map capitalize shells))) ]; yaml = {}; - vim.extraStart = - ''write[^ \t\r\n]*[ \t\r\n]*"\(\([^"]*\.\)\?vimrc\|[^"]*\.vim\)"''; + vim.extraStart = alts [ + (def ''"[^"]*\.vim"\.text'') + (writerExt "vim") + (writerName ''\([^"]*\.\)\?vimrc'') + ]; xdefaults = {}; + xmodmap = {}; }))} " Clear syntax that interferes with nixINSIDE_DOLLAR_CURLY. @@ -329,12 +387,15 @@ let { set isk=@,48-57,_,192-255,-,' ''; - "/syntax/sed.vim".text = /* vim */ '' + "/syntax/sed.vim".text = '' syn region sedBranch \ matchgroup=sedFunction start="T" \ matchgroup=sedSemicolon end=";\|$" \ contains=sedWhitespace ''; + "/syntax/xmodmap.vim".text = '' + syn match xmodmapComment /^\s*!.*/ + ''; })) ]; @@ -429,6 +490,8 @@ let { inoremap <f1> <esc>:tabp<cr> inoremap <f2> <esc>:tabn<cr> + noremap <f3> :ShowSyntax<cr> + " <C-{Up,Down,Right,Left> noremap <esc>Oa <nop> | noremap! <esc>Oa <nop> noremap <esc>Ob <nop> | noremap! <esc>Ob <nop> diff --git a/tv/2configs/xserver/default.nix b/tv/2configs/xserver/default.nix index f68e8e6..051e12e 100644 --- a/tv/2configs/xserver/default.nix +++ b/tv/2configs/xserver/default.nix @@ -48,10 +48,24 @@ in { systemd.services.xmonad = let xmonad = "${pkgs.haskellPackages.xmonad-tv}/bin/xmonad"; - xmonad-prepare = pkgs.writeDash "xmonad-prepare" '' + xmonad-start = pkgs.writeDash "xmonad-start" '' ${pkgs.coreutils}/bin/mkdir -p "$XMONAD_CACHE_DIR" ${pkgs.coreutils}/bin/mkdir -p "$XMONAD_CONFIG_DIR" ${pkgs.coreutils}/bin/mkdir -p "$XMONAD_DATA_DIR" + + f=$HOME/.dbus/session-bus/$(${pkgs.coreutils}/bin/cat /etc/machine-id)-${ + toString config.services.xserver.display + } + if test -e "$f" && + . "$f" && + ${pkgs.coreutils}/bin/kill -0 "$DBUS_SESSION_BUS_PID" + then + export DBUS_SESSION_BUS_ADDRESS + else + eval "$(${pkgs.dbus.lib}/bin/dbus-launch --sh-syntax)" + fi + + exec ${xmonad} ''; xmonad-ready = pkgs.writeDash "xmonad-ready" '' { @@ -97,8 +111,7 @@ in { "/run/wrappers" # for su ]; serviceConfig = { - ExecStartPre = "@${xmonad-prepare} xmonad-prepare"; - ExecStart = "@${xmonad} xmonad-${currentSystem}"; + ExecStart = "@${xmonad-start} xmonad-${currentSystem}"; ExecStop = "@${xmonad} xmonad-${currentSystem} --shutdown"; SyslogIdentifier = "xmonad"; User = cfg.user.name; diff --git a/tv/3modules/iptables.nix b/tv/3modules/iptables.nix index 56861dc..3974760 100644 --- a/tv/3modules/iptables.nix +++ b/tv/3modules/iptables.nix @@ -9,6 +9,37 @@ let { config = lib.mkIf cfg.enable imp; }; + extraTypes = { + rules = types.submodule { + options = { + nat.OUTPUT = mkOption { + type = with types; listOf str; + default = []; + }; + nat.PREROUTING = mkOption { + type = with types; listOf str; + default = []; + }; + nat.POSTROUTING = mkOption { + type = with types; listOf str; + default = []; + }; + filter.FORWARD = mkOption { + type = with types; listOf str; + default = []; + }; + filter.INPUT = mkOption { + type = with types; listOf str; + default = []; + }; + filter.Retiolum = mkOption { + type = with types; listOf str; + default = []; + }; + }; + }; + }; + api = { enable = mkEnableOption "tv.iptables"; @@ -37,19 +68,19 @@ let { default = []; }; - extra = { - nat.POSTROUTING = mkOption { - type = with types; listOf str; - default = []; - }; - filter.FORWARD = mkOption { - type = with types; listOf str; - default = []; - }; - filter.INPUT = mkOption { - type = with types; listOf str; - default = []; - }; + extra = mkOption { + default = {}; + type = extraTypes.rules; + }; + + extra4 = mkOption { + default = {}; + type = extraTypes.rules; + }; + + extra6 = mkOption { + default = {}; + type = extraTypes.rules; }; }; @@ -112,6 +143,7 @@ let { "-o lo -p tcp -m tcp --dport 11423 -j REDIRECT --to-ports 22" ]} ${formatTable cfg.extra.nat} + ${formatTable cfg."extra${toString iptables-version}".nat} COMMIT *filter :INPUT DROP [0:0] @@ -129,6 +161,7 @@ let { ++ ["-i retiolum -j Retiolum"] )} ${formatTable cfg.extra.filter} + ${formatTable cfg."extra${toString iptables-version}".filter} ${concatMapStringsSep "\n" (rule: "-A Retiolum ${rule}") ([] ++ optional (cfg.accept-echo-request == "retiolum") accept-echo-request ++ map accept-tcp (unique (map toString cfg.input-retiolum-accept-tcp)) diff --git a/tv/5pkgs/haskell/xmonad-tv/src/main.hs b/tv/5pkgs/haskell/xmonad-tv/src/main.hs index b7d4e9b..c528017 100644 --- a/tv/5pkgs/haskell/xmonad-tv/src/main.hs +++ b/tv/5pkgs/haskell/xmonad-tv/src/main.hs @@ -1,8 +1,4 @@ -{-# LANGUAGE DeriveDataTypeable #-} -- for XS -{-# LANGUAGE FlexibleContexts #-} -- for xmonad' {-# LANGUAGE LambdaCase #-} -{-# LANGUAGE ScopedTypeVariables #-} - module Main (main) where @@ -51,7 +47,7 @@ mainNoArgs = do let width = 1366 workspaces0 <- getWorkspaces0 handleShutdownEvent <- newShutdownEventHandler - xmonad + launch $ withUrgencyHook (SpawnUrgencyHook "echo emit Urgency ") $ def { terminal = Paths.urxvtc diff --git a/tv/5pkgs/override/default.nix b/tv/5pkgs/override/default.nix new file mode 100644 index 0000000..99c1b3e --- /dev/null +++ b/tv/5pkgs/override/default.nix @@ -0,0 +1,6 @@ +with import <stockholm/lib>; +self: super: { + rxvt_unicode = self.callPackage ./rxvt_unicode.nix { + rxvt_unicode = super.rxvt_unicode; + }; +} diff --git a/tv/5pkgs/override/rxvt_unicode.nix b/tv/5pkgs/override/rxvt_unicode.nix new file mode 100644 index 0000000..da657fb --- /dev/null +++ b/tv/5pkgs/override/rxvt_unicode.nix @@ -0,0 +1,9 @@ +{ fetchurl, rxvt_unicode }: +rxvt_unicode.overrideAttrs (old: { + patches = old.patches ++ [ + (fetchurl { + url = https://cgit.krebsco.de/rxvt-unicode/patch/?id=15f3f94; + sha256 = "12vldwsds27c9l15ffc6svk9mj17jhypcz736pvpmpqbsymlkz2p"; + }) + ]; +}) diff --git a/tv/5pkgs/simple/bash-fzf-history.nix b/tv/5pkgs/simple/bash-fzf-history.nix new file mode 100644 index 0000000..88a8e9e --- /dev/null +++ b/tv/5pkgs/simple/bash-fzf-history.nix @@ -0,0 +1,102 @@ +with import <stockholm/lib>; +{ pkgs + +, edit-key ? "ctrl-e" +, exec-key ? "enter" +, edit-mark ? "${mark-prefix}${edit-key}" +, exec-mark ? "${mark-prefix}${exec-key}" +, edit-command ? "\"\"" +, exec-command ? "accept-line" +, mark-prefix ? " #FZFKEY:" +, finish-keyseq ? "\\C-x\\C-p" +, rebind-keyseq ? "\\C-x\\C-o" + +, start-keyseq ? "\\C-f" +, load-keyseq ? start-keyseq +}: let + script = pkgs.writeBash "bash-fzf-history.sh" '' + if ! command -v fzf >/dev/null; then + # Alternatively rewrite ${pkgs.fzf}/share/fzf/* to use absolute paths. + fzf() { + ${pkgs.fzf}/bin/fzf "$@" + } + fi + + . ${pkgs.fzf}/share/fzf/key-bindings.bash + . ${pkgs.fzf}/share/fzf/completion.bash + + FZF_DEFAULT_OPTS='${toString [ + /* sh */ "--height=40%" + /* sh */ "--inline-info" + /* sh */ "--min-height=4" + /* sh */ "--reverse" + ]}' + + __fzf_history__() ( + IFS=$'\n' + result=( $( + # To add "unknown timestamps" to each line of the history: + # sed -i '/^#[0-9]/{n;b};s/^/#1\n/' "$HISTFILE" + HISTTIMEFORMAT=$'\e[38;5;244m%Y-%m-%dT%H:%M:%S\e[m ' history | + ${pkgs.gnused}/bin/sed ' + s/\(\x1b\[[0-9;]*\)244m1970-[0-9T:-]*/\1237m????-??-??T??:??:??/ + ' | + FZF_DEFAULT_OPTS="${toString [ + /* sh */ "--ansi" + /* sh */ "--tac" + /* sh */ "--sync" + /* sh */ "-n2..,.." + /* sh */ "--tiebreak=index" + /* sh */ "--bind=ctrl-r:toggle-sort" + /* sh */ "--expect=${edit-key},${exec-key}" + /* sh */ "$FZF_DEFAULT_OPTS" + /* sh */ "+m" + ]}" \ + ${pkgs.fzf}/bin/fzf | + ${pkgs.gnused}/bin/sed ' + /^ *[0-9]/{ + s/^ *// + s/ \+/\n/;# index + s/ \+/\n/;# date + } + ' + ) ) + if test -n "$result"; then + key=''${result[0]} + index=''${result[1]} + date=''${result[2]} + command=''${result[3]} + + echo "$command${mark-prefix}$key" + else + # Ensure no empty new line gets produced when fzf was aborted. + echo '${edit-mark}' + fi + ) + + __fzf_rebind_finish_keyseq__() { + local suffix= + case $READLINE_LINE in + *'${edit-mark}') + suffix='${edit-mark}' + bind '"${finish-keyseq}": ${edit-command}' + ;; + *'${exec-mark}') + suffix='${exec-mark}' + bind '"${finish-keyseq}": ${exec-command}' + ;; + esac + READLINE_LINE=${"\${READLINE_LINE:0:-\${#suffix}}"} + } + bind -x '"${rebind-keyseq}": __fzf_rebind_finish_keyseq__' + + bind '"\C-r": reverse-search-history' + bind '"${start-keyseq}": " \C-e\C-u\C-y\ey\C-u`__fzf_history__`\e\C-e\er\e^${rebind-keyseq}${finish-keyseq}"' + + echo '# fzf key bindings loaded:' >&2 + bind -s | ${pkgs.gnugrep}/bin/grep __fzf_ >&2 + ''; +in + script.overrideAttrs (old: rec { + bind = /* sh */ ''bind -x '"${load-keyseq}": . ${script}' ''; + }) diff --git a/tv/5pkgs/simple/utsushi.nix b/tv/5pkgs/simple/utsushi.nix index e61dd18..55e8800 100644 --- a/tv/5pkgs/simple/utsushi.nix +++ b/tv/5pkgs/simple/utsushi.nix @@ -103,7 +103,7 @@ stdenv.mkDerivation rec { src = fetchurl { url = "http://support.epson.net/linux/src/scanner/imagescanv3/debian/imagescan_${meta.version}.orig.tar.gz"; - sha256 = "12mzq3wc8gzdma84pjs5gb0gp8mga13wax5g7vjfrzq8pjyqrnmw"; + sha256 = "1gmiimwkcyzbkfr25vzqczjhgh90fgxd96agbnkpf9gah1mpd6qj"; }; preConfigure = '' @@ -172,6 +172,7 @@ stdenv.mkDerivation rec { "--with-boost=${boost}" "--with-magick" "--with-magick-pp" + "--with-udev-confdir=$(out)/etc/udev" ] ++ stdenv.lib.optionals guiSupport [ "--with-gtkmm" @@ -202,6 +203,6 @@ stdenv.mkDerivation rec { license = stdenv.lib.licenses.gpl3; maintainers = [ stdenv.lib.maintainers.tv ]; platforms = stdenv.lib.platforms.linux; - version = "3.48.0"; + version = "3.54.0"; }; } |