1
0
mirror of https://cgit.krebsco.de/krops synced 2024-06-02 06:13:30 +02:00
krops/pkgs/krops/default.nix

51 lines
1.3 KiB
Nix
Raw Normal View History

let
2018-07-12 14:14:27 +02:00
lib = import ../../lib;
in
2018-07-10 10:15:39 +02:00
{ 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
target' = lib.mkTarget target;
in
writeDash name ''
set -efu
2018-07-10 10:15:39 +02:00
${populate' name { inherit source; target = target'; }}
${openssh}/bin/ssh \
${target'.user}@${target'.host} -p ${target'.port} \
nixos-rebuild switch -I ${target'.path}
'';
2018-07-10 10:15:39 +02:00
writePopulate = name: { source, target }:
populate' name {
inherit source;
target = lib.mkTarget target;
};
writeTest = name: { source, target }: let
target' = lib.mkTarget target;
in
assert lib.isLocalTarget target';
writeDash name ''
set -efu
2018-07-10 10:15:39 +02:00
${populate' name { inherit source; target = target'; }}
${nix}/bin/nix-build \
-A config.system.build.toplevel \
-I ${target'.path} \
--arg modules '[<nixos-config>]' \
--no-out-link \
--show-trace \
'<nixpkgs/nixos/lib/eval-config.nix>'
'';
}