summaryrefslogtreecommitdiffstats
path: root/krebs/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'krebs/default.nix')
-rw-r--r--krebs/default.nix105
1 files changed, 6 insertions, 99 deletions
diff --git a/krebs/default.nix b/krebs/default.nix
index 15d0e8e2e..17c035896 100644
--- a/krebs/default.nix
+++ b/krebs/default.nix
@@ -1,5 +1,6 @@
-{ current-date
-, current-host-name
+assert false;
+
+{ current-host-name
, current-user-name
, lib
, stockholm
@@ -7,31 +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
- # ${current-date} ${current-user-name}@${current-host-name}
- # 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
@@ -39,7 +20,6 @@ let out = {
config = get-config system;
in ''
#! /bin/sh
- # ${current-date} ${current-user-name}@${current-host-name}
# krebs.infest
set -efu
@@ -48,9 +28,6 @@ let out = {
${builtins.readFile ./4lib/infest/install-nix.sh}
''}
- # Prepare target source via bind-mounting
-
-
(${nixos-install args})
${rootssh target ''
@@ -64,7 +41,6 @@ let out = {
config = get-config system;
in ''
#! /bin/sh
- # ${current-date} ${current-user-name}@${current-host-name}
# krebs.init
set -efu
@@ -100,7 +76,6 @@ let out = {
}@args: let
in ''
#! /bin/sh
- # ${current-date} ${current-user-name}@${current-host-name}
# krebs.nixos-install
(${populate (args // { root = "/mnt"; })})
@@ -171,9 +146,10 @@ 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 config;
nix-install =
{ system ? current-host-name
@@ -193,7 +169,6 @@ let out = {
nix-env \
--show-trace \
-f '<stockholm>' \
- --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} \
@@ -206,74 +181,6 @@ let out = {
])}
'';
- populate =
- { system ? current-host-name
- , target ? system
- , root ? ""
- }@args:
- let out = ''
- #! /bin/sh
- # ${current-date} ${current-user-name}@${current-host-name}
- 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 \
- -vrLptgoD \
- ${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}";