1
0
Fork 0
mirror of https://cgit.krebsco.de/krops synced 2024-11-23 03:29:48 +01:00

krops: add writePopulate

This commit is contained in:
tv 2018-07-10 10:15:39 +02:00
parent 4e466eaf05
commit 9677846bf5

View file

@ -8,34 +8,42 @@ let
}; };
in in
{ nix, openssh, populate, writeDash, writeJSON }: { { nix, openssh, populate, writeDash, writeJSON }: let
populate' = name: { source, target }:
writeDash "${name}-populate" ''
set -efu
source=${writeJSON "${name}-source.json" source}
target=${target.user}@${target.host}:${target.port}${target.path}
exec ${populate}/bin/populate "$target" < "$source"
'';
in {
writeDeploy = name: { source, target }: let writeDeploy = name: { source, target }: let
target' = lib.mkTarget target; target' = lib.mkTarget target;
in in
writeDash name '' writeDash name ''
set -efu set -efu
${populate' name { inherit source; target = target'; }}
${populate}/bin/populate \
${target'.user}@${target'.host}:${target'.port}${target'.path} \
< ${writeJSON "${name}-source.json" source}
${openssh}/bin/ssh \ ${openssh}/bin/ssh \
${target'.user}@${target'.host} -p ${target'.port} \ ${target'.user}@${target'.host} -p ${target'.port} \
nixos-rebuild switch -I ${target'.path} nixos-rebuild switch -I ${target'.path}
''; '';
writePopulate = name: { source, target }:
populate' name {
inherit source;
target = lib.mkTarget target;
};
writeTest = name: { source, target }: let writeTest = name: { source, target }: let
target' = lib.mkTarget target; target' = lib.mkTarget target;
in in
assert lib.isLocalTarget target'; assert lib.isLocalTarget target';
writeDash name '' writeDash name ''
set -efu set -efu
${populate' name { inherit source; target = target'; }}
${populate}/bin/populate --force \
${target'.path} \
< ${writeJSON "${name}-source.json" source}
${nix}/bin/nix-build \ ${nix}/bin/nix-build \
-A config.system.build.toplevel \ -A config.system.build.toplevel \
-I ${target'.path} \ -I ${target'.path} \