mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-11-25 09:36:14 +01:00
10da34a3ca
Signed-off-by: magic_rb <magic_rb@redalder.org>
57 lines
1.1 KiB
Nix
57 lines
1.1 KiB
Nix
{
|
|
uterranix-lib,
|
|
pkgs,
|
|
}: {
|
|
name,
|
|
image,
|
|
flake ? "$FLAKE_ROOT",
|
|
hosts ? [],
|
|
}: {
|
|
lib,
|
|
config,
|
|
...
|
|
}: let
|
|
inherit
|
|
(uterranix-lib)
|
|
tf
|
|
;
|
|
inherit
|
|
(lib)
|
|
singleton
|
|
concatMapStringsSep
|
|
;
|
|
in {
|
|
data."external"."nixng-image-${name}" = {
|
|
program = singleton (pkgs.writeShellScript "build_nixng_image_${name}.sh" ''
|
|
set -euo pipefail
|
|
|
|
echo '{"out":"${image}"}'
|
|
'');
|
|
};
|
|
|
|
resource."terraform_data"."nixng-image-${name}-copy" = {
|
|
triggers_replace = [
|
|
(tf "data.external.nixng-image-${name}.result.out")
|
|
];
|
|
provisioner."local-exec" = {
|
|
interpreter = [
|
|
(pkgs.writeShellScript "copy_nixng_image_${name}.sh" ''
|
|
set -euo pipefail
|
|
|
|
_system_path="/$(cut -f '2-' -d '/' <<<"$1")"
|
|
|
|
cd $FLAKE_ROOT
|
|
mkdir -p /tmp/terranix
|
|
${concatMapStringsSep "\n" (host: ''
|
|
flock -x /tmp/terranix/${host} nix copy "$_system_path" --to ssh-ng://${host} -s --no-check-sigs
|
|
'')
|
|
hosts}
|
|
|
|
'')
|
|
(tf "data.external.nixng-image-${name}.result.out")
|
|
];
|
|
command = "ignoreme";
|
|
};
|
|
};
|
|
}
|