diff options
author | lassulus <lass@aidsballs.de> | 2016-02-06 18:45:38 +0100 |
---|---|---|
committer | lassulus <lass@aidsballs.de> | 2016-02-06 18:45:38 +0100 |
commit | fe586d704eed42421ad3fe0d140c0caa64764a68 (patch) | |
tree | a07d0c4d09ef780f703ae03435d51ac60019c956 /krebs/default.nix | |
parent | 138bdc6bf6a18a59cf47d2d2db7c4e7640f50641 (diff) | |
parent | c784d271c5dc8783e5e6308baf4f6dd26430bfca (diff) |
Merge remote-tracking branch 'cd/master'
Diffstat (limited to 'krebs/default.nix')
-rw-r--r-- | krebs/default.nix | 104 |
1 files changed, 4 insertions, 100 deletions
diff --git a/krebs/default.nix b/krebs/default.nix index df2d95483..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"; })}) @@ -174,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 @@ -196,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} \ @@ -209,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 \ - -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}"; |