From 7aa35d3576736eef4ccdb55fb2b84169b2a71159 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 25 Jun 2017 16:15:18 +0200 Subject: tv: properly use symlinkJoin paths Because earlier entries override later ones. --- tv/2configs/htop.nix | 2 +- tv/2configs/vim.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tv/2configs/htop.nix b/tv/2configs/htop.nix index 5d7e027..d7d2d7b 100644 --- a/tv/2configs/htop.nix +++ b/tv/2configs/htop.nix @@ -7,7 +7,6 @@ with import ; htop = pkgs.symlinkJoin { name = "htop"; paths = [ - super.htop (pkgs.writeDashBin "htop" '' export HTOPRC=${pkgs.writeText "htoprc" '' fields=0 48 17 18 38 39 40 2 46 47 49 1 @@ -37,6 +36,7 @@ with import ; ''} exec ${super.htop}/bin/htop "$@" '') + super.htop ]; }; }; diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix index 93ed46d..a3af937 100644 --- a/tv/2configs/vim.nix +++ b/tv/2configs/vim.nix @@ -300,7 +300,6 @@ let { vim-wrapper = pkgs.symlinkJoin { name = "vim"; paths = [ - pkgs.vim_configurable (pkgs.writeDashBin "vim" '' set -efu (umask 0077; exec ${pkgs.coreutils}/bin/mkdir -p ${toString mkdirs}) @@ -310,6 +309,7 @@ let { # vim-orgmode needs Python, thus vim_configurable instead of just vim exec ${pkgs.vim_configurable}/bin/vim "$@" '') + pkgs.vim_configurable ]; }; -- cgit v1.2.3 From e066b757054bc2f237a798e99934b133d89e8e7b Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 27 Jun 2017 10:01:16 +0200 Subject: tv: add htop to default systemPackages --- tv/1systems/cd.nix | 1 - tv/1systems/wu.nix | 1 - tv/1systems/xu.nix | 1 - tv/1systems/zu.nix | 1 - tv/2configs/default.nix | 3 ++- 5 files changed, 2 insertions(+), 5 deletions(-) diff --git a/tv/1systems/cd.nix b/tv/1systems/cd.nix index 108006f..9f2cec5 100644 --- a/tv/1systems/cd.nix +++ b/tv/1systems/cd.nix @@ -25,7 +25,6 @@ with import ; }; environment.systemPackages = with pkgs; [ - htop iftop iotop iptables diff --git a/tv/1systems/wu.nix b/tv/1systems/wu.nix index 60f9fa1..4b3bf85 100644 --- a/tv/1systems/wu.nix +++ b/tv/1systems/wu.nix @@ -31,7 +31,6 @@ with import ; get gnupg1compat haskellPackages.hledger - htop jq mkpasswd netcat diff --git a/tv/1systems/xu.nix b/tv/1systems/xu.nix index 3add017..d82f45a 100644 --- a/tv/1systems/xu.nix +++ b/tv/1systems/xu.nix @@ -34,7 +34,6 @@ with import ; file gnupg1compat haskellPackages.hledger - htop jq krebszones mkpasswd diff --git a/tv/1systems/zu.nix b/tv/1systems/zu.nix index 5552ef0..4fae3ca 100644 --- a/tv/1systems/zu.nix +++ b/tv/1systems/zu.nix @@ -36,7 +36,6 @@ with import ; file gnupg1compat haskellPackages.hledger - htop jq mkpasswd netcat diff --git a/tv/2configs/default.nix b/tv/2configs/default.nix index 4a1247e..d248bf5 100644 --- a/tv/2configs/default.nix +++ b/tv/2configs/default.nix @@ -158,9 +158,10 @@ with import ; { environment.systemPackages = [ pkgs.get + pkgs.htop pkgs.krebspaste - pkgs.ovh-zone pkgs.nix-prefetch-scripts + pkgs.ovh-zone pkgs.push ]; } -- cgit v1.2.3 From 2cee1cee722be0ff4a4b090beffd1f801c3059aa Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 27 Jun 2017 19:55:49 +0200 Subject: tv alnus nixpkgs: e924319 -> 9b948ea --- tv/1systems/alnus.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tv/1systems/alnus.nix b/tv/1systems/alnus.nix index 4bc0318..ef2a050 100644 --- a/tv/1systems/alnus.nix +++ b/tv/1systems/alnus.nix @@ -58,7 +58,7 @@ with import ; krebs.build = { host = config.krebs.hosts.alnus; user = mkForce config.krebs.users.dv; - source.nixpkgs.git.ref = mkForce "e924319cb6c74aa2a9c943eddeb0caef79db01bc"; + source.nixpkgs.git.ref = mkForce "9b948ea439ddbaa26740ce35543e7e35d2aa6d18"; }; networking.networkmanager.enable = true; -- cgit v1.2.3 From 28c6c59f6af9a0f8911a70b7b59cf630ca2161f0 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 27 Jun 2017 21:30:05 +0200 Subject: tv mu: security.wrappers.slock.{slock => source} --- tv/1systems/mu.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tv/1systems/mu.nix b/tv/1systems/mu.nix index fcd0a21..cb8e7d9 100644 --- a/tv/1systems/mu.nix +++ b/tv/1systems/mu.nix @@ -101,7 +101,7 @@ with import ; security.wrappers = { sendmail.source = "${pkgs.exim}/bin/sendmail"; # for cron - slock.slock = "${pkgs.slock}/bin/slock"; + slock.source = "${pkgs.slock}/bin/slock"; }; security.pam.loginLimits = [ -- cgit v1.2.3 From eff4110f40fb8172f44885fbb0f1e5defa69d5d1 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 27 Jun 2017 21:30:22 +0200 Subject: tv mu: kde4 -> plasma5, maybe --- tv/1systems/mu.nix | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tv/1systems/mu.nix b/tv/1systems/mu.nix index cb8e7d9..8e527b0 100644 --- a/tv/1systems/mu.nix +++ b/tv/1systems/mu.nix @@ -82,12 +82,9 @@ with import ; chromiumDev skype libreoffice - kde4.l10n.de - kde4.plasma-nm pidgin-with-plugins pidginotr - kde4.print_manager #foomatic_filters #gutenprint #cups_pdf_filter @@ -138,7 +135,9 @@ with import ; twoFingerScroll = true; }; - services.xserver.desktopManager.kde4.enable = true; + services.xserver.desktopManager.plasma5 = { + enable = true; + }; services.xserver.displayManager.auto = { enable = true; user = "vv"; -- cgit v1.2.3 From 673645605b586f8b0d9f640c96b698b1dc7c3fa7 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 27 Jun 2017 22:29:46 +0200 Subject: tv mu: chromiumDev -> chromium --- tv/1systems/mu.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tv/1systems/mu.nix b/tv/1systems/mu.nix index 8e527b0..3f3b2c2 100644 --- a/tv/1systems/mu.nix +++ b/tv/1systems/mu.nix @@ -79,7 +79,7 @@ with import ; gimp xsane firefoxWrapper - chromiumDev + chromium skype libreoffice pidgin-with-plugins -- cgit v1.2.3 From 84efa820b5dcaf1f05df120a5ed84544c968265e Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 27 Jun 2017 22:57:34 +0200 Subject: tv: configure stockholm for buildbot --- tv/2configs/default.nix | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tv/2configs/default.nix b/tv/2configs/default.nix index d248bf5..5d61cb9 100644 --- a/tv/2configs/default.nix +++ b/tv/2configs/default.nix @@ -1,20 +1,24 @@ -{ config, lib, pkgs, ... }: - with import ; - -{ +{ config, lib, pkgs, ... }: let + builder = if getEnv "dummy_secrets" == "true" + then "buildbot" + else "tv"; +in { krebs.enable = true; krebs.build = { user = config.krebs.users.tv; source = let inherit (config.krebs.build) host; in { nixos-config.symlink = "stockholm/tv/1systems/${host.name}.nix"; - secrets.file = - if getEnv "dummy_secrets" == "true" - then toString - else "/home/tv/secrets/${host.name}"; + secrets.file = getAttr builder { + buildbot = toString ; + tv = "/home/tv/secrets/${host.name}"; + }; secrets-common.file = "/home/tv/secrets/common"; - stockholm.file = "/home/tv/stockholm"; + stockholm.file = getAttr builder { + buildbot = getEnv "PWD"; + tv = "/home/tv/stockholm"; + }; nixpkgs.git = { url = https://github.com/NixOS/nixpkgs; ref = "412b0a17aa2975e092c7ab95a38561c5f82908d4"; # nixos-17.03 -- cgit v1.2.3 From 67b9c8edfd3e7921029342a095ccfaac79674323 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 27 Jun 2017 23:28:41 +0200 Subject: Makefile: call build with whatsupnix --- Makefile | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index ce6205c..ecc2f49 100644 --- a/Makefile +++ b/Makefile @@ -51,13 +51,23 @@ $(if $(target_user),,$(error unbound variable: target_user)) $(if $(target_port),,$(error unbound variable: target_port)) $(if $(target_path),,$(error unbound variable: target_path)) +whatsupnix = \ + if type whatsupnix >/dev/null 2>&1; then \ + whatsupnix $(1); \ + else \ + cat; \ + fi + build = \ nix-build \ + -Q \ --no-out-link \ --show-trace \ -I nixos-config=$(nixos-config) \ -I stockholm=$(stockholm) \ - -E "with import ; $(1)" + -E "with import ; $(1)" \ + $(2) \ + |& $(call whatsupnix) evaluate = \ nix-instantiate \ @@ -84,11 +94,7 @@ deploy: $(ssh) $(target_user)@$(target_host) -p $(target_port) \ env STOCKHOLM_VERSION="$$STOCKHOLM_VERSION" \ nixos-rebuild -Q $(rebuild-command) --show-trace -I $(target_path) \ - |& if type whatsupnix 2>/dev/null; then \ - whatsupnix $(target_user)@$(target_host):$(target_port); \ - else \ - cat; \ - fi + |& $(call whatsupnix,$(target_user)@$(target_host):$(target_port)) # usage: make populate system=foo populate: populate-target = \ -- cgit v1.2.3 From 92895c16cfe2847a66b214461e0b5aab887b0bc0 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 27 Jun 2017 23:29:43 +0200 Subject: make test: use build and evaluate --- Makefile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index ecc2f49..cab53d5 100644 --- a/Makefile +++ b/Makefile @@ -76,7 +76,8 @@ evaluate = \ --show-trace \ -I nixos-config=$(nixos-config) \ -I stockholm=$(stockholm) \ - -E "let eval = import ; in with eval; $(1)" + -E "let eval = import ; in with eval; $(1)" \ + $(2) ifeq ($(MAKECMDGOALS),) $(error No goals specified) @@ -132,10 +133,10 @@ install: # usage: make test system=foo [target=bar] [method={eval,build}] method ?= eval ifeq ($(method),build) -test: command = nix-build --no-out-link +test: test = $(call build,$(1),$(2)) else ifeq ($(method),eval) -test: command ?= nix-instantiate --eval --json --readonly-mode --strict +test: test ?= $(call evaluate,$(1),$(2)) --json --strict | jq -r . else $(error bad method: $(method)) endif @@ -147,6 +148,4 @@ else test: wrapper = $(ssh) $(target_user)@$(target_host) -p $(target_port) endif test: populate - $(wrapper) \ - $(command) --show-trace -I $(target_path) \ - -A config.system.build.toplevel $(target_path)/stockholm + $(wrapper) $(call test,config.system.build.toplevel,-I $(target_path)) -- cgit v1.2.3 From 55cebf457e32ef07d5c98c477ea9fc1379f9d783 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 27 Jun 2017 23:40:38 +0200 Subject: tv: stockholm is really just --- tv/2configs/default.nix | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tv/2configs/default.nix b/tv/2configs/default.nix index 5d61cb9..aae7c5a 100644 --- a/tv/2configs/default.nix +++ b/tv/2configs/default.nix @@ -15,10 +15,7 @@ in { tv = "/home/tv/secrets/${host.name}"; }; secrets-common.file = "/home/tv/secrets/common"; - stockholm.file = getAttr builder { - buildbot = getEnv "PWD"; - tv = "/home/tv/stockholm"; - }; + stockholm.file = toString ; nixpkgs.git = { url = https://github.com/NixOS/nixpkgs; ref = "412b0a17aa2975e092c7ab95a38561c5f82908d4"; # nixos-17.03 -- cgit v1.2.3 From 7efc890066caaa0adf4dcafac92d2f45d6c2ae23 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 27 Jun 2017 23:48:05 +0200 Subject: krebs.build.source: stockholm default is --- tv/2configs/default.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/tv/2configs/default.nix b/tv/2configs/default.nix index aae7c5a..bab1c72 100644 --- a/tv/2configs/default.nix +++ b/tv/2configs/default.nix @@ -15,7 +15,6 @@ in { tv = "/home/tv/secrets/${host.name}"; }; secrets-common.file = "/home/tv/secrets/common"; - stockholm.file = toString ; nixpkgs.git = { url = https://github.com/NixOS/nixpkgs; ref = "412b0a17aa2975e092c7ab95a38561c5f82908d4"; # nixos-17.03 -- cgit v1.2.3 From a65494301f24bd65cecf23777203386a9d1ab15f 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 0000000..d6e09e1 --- /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 eabfaedf0842a72eb097d6fc5469832c0ec057a4 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 d6e09e1..26db52c 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 b21d3900221a573e9998a3c4f059cf6f3f11eb79 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 26db52c..9cc7406 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 73d504d5f7fe219342525b54acda2f6a31ada695 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 9cc7406..e16f172 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 cd7b13f1ceecf8da24c7bd4872a3a53576264feb 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 e16f172..d8f3184 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 1d6009f5127e4aa8ada3a4dd38093425d098dab3 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 --- shell.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell.nix b/shell.nix index d8f3184..302429a 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 2a6bfba2185980d154f9a67a609cf7b417c32770 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 302429a..d6d2158 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 e9cc4f49e161e72c18c6e4da45b2bb95a5a2a010 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 d6d2158..782b4fa 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 d0e8ea1a9e7f68e1a82e3ce9fb4577b7fb62f0bf 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 782b4fa..dbc2b14 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 805dd42490334acdefde06c47c96cd4082be36e0 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 dbc2b14..541a7d6 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 5d06c6f3f0e1122fca5d680022ea5cba15003a45 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 541a7d6..3e7ba81 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 6b4c2a2c261a963b38e1f5951c5c25c8fa6ae102 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 ae47ab0..284e42a 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 b1c7c1b..d077cc0 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 1531509e5d967d226ea4c28051ebbf245a72f361 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 4 Jul 2017 18:08:32 +0200 Subject: shared nixpkgs: 58e2270 -> 72c9ed7 --- shared/2configs/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/2configs/default.nix b/shared/2configs/default.nix index 894f8a9..398f125 100644 --- a/shared/2configs/default.nix +++ b/shared/2configs/default.nix @@ -11,7 +11,7 @@ with import ; nixos-config.symlink = "stockholm/${user.name}/1systems/${host.name}.nix"; nixpkgs.git = { url = https://github.com/NixOS/nixpkgs; - ref = "58e227052d40021d82d015f3f8da011ae54ea430"; # nixos-17.03 @ 2017-05-24 + ref = "72c9ed78d0b1d9d5f531805ddf5bf06bfd447614"; # nixos-17.03 @ 2017-06-17 }; secrets.file = if getEnv "dummy_secrets" == "true" -- cgit v1.2.3