diff options
-rw-r--r-- | configs/default.nix | 1 | ||||
-rw-r--r-- | configs/gitrepos.nix | 2 | ||||
-rw-r--r-- | configs/hw/AO753.nix | 3 | ||||
-rw-r--r-- | configs/hw/winmax2.nix | 3 | ||||
-rw-r--r-- | configs/hw/x220.nix | 4 | ||||
-rw-r--r-- | configs/variables.nix | 19 | ||||
-rw-r--r-- | configs/wiregrill.nix | 4 | ||||
-rw-r--r-- | configs/xserver/default.nix | 2 | ||||
-rw-r--r-- | modules/backup.nix | 252 | ||||
-rw-r--r-- | modules/hw.nix | 15 | ||||
-rw-r--r-- | pkgs/haskell/desktop-pager.nix | 10 | ||||
-rw-r--r-- | pkgs/haskell/hack.nix | 12 | ||||
-rw-r--r-- | pkgs/haskell/much.nix | 19 | ||||
-rw-r--r-- | pkgs/haskell/terminal-scanner.nix | 13 | ||||
-rw-r--r-- | pkgs/haskell/xmonad-tv/src/main.hs | 5 | ||||
-rw-r--r-- | pkgs/haskell/xoutinfo.nix | 6 | ||||
-rw-r--r-- | pkgs/simple/alacritty-tv.nix | 5 | ||||
-rwxr-xr-x | pkgs/simple/fzmenu/bin/otpmenu | 31 | ||||
-rwxr-xr-x | pkgs/simple/fzmenu/bin/passmenu | 31 | ||||
-rw-r--r-- | pkgs/simple/fzmenu/default.nix | 2 | ||||
-rw-r--r-- | systems/xu/config.nix | 5 |
21 files changed, 386 insertions, 58 deletions
diff --git a/configs/default.nix b/configs/default.nix index 06fd83a..fb8627d 100644 --- a/configs/default.nix +++ b/configs/default.nix @@ -19,6 +19,7 @@ ./ssh.nix ./sshd.nix ./tmux.nix + ./variables.nix ./vim.nix ./xdg.nix { diff --git a/configs/gitrepos.nix b/configs/gitrepos.nix index 0e61989..174e303 100644 --- a/configs/gitrepos.nix +++ b/configs/gitrepos.nix @@ -126,7 +126,7 @@ hc = {}; mime = {}; quipper = {}; - scanner = {}; + terminal-scanner = {}; wai-middleware-time = {}; web-routes-wai-custom = {}; xintmap = {}; diff --git a/configs/hw/AO753.nix b/configs/hw/AO753.nix index ea58c01..5e91564 100644 --- a/configs/hw/AO753.nix +++ b/configs/hw/AO753.nix @@ -41,7 +41,4 @@ ''; krebs.nixpkgs.allowUnfreePredicate = pkg: packageName pkg == "broadcom-sta"; - - tv.hw.screens.primary.width = 1366; - tv.hw.screens.primary.height = 768; } diff --git a/configs/hw/winmax2.nix b/configs/hw/winmax2.nix index 4bcd6f1..8af5511 100644 --- a/configs/hw/winmax2.nix +++ b/configs/hw/winmax2.nix @@ -41,7 +41,4 @@ ''; tv.lidControl.enable = true; - - tv.hw.screens.primary.width = 2560; - tv.hw.screens.primary.height = 1600; } diff --git a/configs/hw/x220.nix b/configs/hw/x220.nix index 6ae6cec..323be01 100644 --- a/configs/hw/x220.nix +++ b/configs/hw/x220.nix @@ -64,6 +64,7 @@ services.tlp.enable = true; services.tlp.settings = { START_CHARGE_THRESH_BAT0 = 80; + WOL_DISABLE = false; }; @@ -82,7 +83,4 @@ services.xserver = { videoDriver = "intel"; }; - - tv.hw.screens.primary.width = lib.mkDefault 1366; - tv.hw.screens.primary.height = lib.mkDefault 768; } diff --git a/configs/variables.nix b/configs/variables.nix new file mode 100644 index 0000000..cdfaceb --- /dev/null +++ b/configs/variables.nix @@ -0,0 +1,19 @@ +{ config, lib, ... }: { + options.hrm.environment.variables = lib.mkOption { + type = lib.types.attrsOf lib.types.str; + default = {}; + description = '' + This is a stricter version of `environment.variables`, using + `escapeShellArg` instead of `"` for quoting. + + Use this when you don't have the need to reference other variables or + inject code into `/nix/store/*-set-environment`. This is also useful + for variables that need be used in contexts that don't perform shell + initialization, like e.g. `systemd.services.*.environment`; + ''; + }; + config.environment.variables = + lib.mapAttrs + (_name: value: ''"${lib.escapeShellArg value}"'') + config.hrm.environment.variables; +} diff --git a/configs/wiregrill.nix b/configs/wiregrill.nix index 55bb6f5..ee73061 100644 --- a/configs/wiregrill.nix +++ b/configs/wiregrill.nix @@ -8,8 +8,8 @@ in lib.mkIf cfg.enable { networking.wireguard.interfaces.wiregrill = { ips = - lib.optional (cfg.net.ip4 != null) cfg.net.ip4.addr ++ - lib.optional (cfg.net.ip6 != null) cfg.net.ip6.addr; + lib.optional (cfg.net.ip4 != null) (toCidrNotation cfg.net.ip4) ++ + lib.optional (cfg.net.ip6 != null) (toCidrNotation cfg.net.ip6); listenPort = 51820; privateKeyFile = "${config.krebs.secret.directory}/wiregrill.key"; allowedIPsAsRoutes = true; diff --git a/configs/xserver/default.nix b/configs/xserver/default.nix index 884a982..88c1afb 100644 --- a/configs/xserver/default.nix +++ b/configs/xserver/default.nix @@ -6,13 +6,11 @@ user = config.krebs.build.user; xmonad.pkg = pkgs.haskellPackages.xmonad-tv.overrideAttrs (_: { au = { - XMONAD_BUILD_SCREEN_WIDTH = 1920; XMONAD_BUILD_TERM_FONT_WIDTH = 10; XMONAD_BUILD_TERM_FONT = "xft:Input Mono:size=12:style=Regular"; XMONAD_BUILD_TERM_PADDING = 2; }; }.${config.krebs.build.host.name} or { - XMONAD_BUILD_SCREEN_WIDTH = 1366; XMONAD_BUILD_TERM_FONT_WIDTH = 6; XMONAD_BUILD_TERM_FONT = "-*-clean-*-*-*-*-*-*-*-*-*-*-iso10646-1"; XMONAD_BUILD_TERM_PADDING = 2; diff --git a/modules/backup.nix b/modules/backup.nix new file mode 100644 index 0000000..37f8e67 --- /dev/null +++ b/modules/backup.nix @@ -0,0 +1,252 @@ +{ config, lib, pkgs, ... }: +with import ../lib/pure.nix { inherit lib; }; +let + out = { + options.krebs.backup = api; + config = lib.mkIf cfg.enable imp; + }; + + cfg = config.krebs.backup; + + api = { + enable = mkEnableOption "krebs.backup" // { default = true; }; + plans = mkOption { + default = {}; + type = types.attrsOf (types.submodule ({ config, ... }: { + options = { + enable = mkEnableOption "krebs.backup.${config._module.args.name}" // { + default = true; + }; + method = mkOption { + type = types.enum ["pull" "push"]; + }; + name = mkOption { + type = types.str; + default = config._module.args.name; + defaultText = "‹name›"; + }; + src = mkOption { + type = types.krebs.file-location; + }; + dst = mkOption { + type = types.krebs.file-location; + }; + startAt = mkOption { + default = "hourly"; + type = with types; nullOr str; # TODO systemd.time(7)'s calendar event + }; + snapshots = mkOption { + default = { + hourly = { format = "%Y-%m-%dT%H"; retain = 4; }; + daily = { format = "%Y-%m-%d"; retain = 7; }; + weekly = { format = "%YW%W"; retain = 4; }; + monthly = { format = "%Y-%m"; retain = 12; }; + yearly = { format = "%Y"; }; + }; + type = types.attrsOf (types.submodule { + options = { + format = mkOption { + type = types.str; # TODO date's +FORMAT + }; + retain = mkOption { + type = types.nullOr types.int; + default = null; # null = retain all snapshots + }; + }; + }); + }; + timerConfig = mkOption { + type = with types; attrsOf str; + default = optionalAttrs (config.startAt != null) { + OnCalendar = config.startAt; + }; + }; + }; + })); + }; + }; + + imp = { + krebs.on-failure.plans = + listToAttrs (map (plan: nameValuePair "backup.${plan.name}" { + }) (filter (plan: build-host-is "pull" "dst" plan || + build-host-is "push" "src" plan) + enabled-plans)); + + systemd.services = + listToAttrs (map (plan: nameValuePair "backup.${plan.name}" { + # TODO if there is plan.user, then use its privkey + # TODO push destination users need a similar path + path = with pkgs; [ + coreutils + gnused + openssh + rsync + util-linux + ]; + restartIfChanged = false; + serviceConfig = rec { + ExecStart = start plan; + SyslogIdentifier = ExecStart.name; + Type = "oneshot"; + }; + }) (filter (plan: build-host-is "pull" "dst" plan || + build-host-is "push" "src" plan) + enabled-plans)); + + systemd.timers = + listToAttrs (map (plan: nameValuePair "backup.${plan.name}" { + wantedBy = [ "timers.target" ]; + timerConfig = plan.timerConfig; + }) (filter (plan: plan.timerConfig != {} && ( + build-host-is "pull" "dst" plan || + build-host-is "push" "src" plan)) + enabled-plans)); + + users.groups.backup.gid = genid "backup"; + users.users.root.openssh.authorizedKeys.keys = + map (plan: getAttr plan.method { + push = plan.src.host.ssh.pubkey; + pull = plan.dst.host.ssh.pubkey; + }) (filter (plan: build-host-is "pull" "src" plan || + build-host-is "push" "dst" plan) + enabled-plans); + }; + + enabled-plans = filter (getAttr "enable") (attrValues cfg.plans); + + build-host-is = method: side: plan: + plan.method == method && + config.krebs.build.host.name == plan.${side}.host.name; + + start = plan: let + login-name = "root"; + identity = local.host.ssh.privkey.path; + ssh = "ssh -i ${shell.escape identity}"; + local = getAttr plan.method { + push = plan.src // { rsync = src-rsync; }; + pull = plan.dst // { rsync = dst-rsync; }; + }; + remote = getAttr plan.method { + push = plan.dst // { rsync = dst-rsync; }; + pull = plan.src // { rsync = src-rsync; }; + }; + src-rsync = "rsync"; + dst-rsync = concatStringsSep " && " [ + "stat ${shell.escape plan.dst.path} >/dev/null" + "mkdir -m 0700 -p ${shell.escape plan.dst.path}/current" + "flock -n ${shell.escape plan.dst.path} rsync" + ]; + in pkgs.writeBash "backup.${plan.name}" '' + set -efu + start_date=$(date +%s) + ssh_target=${shell.escape login-name}@$(${fastest-address remote.host}) + ${getAttr plan.method { + push = '' + rsync_src=${shell.escape plan.src.path} + rsync_dst=$ssh_target:${shell.escape plan.dst.path} + echo >&2 "update snapshot current; $rsync_src -> $rsync_dst" + ''; + pull = '' + rsync_src=$ssh_target:${shell.escape plan.src.path} + rsync_dst=${shell.escape plan.dst.path} + echo >&2 "update snapshot current; $rsync_dst <- $rsync_src" + ''; + }} + # In `dst-rsync`'s `mkdir m 0700 -p` above, we care only about permission + # of the deepest directory: + # shellcheck disable=SC2174 + ${local.rsync} >&2 \ + -aAX --delete \ + --filter='dir-merge /.backup-filter' \ + --rsh=${shell.escape ssh} \ + --rsync-path=${shell.escape remote.rsync} \ + --link-dest=${shell.escape plan.dst.path}/current \ + "$rsync_src/" \ + "$rsync_dst/.partial" + + dst_exec() { + ${getAttr plan.method { + push = ''exec ${ssh} "$ssh_target" -T "exec$(printf ' %q' "$@")"''; + pull = ''exec "$@"''; + }} + } + dst_exec env \ + start_date="$start_date" \ + flock -n ${shell.escape plan.dst.path} \ + /bin/sh < ${toFile "backup.${plan.name}.take-snapshots" '' + set -efu + : $start_date + + dst_path=${shell.escape plan.dst.path} + + mv "$dst_path/current" "$dst_path/.previous" + mv "$dst_path/.partial" "$dst_path/current" + rm -fR "$dst_path/.previous" + echo >&2 + + snapshot() {( + : $ns $format $retain + name=$(date --date="@$start_date" +"$format") + if ! test -e "$dst_path/$ns/$name"; then + echo >&2 "create snapshot: $ns/$name" + mkdir -m 0700 -p "$dst_path/$ns" + rsync >&2 \ + -aAX --delete \ + --filter='dir-merge /.backup-filter' \ + --link-dest="$dst_path/current" \ + "$dst_path/current/" \ + "$dst_path/$ns/.partial.$name" + mv "$dst_path/$ns/.partial.$name" "$dst_path/$ns/$name" + echo >&2 + fi + case $retain in + ([0-9]*) + delete_from=$(($retain + 1)) + ls -r "$dst_path/$ns" \ + | sed -n "$delete_from,\$p" \ + | while read old_name; do + echo >&2 "delete snapshot: $ns/$old_name" + rm -fR "$dst_path/$ns/$old_name" + done + ;; + (ALL) + : + ;; + esac + )} + + ${concatStringsSep "\n" (mapAttrsToList (ns: { format, retain, ... }: + toString (map shell.escape [ + "ns=${ns}" + "format=${format}" + "retain=${if retain == null then "ALL" else toString retain}" + "snapshot" + ])) + plan.snapshots)} + ''} + ''; + + # XXX Is one ping enough to determine fastest address? + fastest-address = host: '' + { ${pkgs.fping}/bin/fping </dev/null -a -e \ + ${concatMapStringsSep " " shell.escape + (mapAttrsToList (_: net: head net.aliases) host.nets)} \ + | ${pkgs.gnused}/bin/sed -r 's/^(\S+) \(([0-9.]+) ms\)$/\2\t\1/' \ + | ${pkgs.coreutils}/bin/sort -n \ + | ${pkgs.coreutils}/bin/cut -f2 \ + | ${pkgs.coreutils}/bin/head -n 1 + } + ''; + +in out +# TODO ionice +# TODO mail on missing push +# TODO don't cancel plans on activation +# also, don't hang while deploying at: +# starting the following units: backup.wu-home-xu.push.service, backup.wu-home-xu.push.timer +# TODO make sure that secure hosts cannot backup to insecure ones +# TODO optionally only backup when src and dst are near enough :) +# TODO try using btrfs for snapshots (configurable) +# TODO warn if partial snapshots are found +# TODO warn if unknown stuff is found in dst path diff --git a/modules/hw.nix b/modules/hw.nix deleted file mode 100644 index 653b04f..0000000 --- a/modules/hw.nix +++ /dev/null @@ -1,15 +0,0 @@ -{ lib, mylib, ... }: let - local.types.screen = lib.types.submodule { - options.width = lib.mkOption { - type = mylib.types.uint; - }; - options.height = lib.mkOption { - type = mylib.types.uint; - }; - }; -in { - options.tv.hw.screens = lib.mkOption { - type = lib.types.attrsOf local.types.screen; - default = {}; - }; -} diff --git a/pkgs/haskell/desktop-pager.nix b/pkgs/haskell/desktop-pager.nix index 3b96159..8301235 100644 --- a/pkgs/haskell/desktop-pager.nix +++ b/pkgs/haskell/desktop-pager.nix @@ -1,15 +1,15 @@ { mkDerivation, aeson, base, blessings, bytestring, containers , data-default, extra, fetchgit, hack, lib, optparse-applicative -, probability, scanner, speculate, split, terminal-size, text, unix -, utf8-string, X11 +, probability, speculate, split, terminal-scanner, terminal-size +, text, unix, utf8-string, X11 }: mkDerivation { pname = "desktop-pager"; version = "1.0.0"; src = fetchgit { url = "https://cgit.krebsco.de/desktop-pager"; - sha256 = "11v4f2sz6p69fx2804w0akb8xqv56g89chjyx77jhwqcng2bn6pw"; - rev = "0894fbe50ee2f63b510d32ab8c524134e450f20d"; + sha256 = "1hb8an31szwx9zixzb1m7219jrz3cdz57phf45r4b3n6qrzcn35l"; + rev = "3919fb8adc06134a304d4fcbcd192c8707c06cbd"; fetchSubmodules = true; }; isLibrary = true; @@ -17,7 +17,7 @@ mkDerivation { libraryHaskellDepends = [ base extra utf8-string X11 ]; executableHaskellDepends = [ aeson base blessings bytestring containers data-default hack - optparse-applicative probability scanner speculate split + optparse-applicative probability speculate split terminal-scanner terminal-size text unix X11 ]; license = lib.licenses.mit; diff --git a/pkgs/haskell/hack.nix b/pkgs/haskell/hack.nix index f1b22b5..0eb0232 100644 --- a/pkgs/haskell/hack.nix +++ b/pkgs/haskell/hack.nix @@ -1,13 +1,14 @@ { mkDerivation, base, blessings, containers, data-default, fetchgit -, lens, lib, mtl, old-locale, process, input-scanner, time, unix, zippers +, lens, lib, mtl, old-locale, process, terminal-scanner, time, unix +, zippers }: mkDerivation { pname = "hack"; - version = "1.0.2"; + version = "1.0.3"; src = fetchgit { url = "https://cgit.krebsco.de/hack"; - hash = "sha256-QHSGF4wFwLyn8W8jYbN1QajMnmQqUI+7VWk7yVvJgIg="; - rev = "refs/tags/1.0.2"; + sha256 = "04vxcfm204sxn3v48ch27srgqgpiqbm9i82lrmgp1yyx84wchq32"; + rev = "a6fc1e51f1f87a7cc485a47000f23f1f054beb95"; fetchSubmodules = true; }; isLibrary = true; @@ -15,7 +16,8 @@ mkDerivation { libraryHaskellDepends = [ base ]; executableHaskellDepends = [ base blessings containers data-default lens mtl old-locale process - input-scanner time unix zippers + terminal-scanner time unix zippers ]; license = lib.licenses.mit; + mainProgram = "hack"; } diff --git a/pkgs/haskell/much.nix b/pkgs/haskell/much.nix index 865294d..9744a25 100644 --- a/pkgs/haskell/much.nix +++ b/pkgs/haskell/much.nix @@ -3,17 +3,17 @@ , containers, data-default, deepseq, directory, either , email-header, fetchgit, filepath, friendly-time, http-types , hyphenation, lib, linebreak, network, old-locale -, optparse-applicative, process, random, rosezipper, safe, scanner -, servant-server, split, terminal-size, text, time, transformers -, transformers-compat, unix, vector, wai, warp +, optparse-applicative, process, random, rosezipper, safe +, servant-server, split, terminal-scanner, terminal-size, text +, time, transformers, transformers-compat, unix, vector, wai, warp }: mkDerivation rec { pname = "much"; version = "1.3.2"; src = fetchgit { url = "https://cgit.krebsco.de/much"; - hash = "sha256-q65EYO1d3NYVv2NECkGWPb1TyHGdARNi/GX4pgQmljc="; - rev = "refs/tags/${version}"; + sha256 = "001lvn4f3pgxwq0fgxvk0jl33r54gvh908r6wx02fw4s6b3sysc0"; + rev = "3a0fe1da7c33b024128079f5810c6a99b25aebe7"; fetchSubmodules = true; }; isLibrary = true; @@ -23,14 +23,15 @@ mkDerivation rec { bytestring case-insensitive containers data-default deepseq directory either email-header filepath friendly-time http-types hyphenation linebreak network old-locale optparse-applicative - process random rosezipper safe scanner servant-server split - terminal-size text time transformers transformers-compat unix - vector wai warp + process random rosezipper safe servant-server split + terminal-scanner terminal-size text time transformers + transformers-compat unix vector wai warp ]; executableHaskellDepends = [ aeson base blessings bytestring case-insensitive containers data-default deepseq directory filepath hyphenation linebreak - process rosezipper safe scanner text time transformers unix + process rosezipper safe terminal-scanner text time transformers + unix ]; license = lib.licenses.mit; } diff --git a/pkgs/haskell/terminal-scanner.nix b/pkgs/haskell/terminal-scanner.nix new file mode 100644 index 0000000..4801df7 --- /dev/null +++ b/pkgs/haskell/terminal-scanner.nix @@ -0,0 +1,13 @@ +{ mkDerivation, base, fetchgit, lib }: +mkDerivation { + pname = "terminal-scanner"; + version = "1.0.1"; + src = fetchgit { + url = "https://cgit.krebsco.de/terminal-scanner"; + sha256 = "1ic8j2nlhmy76fnqji277wsl1cikd9y4lwqqcxzldjx1vi61r13r"; + rev = "3c5301303230f563214c5ff003f9fc8e2e0a7199"; + fetchSubmodules = true; + }; + libraryHaskellDepends = [ base ]; + license = lib.licenses.mit; +} diff --git a/pkgs/haskell/xmonad-tv/src/main.hs b/pkgs/haskell/xmonad-tv/src/main.hs index e3090a3..711f9eb 100644 --- a/pkgs/haskell/xmonad-tv/src/main.hs +++ b/pkgs/haskell/xmonad-tv/src/main.hs @@ -73,7 +73,8 @@ mainNoArgs = do myMasterDelta <- readEnv' (1 / 20) "XMONAD_MASTER_DELTA" :: IO Rational myMasterWidth <- readEnv' (1 / 2) "XMONAD_MASTER_WIDTH" :: IO Rational myScreenGaps <- readEnv' [] "XMONAD_SCREEN_GAPS" :: IO [Int] - myScreenWidth <- readEnv "XMONAD_SCREEN_WIDTH" :: IO Dimension + myScreenWidth <- + bracket (getEnv "DISPLAY" >>= openDisplay) closeDisplay (return . widthOfScreen . defaultScreenOfDisplay) handleShutdownEvent <- newShutdownEventHandler config <- ewmhExtra @@ -151,7 +152,9 @@ myKeys conf = Map.fromList $ , ((_4S , xK_c ), kill) , ((_4 , xK_o ), forkFile {-pkg:fzmenu-}"otpmenu" [] Nothing) + , ((_4C , xK_o ), forkFile {-pkg:fzmenu-}"otpmenu" ["--phase2-method=copy"] Nothing) , ((_4 , xK_p ), forkFile {-pkg:fzmenu-}"passmenu" [] Nothing) + , ((_4C , xK_p ), forkFile {-pkg:fzmenu-}"passmenu" ["--phase2-method=copy"] Nothing) , ((_4 , xK_x ), forkFile {-pkg:alacritty-tv-}"alacritty" ["--singleton"] Nothing) , ((_4C , xK_x ), spawnRootTerm) diff --git a/pkgs/haskell/xoutinfo.nix b/pkgs/haskell/xoutinfo.nix index 64b6f87..fc983d6 100644 --- a/pkgs/haskell/xoutinfo.nix +++ b/pkgs/haskell/xoutinfo.nix @@ -1,11 +1,11 @@ { mkDerivation, aeson, base, bytestring, fetchgit, lib, X11 }: mkDerivation { pname = "xoutinfo"; - version = "0.1.0.0"; + version = "0.1.1.0"; src = fetchgit { url = "https://cgit.ni.krebsco.de/xoutinfo"; - sha256 = "1g3s9vyy7bpsl2zjiq6kk16c8hhf3n2yz4lv3ic0qy0n6wn6qqi8"; - rev = "cf7377886a55e36701bd0d5ce7c723aa6d7bd9bd"; + hash = "sha256-QSyCal5E7O1JBlZ7OV3aM8j68YozKyKgYhL2HYFTsvg="; + rev = "0.1.1.0"; fetchSubmodules = true; }; isLibrary = false; diff --git a/pkgs/simple/alacritty-tv.nix b/pkgs/simple/alacritty-tv.nix index bea5776..0d2fe59 100644 --- a/pkgs/simple/alacritty-tv.nix +++ b/pkgs/simple/alacritty-tv.nix @@ -26,6 +26,11 @@ pkgs.symlinkJoin { config=/etc/alacritty/default.toml fi + export WINIT_X11_SCALE_FACTOR=$( + ${pkgs.haskellPackages.xoutinfo}/bin/xoutinfo | + ${pkgs.jq}/bin/jq .device_scale_factor + ) + case ''${1-} in --singleton) shift diff --git a/pkgs/simple/fzmenu/bin/otpmenu b/pkgs/simple/fzmenu/bin/otpmenu index 714ab7c..59706c1 100755 --- a/pkgs/simple/fzmenu/bin/otpmenu +++ b/pkgs/simple/fzmenu/bin/otpmenu @@ -1,8 +1,22 @@ #! /bin/sh +# usage: otpmenu [--phase2-method=METHOD] +# where METHOD is either copy or type, type being the default. set -efu #PATH= +while test $# -gt 0; do + case $1 in + --phase2-method=copy|--phase2-method=type) + export FZMENU_PHASE2_METHOD=${1#*=} + shift 1 + ;; + *) + echo "$0: error: bad argument: $1" >&2 + exit 1 + esac +done + case ${FZMENU_PHASE-0} in 0) export FZMENU_PHASE=1 @@ -25,7 +39,7 @@ case ${FZMENU_PHASE-0} in exec fzf \ --history=/dev/null \ --no-sort \ - --prompt='OTP: ' \ + --prompt="${FZMENU_PHASE2_METHOD-type} otp: " \ ) then export FZMENU_PHASE=2 @@ -38,8 +52,19 @@ case ${FZMENU_PHASE-0} in # lucidatypewriter, causing a warning to be printed to stderr. font='-*-clean-*-*-*-*-*-*-*-*-*-*-iso10646-1' pass=$(pass otp code "$FZMENU_RESULT/otp") - printf %s "$pass" | - xvkbd -xrm "xvkbd*Font: $font" -xsendevent -file - + case ${FZMENU_PHASE2_METHOD-type} in + copy) + printf %s "$pass" | + xsel -p -i -t 60000 + ;; + type) + printf %s "$pass" | + xvkbd -xrm "xvkbd*Font: $font" -xsendevent -file - + ;; + *) + echo "$0: error: bad phase2 method: $FZMENU_PHASE2_METHOD" >&2 + exit -1 + esac ;; *) echo "$0: error: bad phase: $FZMENU_PHASE" >&2 diff --git a/pkgs/simple/fzmenu/bin/passmenu b/pkgs/simple/fzmenu/bin/passmenu index a798925..0b07174 100755 --- a/pkgs/simple/fzmenu/bin/passmenu +++ b/pkgs/simple/fzmenu/bin/passmenu @@ -1,8 +1,22 @@ #! /bin/sh +# usage: passmenu [--phase2-method=METHOD] +# where METHOD is either copy or type, type being the default. set -efu #PATH= +while test $# -gt 0; do + case $1 in + --phase2-method=copy|--phase2-method=type) + export FZMENU_PHASE2_METHOD=${1#*=} + shift 1 + ;; + *) + echo "$0: error: bad argument: $1" >&2 + exit 1 + esac +done + case ${FZMENU_PHASE-0} in 0) export FZMENU_PHASE=1 @@ -26,7 +40,7 @@ case ${FZMENU_PHASE-0} in exec fzf \ --history=/dev/null \ --no-sort \ - --prompt='pass: ' \ + --prompt="${FZMENU_PHASE2_METHOD-type} pass: " \ ) then export FZMENU_PHASE=2 @@ -39,8 +53,19 @@ case ${FZMENU_PHASE-0} in # lucidatypewriter, causing a warning to be printed to stderr. font='-*-clean-*-*-*-*-*-*-*-*-*-*-iso10646-1' pass=$(pass show "$FZMENU_RESULT") - printf %s "$pass" | - xvkbd -xrm "xvkbd*Font: $font" -xsendevent -file - + case ${FZMENU_PHASE2_METHOD-type} in + copy) + printf %s "$pass" | + xsel -p -i -t 60000 + ;; + type) + printf %s "$pass" | + xvkbd -xrm "xvkbd*Font: $font" -xsendevent -file - + ;; + *) + echo "$0: error: bad phase2 method: $FZMENU_PHASE2_METHOD" >&2 + exit -1 + esac ;; *) echo "$0: error: bad phase: $FZMENU_PHASE" >&2 diff --git a/pkgs/simple/fzmenu/default.nix b/pkgs/simple/fzmenu/default.nix index c4dccbf..e709d74 100644 --- a/pkgs/simple/fzmenu/default.nix +++ b/pkgs/simple/fzmenu/default.nix @@ -28,6 +28,7 @@ pkgs.runCommand "fzmenu" { ext.pass-otp ])) pkgs.utillinux + pkgs.xsel pkgs.xvkbd terminal ]} @@ -44,6 +45,7 @@ pkgs.runCommand "fzmenu" { ext.pass-otp ])) pkgs.utillinux + pkgs.xsel pkgs.xvkbd terminal ]} diff --git a/systems/xu/config.nix b/systems/xu/config.nix index ee7ae46..603d0d4 100644 --- a/systems/xu/config.nix +++ b/systems/xu/config.nix @@ -140,8 +140,13 @@ gptfdisk ]; + networking.usePredictableInterfaceNames = false; + networking.wireless.enable = true; + networking.interfaces.eth0.useDHCP = true; + networking.interfaces.eth0.wakeOnLan.enable = true; + #services.bitlbee.enable = true; #services.tor.client.enable = true; #services.tor.enable = true; |