factor out withEnv (#572)

Reviewed-on: fediversity/fediversity#572
This commit is contained in:
Kiara Grouwstra 2025-11-06 15:42:37 +01:00
parent 95a8b41e02
commit 9e02939e5b
2 changed files with 17 additions and 12 deletions

View file

@ -15,7 +15,7 @@ let
str
submodule
;
inherit (pkgs.callPackage ../utils.nix { }) toBash withPackages tfApply;
inherit (pkgs.callPackage ../utils.nix { }) withPackages withEnv tfApply;
writeConfig =
{
system,
@ -244,9 +244,7 @@ in
pkgs.jq
])
''
env ${
toString (lib.mapAttrsToList (k: v: "${k}=\"${toBash v}\"") environment)
} bash ./deployment/run/ssh-single-host/run.sh
env ${withEnv environment} bash ./deployment/run/ssh-single-host/run.sh
'';
};
};

View file

@ -5,6 +5,15 @@
...
}:
rec {
mapKeys =
keyMapper:
lib.mapAttrs' (
k: value: {
name = keyMapper k;
inherit value;
}
);
evalModel =
module:
(lib.evalModules {
@ -51,6 +60,10 @@ rec {
];
};
filterNull = lib.filterAttrs (_: v: v != null);
withEnv = environment: toString (lib.mapAttrsToList (k: v: "${k}=\"${toBash v}\"") environment);
tfApply =
{
directory,
@ -62,14 +75,8 @@ rec {
}:
let
env-vars = ''
${
toString (
lib.mapAttrsToList (k: v: "TF_VAR_${k}=\"${toBash v}\"") (
lib.filterAttrs (_: v: v != null) environment
)
)
} \
${toString (lib.mapAttrsToList (k: v: "${k}=\"${toBash v}\"") httpBackend.value)} \
${withEnv (mapKeys (k: "TF_VAR_${k}") (filterNull environment))} \
${withEnv (filterNull httpBackend.value)} \
'';
tfPackage = pkgs.callPackage ./run/${directory}/tf.nix { };
tf-env = pkgs.callPackage ./run/tf-env.nix {