From c3c4aac670cf0ac26340061cef1527b3d7f64386 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 1 Feb 2016 03:00:48 +0100 Subject: make deploy2: deploy using nixos-rebuild switch --- krebs/default.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'krebs/default.nix') diff --git a/krebs/default.nix b/krebs/default.nix index 15d0e8e2e..2cdecaccb 100644 --- a/krebs/default.nix +++ b/krebs/default.nix @@ -171,9 +171,12 @@ let out = { ${b} ''; - get-config = system: - stockholm.users.${current-user-name}.${system}.config + get-config = system: let + config = stockholm.users.${current-user-name}.${system}.config or (abort "unknown system: ${system}, user: ${current-user-name}"); + in + assert config.krebs.build.source-version == 1; + config; nix-install = { system ? current-host-name -- cgit v1.2.3 From 8aec9eb987ab89dec9326709c3a72a287d9aa1d0 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 1 Feb 2016 03:14:59 +0100 Subject: krebs.populate: disable copy-links, owner, and group --- krebs/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'krebs/default.nix') diff --git a/krebs/default.nix b/krebs/default.nix index 2cdecaccb..df2d95483 100644 --- a/krebs/default.nix +++ b/krebs/default.nix @@ -243,7 +243,7 @@ let out = { --exclude tmp \ --rsync-path='mkdir -p ${target-path} && rsync' \ --delete-excluded \ - -vrLptgoD \ + -vrlptD \ ${config.path}/ \ root@${target}:${target-path} ''; -- cgit v1.2.3 From 65977c6108d9517d58a6bd6ce8676c6a7b97615e Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 4 Feb 2016 04:44:26 +0100 Subject: RIP current-date --- krebs/default.nix | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'krebs/default.nix') diff --git a/krebs/default.nix b/krebs/default.nix index df2d95483..e9ee71b34 100644 --- a/krebs/default.nix +++ b/krebs/default.nix @@ -1,5 +1,4 @@ -{ current-date -, current-host-name +{ current-host-name , current-user-name , lib , stockholm @@ -21,7 +20,6 @@ let out = { config = get-config system; in '' #! /bin/sh - # ${current-date} ${current-user-name}@${current-host-name} # krebs.deploy set -efu (${populate args}) @@ -39,7 +37,6 @@ let out = { config = get-config system; in '' #! /bin/sh - # ${current-date} ${current-user-name}@${current-host-name} # krebs.infest set -efu @@ -64,7 +61,6 @@ let out = { config = get-config system; in '' #! /bin/sh - # ${current-date} ${current-user-name}@${current-host-name} # krebs.init set -efu @@ -100,7 +96,6 @@ let out = { }@args: let in '' #! /bin/sh - # ${current-date} ${current-user-name}@${current-host-name} # krebs.nixos-install (${populate (args // { root = "/mnt"; })}) @@ -196,7 +191,6 @@ let out = { nix-env \ --show-trace \ -f '' \ - --argstr current-date ${lib.shell.escape current-date} \ --argstr current-host-name ${lib.shell.escape current-host-name} \ --argstr current-user-name ${lib.shell.escape current-user-name} \ --profile ${lib.shell.escape config.krebs.build.profile} \ @@ -216,7 +210,6 @@ let out = { }@args: let out = '' #! /bin/sh - # ${current-date} ${current-user-name}@${current-host-name} set -efu ${lib.concatStringsSep "\n" (lib.concatMap -- cgit v1.2.3 From b857a48632128be0324c68be95bee16fb0f1b15f Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 4 Feb 2016 05:40:26 +0100 Subject: krebs.build.populate: init and drop support for v1 --- krebs/default.nix | 95 ++----------------------------------------------------- 1 file changed, 3 insertions(+), 92 deletions(-) (limited to 'krebs/default.nix') diff --git a/krebs/default.nix b/krebs/default.nix index e9ee71b34..17c035896 100644 --- a/krebs/default.nix +++ b/krebs/default.nix @@ -1,3 +1,5 @@ +assert false; + { current-host-name , current-user-name , lib @@ -6,30 +8,11 @@ }: let out = { - inherit deploy; inherit infest; inherit init; inherit nixos-install; - inherit populate; }; - deploy = - { system ? current-host-name - , target ? system - }@args: let - config = get-config system; - in '' - #! /bin/sh - # krebs.deploy - set -efu - (${populate args}) - ${rootssh target '' - ${nix-install args} - ${config.krebs.build.profile}/bin/switch-to-configuration switch - ''} - echo OK - ''; - infest = { system ? current-host-name , target ? system @@ -45,9 +28,6 @@ let out = { ${builtins.readFile ./4lib/infest/install-nix.sh} ''} - # Prepare target source via bind-mounting - - (${nixos-install args}) ${rootssh target '' @@ -169,9 +149,7 @@ let out = { get-config = system: let config = stockholm.users.${current-user-name}.${system}.config or (abort "unknown system: ${system}, user: ${current-user-name}"); - in - assert config.krebs.build.source-version == 1; - config; + in config; nix-install = { system ? current-host-name @@ -203,73 +181,6 @@ let out = { ])} ''; - populate = - { system ? current-host-name - , target ? system - , root ? "" - }@args: - let out = '' - #! /bin/sh - set -efu - ${lib.concatStringsSep "\n" - (lib.concatMap - (type: lib.mapAttrsToList (_: methods.${type}) - config.krebs.build.source.${type}) - ["dir" "git"])} - ''; - - - config = get-config system; - - current-host = config.krebs.hosts.${current-host-name}; - current-user = config.krebs.users.${current-user-name}; - - methods.dir = config: - let - can-push = config.host.name == current-host.name; - target-path = root + config.target-path; - push-method = '' - rsync \ - --exclude .git \ - --exclude .graveyard \ - --exclude old \ - --exclude tmp \ - --rsync-path='mkdir -p ${target-path} && rsync' \ - --delete-excluded \ - -vrlptD \ - ${config.path}/ \ - root@${target}:${target-path} - ''; - in - if can-push then push-method else - let dir = "file://${config.host.name}${config.path}"; in - # /!\ revise this message when using more than just push-method - throw "No way to push ${dir} from ${current-host.name} to ${target}"; - - methods.git = config: - let target-path = root + config.target-path; - in rootssh target '' - mkdir -p ${target-path} - cd ${target-path} - if ! test -e .git; then - git init - fi - if ! cur_url=$(git config remote.origin.url 2>/dev/null); then - git remote add origin ${config.url} - elif test "$cur_url" != ${config.url}; then - git remote set-url origin ${config.url} - fi - if test "$(git rev-parse --verify HEAD 2>/dev/null)" != ${config.rev}; then - git fetch origin - git checkout ${config.rev} -- . - git checkout -q ${config.rev} - git submodule init - git submodule update - fi - git clean -dxf - ''; - in out; - rootssh = target: script: let flags = "-o StrictHostKeyChecking=${StrictHostKeyChecking}"; -- cgit v1.2.3