From 10adb2d27e3005c7239585eb38dbbe3b5b01a400 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 28 Jun 2017 03:31:14 +0200 Subject: whatsupnix: use gawk and nix-store explicitly --- krebs/5pkgs/simple/whatsupnix/whatsupnix.bash | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/krebs/5pkgs/simple/whatsupnix/whatsupnix.bash b/krebs/5pkgs/simple/whatsupnix/whatsupnix.bash index 04276304..12720957 100644 --- a/krebs/5pkgs/simple/whatsupnix/whatsupnix.bash +++ b/krebs/5pkgs/simple/whatsupnix/whatsupnix.bash @@ -17,15 +17,12 @@ # 2 Build error; at least one failed derivation could be found. # -GAWK=${GAWK:-gawk} -NIX_STORE=${NIX_STORE:-nix-store} - failed_drvs=$(mktemp --tmpdir whatsupnix.XXXXXXXX) trap 'rm -f -- "$failed_drvs"' EXIT exec >&2 -$GAWK -v failed_drvs="$failed_drvs" ' +gawk -v failed_drvs="$failed_drvs" ' match($0, /^builder for ‘(\/nix\/store\/[^’]+\.drv)’ failed/, m) { print m[1] >> failed_drvs } @@ -35,7 +32,7 @@ $GAWK -v failed_drvs="$failed_drvs" ' case $# in 0) print_log() { - NIX_PAGER= $NIX_STORE -l "$1" + NIX_PAGER= nix-store -l "$1" } ;; 1) -- cgit v1.2.3 From ed71d568831941632d2fa6e783d10d703c4ceee6 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 29 Jun 2017 22:06:13 +0200 Subject: shell: init --- shell.nix | 210 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100644 shell.nix diff --git a/shell.nix b/shell.nix new file mode 100644 index 00000000..d6e09e1a --- /dev/null +++ b/shell.nix @@ -0,0 +1,210 @@ +{ nixpkgs ? import {} }: let + + inherit (nixpkgs) lib pkgs; + slib = import ./lib; + spkgs = { + populate = pkgs.callPackage ./krebs/5pkgs/simple/populate {}; + whatsupnix = pkgs.callPackage ./krebs/5pkgs/simple/whatsupnix {}; + }; + + # usage: deploy system=SYSTEM [target=TARGET] + cmds.deploy = pkgs.writeScript "cmds.deploy" /* sh */ '' + #! ${pkgs.dash}/bin/dash + set -efu + + command=deploy + . ${init.args} + \test -n "''${target-}" || target=$system + . ${init.env} + + exec ${utils.deploy} + ''; + + # usage: test system=SYSTEM target=TARGET + cmds.test = pkgs.writeScript "cmds.test" /* sh */ '' + #! ${pkgs.dash}/bin/dash + set -efu + + command=test + . ${init.args} + . ${init.env} + + export dummy_secrets=true + exec ${utils.build} config.system.build.toplevel + ''; + + init.args = pkgs.writeText "init.args" /* sh */ '' + fail= + for arg; do + case $arg in + system=*) system=''${arg#*=};; + target=*) target=''${arg#*=};; + *) echo "$command: bad argument: $arg" >&2; fail=1 + esac + done + if \test -n "$fail"; then + exit 1 + fi + unset fail + ''; + + init.env = pkgs.writeText "init.env" /* sh */ '' + config=''${config-$LOGNAME/1systems/$system.nix} + + export config + export system + export target + + export target_object="$(${init.env.parsetarget} $target)" + export target_user="$(echo $target_object | ${pkgs.jq}/bin/jq -r .user)" + export target_host="$(echo $target_object | ${pkgs.jq}/bin/jq -r .host)" + export target_port="$(echo $target_object | ${pkgs.jq}/bin/jq -r .port)" + export target_path="$(echo $target_object | ${pkgs.jq}/bin/jq -r .path)" + export target_local="$(echo $target_object | ${pkgs.jq}/bin/jq -r .local)" + + export qtarget="$target_user@$target_host:$target_port$target_path" + + ${init.env.populate} + + if \test "$target_local" != true && \test "''${DISABLE_PROXY-}" != 1; then + exec ${init.env.proxy} "$command" "$@" + fi + '' // { + parsetarget = pkgs.writeScript "init.env.parsetarget" /* sh */ '' + #! ${pkgs.dash}/bin/dash + set -efu + exec ${pkgs.jq}/bin/jq \ + -enr \ + --arg target "$1" \ + -f ${init.env.parsetarget.jq} + '' // { + jq = pkgs.writeText "init.env.parsetarget.jq" '' + def when(c; f): if c then f else . end; + def capturesDef(i; v): .captures[i].string | when(. == null; v); + $target | match("^(?:([^@]+)@)?([^:/]+)?(?::([0-9]+))?(/.*)?$") | { + user: capturesDef(0; "root"), + host: capturesDef(1; env.system), + port: capturesDef(2; "22"), + path: capturesDef(3; "/var/src"), + } | . + { + local: (.user == env.LOGNAME and .host == env.HOSTNAME), + } + ''; + }; + populate = pkgs.writeScript "init.env.populate" /* sh */ '' + #! ${pkgs.dash}/bin/dash + set -efu + if \test "''${DISABLE_POPULATE-}" = 1; then + exit + fi + set -x + ${pkgs.nix}/bin/nix-instantiate \ + --eval \ + --json \ + --readonly-mode \ + --show-trace \ + --strict \ + -I nixos-config="$config" \ + -E 'with import ; config.krebs.build.source' \ + | + ${spkgs.populate}/bin/populate "$qtarget" >&2 + ''; + proxy = pkgs.writeScript "init.env.proxy" /* sh */ '' + #! ${pkgs.dash}/bin/dash + set -efu + q() { + ${pkgs.jq}/bin/jq -nr --arg x "$*" '$x | @sh "\(.)"' + } + exec ${pkgs.openssh}/bin/ssh \ + "$target_user@$target_host" -p "$target_port" \ + cd "$target_path/stockholm" \; \ + NIX_PATH=$(q "$target_path") \ + STOCKHOLM_VERSION=$STOCKHOLM_VERSION \ + nix-shell \ + --command $(q \ + config=$config \ + system=$system \ + target=$target \ + DISABLE_POPULATE=1 \ + DISABLE_PROXY=1 \ + "$*" + ) + ''; + }; + + utils.build = pkgs.writeScript "utils.build" /* sh */ '' + #! ${pkgs.dash}/bin/dash + set -efu + expr=$1 + shift + ${pkgs.nix}/bin/nix-build \ + -Q \ + --no-out-link \ + --show-trace \ + -E "with import ; $expr" \ + -I "$target_path" \ + "$@" \ + 2>&1 | + ${pkgs.coreutils}/bin/stdbuf -oL ${spkgs.whatsupnix}/bin/whatsupnix + ''; + + utils.deploy = pkgs.writeScript "utils.deploy" /* sh */ '' + #! ${pkgs.dash}/bin/dash + set -efu + PATH=/run/current-system/sw/bin nixos-rebuild \ + switch \ + -Q \ + --show-trace \ + -I "$target_path" \ + "$@" \ + 2>&1 | + ${pkgs.coreutils}/bin/stdbuf -oL ${spkgs.whatsupnix}/bin/whatsupnix + ''; + + hook.get-version = pkgs.writeScript "hook.get-version" /* sh */ '' + #! ${pkgs.dash}/bin/dash + set -efu + version=git.$(${pkgs.git}/bin/git describe --always --dirty) + case $version in (*-dirty) + version=$version@$HOSTNAME + esac + date=$(${pkgs.coreutils}/bin/date +%y.%m) + echo "$date.$version" + ''; + + hook.pkg = pkgs.runCommand "hook.pkg" {} /* sh */ '' + mkdir -p $out/bin + ${lib.concatStrings (lib.mapAttrsToList (name: path: /* sh */ '' + ln -s ${path} $out/bin/${name} + '') cmds)} + ''; + +in pkgs.stdenv.mkDerivation { + name = "stockholm"; + shellHook = '' + export NIX_PATH="stockholm=$PWD''${NIX_PATH+:$NIX_PATH}" + export PATH=${lib.makeBinPath [ + hook.pkg + ]} + + eval "$(declare -F | ${pkgs.gnused}/bin/sed s/declare/unset/)" + shopt -u no_empty_cmd_completion + unalias -a + + enable -n \ + . [ alias bg bind break builtin caller cd command compgen complete \ + compopt continue dirs disown eval exec false fc fg getopts hash \ + help history jobs kill let local logout mapfile popd printf pushd \ + pwd read readarray readonly shift source suspend test times trap \ + true typeset ulimit umask unalias wait + + exitHandler() { + : + } + + export HOSTNAME="$(${pkgs.nettools}/bin/hostname)" + export STOCKHOLM_VERSION="''${STOCKHOLM_VERSION-$(${hook.get-version})}" + + PS1='\[\e[38;5;162m\]\w\[\e[0m\] ' + ''; +} -- cgit v1.2.3 From 0d9ded0b58b79fd35fa14f41726d9f8a4aa4a78e Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 29 Jun 2017 23:51:16 +0200 Subject: Revert "k 4 infest: prepare Regression for stockholm" This reverts commit d58e8035b4101b20539279247ec083b72ba0a647. --- krebs/4lib/infest/prepare.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/krebs/4lib/infest/prepare.sh b/krebs/4lib/infest/prepare.sh index 8e921ce0..50d521e1 100644 --- a/krebs/4lib/infest/prepare.sh +++ b/krebs/4lib/infest/prepare.sh @@ -36,7 +36,14 @@ prepare() {( ;; esac ;; - nixos|stockholm) + nixos) + case $(cat /proc/cmdline) in + *' root=LABEL=NIXOS_ISO '*) + prepare_nixos_iso "$@" + exit + esac + ;; + stockholm) case $(cat /proc/cmdline) in *' root=LABEL=NIXOS_ISO '*) prepare_nixos_iso "$@" @@ -95,8 +102,7 @@ prepare_nixos_iso() { mkdir -p bin rm -f bin/nixos-install cp "$(type -p nixos-install)" bin/nixos-install - sed -i 's@^\(\(export \|\)NIX_PATH\)=\"[^\"]*\"@\1=$target_path@' bin/nixos-install - + sed -i "s@^NIX_PATH=\"[^\"]*\"@NIX_PATH=$target_path@" bin/nixos-install } get_nixos_install() { @@ -211,7 +217,7 @@ prepare_common() {( mkdir -p bin rm -f bin/nixos-install cp "$(type -p nixos-install)" bin/nixos-install - sed -i 's@^\(\(export \|\)NIX_PATH\)=\"[^\"]*\"@\1=$target_path@' bin/nixos-install + sed -i "s@^NIX_PATH=\"[^\"]*\"@NIX_PATH=$target_path@" bin/nixos-install if ! grep -q '^PATH.*#krebs' .bashrc; then echo '. /root/.nix-profile/etc/profile.d/nix.sh' >> .bashrc -- cgit v1.2.3 From b9c11e44e779769ca0a6b13eedee82782bc63927 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 30 Jun 2017 03:16:24 +0200 Subject: shell: mark shellHook as sh --- shell.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell.nix b/shell.nix index d6e09e1a..26db52c3 100644 --- a/shell.nix +++ b/shell.nix @@ -181,7 +181,7 @@ in pkgs.stdenv.mkDerivation { name = "stockholm"; - shellHook = '' + shellHook = /* sh */ '' export NIX_PATH="stockholm=$PWD''${NIX_PATH+:$NIX_PATH}" export PATH=${lib.makeBinPath [ hook.pkg -- cgit v1.2.3 From 849d0ba98f03dc8700e6b9bb724b9afdbde68713 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 30 Jun 2017 04:27:02 +0200 Subject: shell: using proxy implies populated target --- shell.nix | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/shell.nix b/shell.nix index 26db52c3..9cc74066 100644 --- a/shell.nix +++ b/shell.nix @@ -64,10 +64,11 @@ export qtarget="$target_user@$target_host:$target_port$target_path" - ${init.env.populate} - - if \test "$target_local" != true && \test "''${DISABLE_PROXY-}" != 1; then - exec ${init.env.proxy} "$command" "$@" + if \test "''${using_proxy-}" != true; then + ${init.env.populate} + if \test "$target_local" != true; then + exec ${init.env.proxy} "$command" "$@" + fi fi '' // { parsetarget = pkgs.writeScript "init.env.parsetarget" /* sh */ '' @@ -94,10 +95,6 @@ populate = pkgs.writeScript "init.env.populate" /* sh */ '' #! ${pkgs.dash}/bin/dash set -efu - if \test "''${DISABLE_POPULATE-}" = 1; then - exit - fi - set -x ${pkgs.nix}/bin/nix-instantiate \ --eval \ --json \ @@ -125,8 +122,7 @@ config=$config \ system=$system \ target=$target \ - DISABLE_POPULATE=1 \ - DISABLE_PROXY=1 \ + using_proxy=true \ "$*" ) ''; -- cgit v1.2.3 From 7d983f09c8433b623ffb49435807d3417a93776b Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 30 Jun 2017 04:27:25 +0200 Subject: shell: inline qtarget --- shell.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shell.nix b/shell.nix index 9cc74066..e16f172e 100644 --- a/shell.nix +++ b/shell.nix @@ -62,8 +62,6 @@ export target_path="$(echo $target_object | ${pkgs.jq}/bin/jq -r .path)" export target_local="$(echo $target_object | ${pkgs.jq}/bin/jq -r .local)" - export qtarget="$target_user@$target_host:$target_port$target_path" - if \test "''${using_proxy-}" != true; then ${init.env.populate} if \test "$target_local" != true; then @@ -104,7 +102,9 @@ -I nixos-config="$config" \ -E 'with import ; config.krebs.build.source' \ | - ${spkgs.populate}/bin/populate "$qtarget" >&2 + ${spkgs.populate}/bin/populate \ + "$target_user@$target_host:$target_port$target_path" \ + >&2 ''; proxy = pkgs.writeScript "init.env.proxy" /* sh */ '' #! ${pkgs.dash}/bin/dash -- cgit v1.2.3 From 74522bba94a3a62dcaed15c6ab9ff4e064a654ab Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 30 Jun 2017 04:40:45 +0200 Subject: shell: use stockholm overlay --- shell.nix | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/shell.nix b/shell.nix index e16f172e..d8f3184d 100644 --- a/shell.nix +++ b/shell.nix @@ -1,11 +1,7 @@ -{ nixpkgs ? import {} }: let +{ nixpkgs ? import { overlays = [(import ./krebs/5pkgs)]; } }: let inherit (nixpkgs) lib pkgs; slib = import ./lib; - spkgs = { - populate = pkgs.callPackage ./krebs/5pkgs/simple/populate {}; - whatsupnix = pkgs.callPackage ./krebs/5pkgs/simple/whatsupnix {}; - }; # usage: deploy system=SYSTEM [target=TARGET] cmds.deploy = pkgs.writeScript "cmds.deploy" /* sh */ '' @@ -102,7 +98,7 @@ -I nixos-config="$config" \ -E 'with import ; config.krebs.build.source' \ | - ${spkgs.populate}/bin/populate \ + ${pkgs.populate}/bin/populate \ "$target_user@$target_host:$target_port$target_path" \ >&2 ''; @@ -141,7 +137,7 @@ -I "$target_path" \ "$@" \ 2>&1 | - ${pkgs.coreutils}/bin/stdbuf -oL ${spkgs.whatsupnix}/bin/whatsupnix + ${pkgs.coreutils}/bin/stdbuf -oL ${pkgs.whatsupnix}/bin/whatsupnix ''; utils.deploy = pkgs.writeScript "utils.deploy" /* sh */ '' @@ -154,7 +150,7 @@ -I "$target_path" \ "$@" \ 2>&1 | - ${pkgs.coreutils}/bin/stdbuf -oL ${spkgs.whatsupnix}/bin/whatsupnix + ${pkgs.coreutils}/bin/stdbuf -oL ${pkgs.whatsupnix}/bin/whatsupnix ''; hook.get-version = pkgs.writeScript "hook.get-version" /* sh */ '' -- cgit v1.2.3 From dbe4cc21e33ccc22b9dd352dd8c6913d60a0cbc0 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 30 Jun 2017 04:53:34 +0200 Subject: pkgs.whatsupnix: print gawk output ASAP --- krebs/5pkgs/simple/whatsupnix/whatsupnix.bash | 2 +- shell.nix | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/krebs/5pkgs/simple/whatsupnix/whatsupnix.bash b/krebs/5pkgs/simple/whatsupnix/whatsupnix.bash index 12720957..2ad9aadc 100644 --- a/krebs/5pkgs/simple/whatsupnix/whatsupnix.bash +++ b/krebs/5pkgs/simple/whatsupnix/whatsupnix.bash @@ -26,7 +26,7 @@ gawk -v failed_drvs="$failed_drvs" ' match($0, /^builder for ‘(\/nix\/store\/[^’]+\.drv)’ failed/, m) { print m[1] >> failed_drvs } - { print $0 } + { print $0; fflush("/dev/stdout") } ' case $# in diff --git a/shell.nix b/shell.nix index d8f3184d..302429a4 100644 --- a/shell.nix +++ b/shell.nix @@ -137,7 +137,7 @@ -I "$target_path" \ "$@" \ 2>&1 | - ${pkgs.coreutils}/bin/stdbuf -oL ${pkgs.whatsupnix}/bin/whatsupnix + ${pkgs.whatsupnix}/bin/whatsupnix ''; utils.deploy = pkgs.writeScript "utils.deploy" /* sh */ '' @@ -150,7 +150,7 @@ -I "$target_path" \ "$@" \ 2>&1 | - ${pkgs.coreutils}/bin/stdbuf -oL ${pkgs.whatsupnix}/bin/whatsupnix + ${pkgs.whatsupnix}/bin/whatsupnix ''; hook.get-version = pkgs.writeScript "hook.get-version" /* sh */ '' -- cgit v1.2.3 From a2ea8740a40d5e9f5dc8e86d33e605a78963fc2f Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 30 Jun 2017 04:56:21 +0200 Subject: shell: use writeDash --- shell.nix | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/shell.nix b/shell.nix index 302429a4..d6d21586 100644 --- a/shell.nix +++ b/shell.nix @@ -4,8 +4,7 @@ slib = import ./lib; # usage: deploy system=SYSTEM [target=TARGET] - cmds.deploy = pkgs.writeScript "cmds.deploy" /* sh */ '' - #! ${pkgs.dash}/bin/dash + cmds.deploy = pkgs.writeDash "cmds.deploy" '' set -efu command=deploy @@ -17,8 +16,7 @@ ''; # usage: test system=SYSTEM target=TARGET - cmds.test = pkgs.writeScript "cmds.test" /* sh */ '' - #! ${pkgs.dash}/bin/dash + cmds.test = pkgs.writeDash "cmds.test" /* sh */ '' set -efu command=test @@ -65,8 +63,7 @@ fi fi '' // { - parsetarget = pkgs.writeScript "init.env.parsetarget" /* sh */ '' - #! ${pkgs.dash}/bin/dash + parsetarget = pkgs.writeDash "init.env.parsetarget" '' set -efu exec ${pkgs.jq}/bin/jq \ -enr \ @@ -86,8 +83,7 @@ } ''; }; - populate = pkgs.writeScript "init.env.populate" /* sh */ '' - #! ${pkgs.dash}/bin/dash + populate = pkgs.writeDash "init.env.populate" '' set -efu ${pkgs.nix}/bin/nix-instantiate \ --eval \ @@ -102,8 +98,7 @@ "$target_user@$target_host:$target_port$target_path" \ >&2 ''; - proxy = pkgs.writeScript "init.env.proxy" /* sh */ '' - #! ${pkgs.dash}/bin/dash + proxy = pkgs.writeDash "init.env.proxy" '' set -efu q() { ${pkgs.jq}/bin/jq -nr --arg x "$*" '$x | @sh "\(.)"' @@ -124,8 +119,7 @@ ''; }; - utils.build = pkgs.writeScript "utils.build" /* sh */ '' - #! ${pkgs.dash}/bin/dash + utils.build = pkgs.writeDash "utils.build" '' set -efu expr=$1 shift @@ -140,8 +134,7 @@ ${pkgs.whatsupnix}/bin/whatsupnix ''; - utils.deploy = pkgs.writeScript "utils.deploy" /* sh */ '' - #! ${pkgs.dash}/bin/dash + utils.deploy = pkgs.writeDash "utils.deploy" '' set -efu PATH=/run/current-system/sw/bin nixos-rebuild \ switch \ @@ -153,8 +146,7 @@ ${pkgs.whatsupnix}/bin/whatsupnix ''; - hook.get-version = pkgs.writeScript "hook.get-version" /* sh */ '' - #! ${pkgs.dash}/bin/dash + hook.get-version = pkgs.writeDash "hook.get-version" '' set -efu version=git.$(${pkgs.git}/bin/git describe --always --dirty) case $version in (*-dirty) -- cgit v1.2.3 From c500d72ad855418b7d4d9d852d423a8a9440285c Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 30 Jun 2017 09:43:33 +0200 Subject: shell: rename hook attribute to shell --- shell.nix | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/shell.nix b/shell.nix index d6d21586..782b4fa3 100644 --- a/shell.nix +++ b/shell.nix @@ -121,32 +121,27 @@ utils.build = pkgs.writeDash "utils.build" '' set -efu - expr=$1 - shift ${pkgs.nix}/bin/nix-build \ -Q \ --no-out-link \ --show-trace \ - -E "with import ; $expr" \ + -E "with import ; $1" \ -I "$target_path" \ - "$@" \ 2>&1 | ${pkgs.whatsupnix}/bin/whatsupnix ''; utils.deploy = pkgs.writeDash "utils.deploy" '' set -efu - PATH=/run/current-system/sw/bin nixos-rebuild \ - switch \ + PATH=/run/current-system/sw/bin nixos-rebuild switch \ -Q \ --show-trace \ -I "$target_path" \ - "$@" \ 2>&1 | ${pkgs.whatsupnix}/bin/whatsupnix ''; - hook.get-version = pkgs.writeDash "hook.get-version" '' + shell.get-version = pkgs.writeDash "shell.get-version" '' set -efu version=git.$(${pkgs.git}/bin/git describe --always --dirty) case $version in (*-dirty) @@ -156,7 +151,7 @@ echo "$date.$version" ''; - hook.pkg = pkgs.runCommand "hook.pkg" {} /* sh */ '' + shell.cmdspkg = pkgs.runCommand "shell.cmdspkg" {} /* sh */ '' mkdir -p $out/bin ${lib.concatStrings (lib.mapAttrsToList (name: path: /* sh */ '' ln -s ${path} $out/bin/${name} @@ -168,7 +163,7 @@ in pkgs.stdenv.mkDerivation { shellHook = /* sh */ '' export NIX_PATH="stockholm=$PWD''${NIX_PATH+:$NIX_PATH}" export PATH=${lib.makeBinPath [ - hook.pkg + shell.cmdspkg ]} eval "$(declare -F | ${pkgs.gnused}/bin/sed s/declare/unset/)" @@ -187,7 +182,7 @@ in pkgs.stdenv.mkDerivation { } export HOSTNAME="$(${pkgs.nettools}/bin/hostname)" - export STOCKHOLM_VERSION="''${STOCKHOLM_VERSION-$(${hook.get-version})}" + export STOCKHOLM_VERSION="''${STOCKHOLM_VERSION-$(${shell.get-version})}" PS1='\[\e[38;5;162m\]\w\[\e[0m\] ' ''; -- cgit v1.2.3 From aa8fb19044cebff2d9687ab975340a7c0c96990d Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 30 Jun 2017 09:44:28 +0200 Subject: shell: use writeOut to create cmdspkg --- shell.nix | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/shell.nix b/shell.nix index 782b4fa3..dbc2b14f 100644 --- a/shell.nix +++ b/shell.nix @@ -151,12 +151,9 @@ echo "$date.$version" ''; - shell.cmdspkg = pkgs.runCommand "shell.cmdspkg" {} /* sh */ '' - mkdir -p $out/bin - ${lib.concatStrings (lib.mapAttrsToList (name: path: /* sh */ '' - ln -s ${path} $out/bin/${name} - '') cmds)} - ''; + shell.cmdspkg = pkgs.writeOut "shell.cmdspkg" (lib.mapAttrs' (name: link: + lib.nameValuePair "/bin/${name}" { inherit link; } + ) cmds); in pkgs.stdenv.mkDerivation { name = "stockholm"; -- cgit v1.2.3 From babbed38df4c0ff90eea9daa00cea3a105fb3ab2 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 30 Jun 2017 11:04:17 +0200 Subject: shell: use getopt --- shell.nix | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/shell.nix b/shell.nix index dbc2b14f..541a7d68 100644 --- a/shell.nix +++ b/shell.nix @@ -3,7 +3,7 @@ inherit (nixpkgs) lib pkgs; slib = import ./lib; - # usage: deploy system=SYSTEM [target=TARGET] + # usage: deploy --system=SYSTEM [--target=TARGET] cmds.deploy = pkgs.writeDash "cmds.deploy" '' set -efu @@ -15,7 +15,7 @@ exec ${utils.deploy} ''; - # usage: test system=SYSTEM target=TARGET + # usage: test --system=SYSTEM --target=TARGET cmds.test = pkgs.writeDash "cmds.test" /* sh */ '' set -efu @@ -28,18 +28,19 @@ ''; init.args = pkgs.writeText "init.args" /* sh */ '' - fail= - for arg; do - case $arg in - system=*) system=''${arg#*=};; - target=*) target=''${arg#*=};; - *) echo "$command: bad argument: $arg" >&2; fail=1 - esac - done - if \test -n "$fail"; then - exit 1 - fi - unset fail + args=$(${pkgs.utillinux}/bin/getopt -n "$command" -s sh \ + -o s:t: \ + -l system:,target: \ + -- "$@") + if \test $? != 0; then exit 1; fi + eval set -- "$args" + while :; do case $1 in + -s|--system) system=$2; shift 2;; + -t|--target) target=$2; shift 2;; + --) shift; break;; + esac; done + for arg; do echo "$command: bad argument: $arg" >&2; done + if \test $# != 0; then exit 2; fi ''; init.env = pkgs.writeText "init.env" /* sh */ '' -- cgit v1.2.3 From 9ee286644d050e68292776e02357549801fd20b6 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 30 Jun 2017 11:04:58 +0200 Subject: shell: use stockholm lib --- shell.nix | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/shell.nix b/shell.nix index 541a7d68..3e7ba81c 100644 --- a/shell.nix +++ b/shell.nix @@ -1,7 +1,6 @@ -{ nixpkgs ? import { overlays = [(import ./krebs/5pkgs)]; } }: let - - inherit (nixpkgs) lib pkgs; - slib = import ./lib; +let + lib = import ./lib; + pkgs = import { overlays = [(import ./krebs/5pkgs)]; }; # usage: deploy --system=SYSTEM [--target=TARGET] cmds.deploy = pkgs.writeDash "cmds.deploy" '' -- cgit v1.2.3 From 3be018f9f65e4d7ca2681c9fa20b9f7d2cd32287 Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 30 Jun 2017 13:11:17 +0200 Subject: l exim: add polo@lassul.us & shack@lassul.us --- lass/2configs/exim-smarthost.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lass/2configs/exim-smarthost.nix b/lass/2configs/exim-smarthost.nix index b8d00e7d..fd2f1f76 100644 --- a/lass/2configs/exim-smarthost.nix +++ b/lass/2configs/exim-smarthost.nix @@ -32,6 +32,8 @@ with import ; { from = "feed@lassul.us"; to = lass.mail; } { from = "art@lassul.us"; to = lass.mail; } { from = "irgendwas@lassul.us"; to = lass.mail; } + { from = "polo@lassul.us"; to = lass.mail; } + { from = "shack@lassul.us"; to = lass.mail; } ]; system-aliases = [ { from = "mailer-daemon"; to = "postmaster"; } -- cgit v1.2.3 From bc07a6043eecb26c5a995e2dab02e84ef52ebea0 Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 30 Jun 2017 13:14:57 +0200 Subject: l pkgs.init: use grub with EFI, remove /bku --- lass/5pkgs/init/default.nix | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/lass/5pkgs/init/default.nix b/lass/5pkgs/init/default.nix index b484d2c3..67918753 100644 --- a/lass/5pkgs/init/default.nix +++ b/lass/5pkgs/init/default.nix @@ -19,14 +19,15 @@ pkgs.writeText "init" '' disk=${disk} - luksdev=${disk}2 + luksdev=${disk}3 luksmap=/dev/mapper/${luksmap} vgname=${vgname} + bootdev=/dev/sda2 + rootdev=/dev/mapper/${vgname}-root homedev=/dev/mapper/${vgname}-home - bkudev=/dev/mapper/${vgname}-bku # #generate keyfile @@ -49,7 +50,8 @@ pkgs.writeText "init" '' mklabel gpt \ mkpart no-fs 0 1024KiB \ set 1 bios_grub on \ - mkpart primary 1025KiB 100% + mkpart ESP fat32 1025KiB 1024MiB set 2 boot on \ + mkpart primary 1025MiB 100% fi if ! test "$(blkid -o value -s PARTLABEL "$luksdev")" = primary; then @@ -78,9 +80,8 @@ pkgs.writeText "init" '' lvchange -a y /dev/mapper/"$vgname" - if ! test -e "$rootdev"; then lvcreate -L 100G -n root "$vgname"; fi - if ! test -e "$homedev"; then lvcreate -L 100G -n home "$vgname"; fi - if ! test -e "$bkudev"; then lvcreate -L 200G -n bku "$vgname"; fi + if ! test -e "$rootdev"; then lvcreate -L 7G -n root "$vgname"; fi + if ! test -e "$homedev"; then lvcreate -L 100M -n home "$vgname"; fi # lvchange -a n "$vgname" @@ -89,6 +90,10 @@ pkgs.writeText "init" '' # formatting # + if ! test "$(blkid -o value -s TYPE "$bootdev")" = vfat; then + mkfs.vfat "$bootdev" + fi + if ! test "$(blkid -o value -s TYPE "$rootdev")" = btrfs; then mkfs.btrfs "$rootdev" fi @@ -97,22 +102,18 @@ pkgs.writeText "init" '' mkfs.btrfs "$homedev" fi - if ! test "$(blkid -o value -s TYPE "$bkudev")" = btrfs; then - mkfs.btrfs "$bkudev" - fi - if ! test "$(lsblk -n -o MOUNTPOINT "$rootdev")" = /mnt; then mount "$rootdev" /mnt fi + if ! test "$(lsblk -n -o MOUNTPOINT "$bootdev")" = /mnt/boot; then + mkdir -m 0000 -p /mnt/boot + mount "$bootdev" /mnt/boot + fi if ! test "$(lsblk -n -o MOUNTPOINT "$homedev")" = /mnt/home; then mkdir -m 0000 -p /mnt/home mount "$homedev" /mnt/home fi - if ! test "$(lsblk -n -o MOUNTPOINT "$bkudev")" = /mnt/bku; then - mkdir -m 0000 -p /mnt/bku - mount "$bkudev" /mnt/bku - fi # umount -R /mnt @@ -122,6 +123,7 @@ pkgs.writeText "init" '' nix-env -iA nixos.git + # TODO: get sentinal file from target_path mkdir -p /mnt/var/src touch /mnt/var/src/.populate -- cgit v1.2.3 From ee95efd51080341f8be19a685152ecdb4a1f12f5 Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 30 Jun 2017 13:44:07 +0200 Subject: l icarus: use new fileSystem layout --- lass/1systems/icarus.nix | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lass/1systems/icarus.nix b/lass/1systems/icarus.nix index b869a67a..13c517e3 100644 --- a/lass/1systems/icarus.nix +++ b/lass/1systems/icarus.nix @@ -6,9 +6,9 @@ with import ; ../. ../2configs/retiolum.nix ../2configs/hw/tp-x220.nix - ../2configs/baseX.nix ../2configs/git.nix ../2configs/exim-retiolum.nix + ../2configs/baseX.nix ../2configs/browsers.nix ../2configs/programs.nix ../2configs/fetchWallpaper.nix @@ -22,9 +22,9 @@ with import ; loader.grub.enable = true; loader.grub.version = 2; loader.grub.device = "/dev/sda"; - loader.grub.enableCryptodisk = true; + loader.grub.efiSupport = true; - initrd.luks.devices = [ { name = "luksroot"; device = "/dev/sda2"; } ]; + initrd.luks.devices = [ { name = "luksroot"; device = "/dev/sda3"; } ]; initrd.luks.cryptoModules = [ "aes" "sha512" "sha1" "xts" ]; initrd.availableKernelModules = [ "xhci_hcd" "ehci_pci" "ahci" "usb_storage" ]; }; @@ -34,11 +34,14 @@ with import ; fsType = "btrfs"; options = ["defaults" "noatime" "ssd" "compress=lzo"]; }; - "/bku" = { - device = "/dev/mapper/pool-bku"; - fsType = "btrfs"; - options = ["defaults" "noatime" "ssd" "compress=lzo"]; + "/boot" = { + device = "/dev/sda2"; }; + #"/bku" = { + # device = "/dev/mapper/pool-bku"; + # fsType = "btrfs"; + # options = ["defaults" "noatime" "ssd" "compress=lzo"]; + #}; "/home" = { device = "/dev/mapper/pool-home"; fsType = "btrfs"; -- cgit v1.2.3 From e05591d73e4400a901525dc18a54981a5be6f82f Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 30 Jun 2017 13:44:29 +0200 Subject: l mors: use new fileSystem layout --- lass/1systems/mors.nix | 47 ++++++++++++++--------------------------------- 1 file changed, 14 insertions(+), 33 deletions(-) diff --git a/lass/1systems/mors.nix b/lass/1systems/mors.nix index b9ab5450..0bfd5451 100644 --- a/lass/1systems/mors.nix +++ b/lass/1systems/mors.nix @@ -96,49 +96,30 @@ with import ; loader.grub.enable = true; loader.grub.version = 2; loader.grub.device = "/dev/sda"; + loader.grub.efiSupport = true; - initrd.luks.devices = [ { name = "luksroot"; device = "/dev/sda2"; } ]; + initrd.luks.devices = [ { name = "luksroot"; device = "/dev/sda3"; } ]; initrd.luks.cryptoModules = [ "aes" "sha512" "sha1" "xts" ]; initrd.availableKernelModules = [ "xhci_hcd" "ehci_pci" "ahci" "usb_storage" ]; }; fileSystems = { "/" = { - device = "/dev/big/nix"; - fsType = "ext4"; + device = "/dev/mapper/pool-root"; + fsType = "btrfs"; + options = ["defaults" "noatime" "ssd" "compress=lzo"]; }; - "/boot" = { - device = "/dev/sda1"; - }; - - "/mnt/loot" = { - device = "/dev/big/loot"; - fsType = "ext4"; + device = "/dev/sda2"; }; - + #"/bku" = { + # device = "/dev/mapper/pool-bku"; + # fsType = "btrfs"; + # options = ["defaults" "noatime" "ssd" "compress=lzo"]; + #}; "/home" = { - device = "/dev/big/home"; - fsType = "ext4"; - }; - - "/home/lass" = { - device = "/dev/big/home-lass"; - fsType = "ext4"; - }; - - "/home/games/.local/share/Steam" = { - device = "/dev/big/steam"; - fsType = "ext4"; - }; - - "/home/virtual/virtual" = { - device = "/dev/big/virtual"; - fsType = "ext4"; - }; - - "/mnt/conf" = { - device = "/dev/big/conf"; - fsType = "ext4"; + device = "/dev/mapper/pool-home"; + fsType = "btrfs"; + options = ["defaults" "noatime" "ssd" "compress=lzo"]; }; "/tmp" = { device = "tmpfs"; -- cgit v1.2.3 From d5aca8696caeac6d88923e1f668af213abc987fa Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 30 Jun 2017 13:48:55 +0200 Subject: l buildbot: tests hosts in correct order --- lass/2configs/buildbot-standalone.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lass/2configs/buildbot-standalone.nix b/lass/2configs/buildbot-standalone.nix index e765ddbb..449feb38 100644 --- a/lass/2configs/buildbot-standalone.nix +++ b/lass/2configs/buildbot-standalone.nix @@ -120,9 +120,6 @@ in { system={}".format(host)] ) - for i in [ "alnus", "mu", "nomic", "wu", "xu", "zu" ]: - build_host(env_tv, i) - for i in [ "mors", "uriel", "shodan", "icarus", "cloudkrebs", "echelon", "dishfire", "prism" ]: build_host(env_lass, i) @@ -135,6 +132,9 @@ in { for i in [ "test-minimal-deploy", "test-all-krebs-modules", "wolf", "test-centos7" ]: build_host(env_shared, i) + for i in [ "alnus", "mu", "nomic", "wu", "xu", "zu" ]: + build_host(env_tv, i) + bu.append( util.BuilderConfig( name="build-hosts", -- cgit v1.2.3 From 4f1821f3971708a8f7d4db5f15b8c9651138518d Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 2 Jul 2017 00:09:16 +0200 Subject: tv: turn pkgs into an overlay --- tv/5pkgs/default.nix | 88 ++++++++++++++++++++++++++++++---------------------- tv/default.nix | 4 +-- 2 files changed, 53 insertions(+), 39 deletions(-) diff --git a/tv/5pkgs/default.nix b/tv/5pkgs/default.nix index ae47ab0f..284e42a7 100644 --- a/tv/5pkgs/default.nix +++ b/tv/5pkgs/default.nix @@ -1,40 +1,54 @@ -{ config, pkgs, ... }: with import ; -{ - nixpkgs.config.packageOverrides = super: let - - # This callPackage will try to detect obsolete overrides. - callPackage = path: args: let - override = super.callPackage path args; - upstream = optionalAttrs (override ? "name") - (super.${(parseDrvName override.name).name} or {}); - in if upstream ? "name" && - override ? "name" && - compareVersions upstream.name override.name != -1 - then trace "Upstream `${upstream.name}' gets overridden by `${override.name}'." override - else override; - - in {} - // mapAttrs (_: flip callPackage {}) - (filterAttrs (_: dir: pathExists (dir + "/default.nix")) - (subdirsOf ./.)) - // { - # TODO use XDG_RUNTIME_DIR? - cr = pkgs.writeDashBin "cr" '' - set -efu - export LC_TIME=de_DE.utf8 - exec ${pkgs.chromium}/bin/chromium \ - --ssl-version-min=tls1 \ - --disk-cache-dir=/tmp/chromium-disk-cache_"$LOGNAME" \ - --disk-cache-size=50000000 \ - "$@" - ''; - ejabberd = callPackage ./ejabberd { - erlang = pkgs.erlangR16; - }; - ff = pkgs.writeDashBin "ff" '' - exec ${pkgs.firefoxWrapper}/bin/firefox "$@" - ''; - gnupg = pkgs.gnupg21; +self: super: let + + # This callPackage will try to detect obsolete overrides. + callPackage = path: args: let + override = super.callPackage path args; + upstream = optionalAttrs (override ? "name") + (super.${(parseDrvName override.name).name} or {}); + in if upstream ? "name" && + override ? "name" && + compareVersions upstream.name override.name != -1 + then + trace + "Upstream `${upstream.name}' gets overridden by `${override.name}'." + override + else override; + +in { + + # TODO use XDG_RUNTIME_DIR? + cr = self.writeDashBin "cr" '' + set -efu + export LC_TIME=de_DE.utf8 + exec ${self.chromium}/bin/chromium \ + --ssl-version-min=tls1 \ + --disk-cache-dir=/tmp/chromium-disk-cache_"$LOGNAME" \ + --disk-cache-size=50000000 \ + "$@" + ''; + + ejabberd = callPackage ./ejabberd { + erlang = self.erlangR16; }; + + ff = self.writeDashBin "ff" '' + exec ${self.firefoxWrapper}/bin/firefox "$@" + ''; + + gnupg = self.gnupg21; + + # https://github.com/NixOS/nixpkgs/issues/16113 + wvdial = let + nixpkgs-1509 = import (self.fetchFromGitHub { + owner = "NixOS"; repo = "nixpkgs-channels"; + rev = "91371c2bb6e20fc0df7a812332d99c38b21a2bda"; + sha256 = "1as1i0j9d2n3iap9b471y4x01561r2s3vmjc5281qinirlr4al73"; + }) {}; + in nixpkgs-1509.wvdial; + } + +// mapAttrs (_: flip callPackage {}) + (filterAttrs (_: dir: pathExists (dir + "/default.nix")) + (subdirsOf ./.)) diff --git a/tv/default.nix b/tv/default.nix index b1c7c1be..d077cc09 100644 --- a/tv/default.nix +++ b/tv/default.nix @@ -1,9 +1,9 @@ -_: +{ pkgs, ... }: { imports = [ ../krebs ./2configs ./3modules - ./5pkgs ]; + nixpkgs.config.packageOverrides = import ./5pkgs pkgs; } -- cgit v1.2.3 From 70e5b248691010a81a121d206d039cce816a8a79 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 3 Jul 2017 00:07:38 +0200 Subject: l prism.r: fetch nixpkgs only once per day --- lass/1systems/prism.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lass/1systems/prism.nix b/lass/1systems/prism.nix index af847333..531dec9d 100644 --- a/lass/1systems/prism.nix +++ b/lass/1systems/prism.nix @@ -229,6 +229,10 @@ in { OnUnitInactiveSec = "2min"; RandomizedDelaySec = "2min"; }; + krebs.repo-sync.repos.nixpkgs.timerConfig = { + OnBootSec = "90min"; + OnUnitInactiveSec = "24h"; + }; } { lass.usershadow = { -- cgit v1.2.3