Skip to content

Commit

Permalink
Use same option names as agenix
Browse files Browse the repository at this point in the history
  • Loading branch information
Sohalt committed Jan 26, 2023
1 parent 02bfe4c commit 61665ae
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions module/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ with lib; let

# Options for a secret file
# Based on https://github.com/ryantm/agenix/pull/58
secretFile = types.submodule ({name, ...}: {
secretType = types.submodule ({ name, ... }: {
options = {
path = mkOption {
description = "Absolute path of where the file will be saved. Defaults to mount/name";
Expand Down Expand Up @@ -200,10 +200,10 @@ with lib; let
});
in {
options.homeage = {
file = mkOption {
description = "Attrset of secret files";
default = {};
type = types.attrsOf secretFile;
secrets = mkOption {
description = "Attrset of secrets";
default = { };
type = types.attrsOf secretType;
};

pkg = mkOption {
Expand Down Expand Up @@ -249,7 +249,7 @@ in {
};
};

config = mkIf (cfg.file != {}) (mkMerge [
config = mkIf (cfg.secrets != {}) (mkMerge [
{
assertions = [
{
Expand All @@ -258,7 +258,7 @@ in {
}
{
assertion = let
paths = mapAttrsToList (_: value: value.path) cfg.file;
paths = mapAttrsToList (_: value: value.path) cfg.secrets;
in
(unique paths) == paths;
message = "overlapping secret file paths.";
Expand All @@ -277,7 +277,7 @@ in {
DECRYPTION=
${
builtins.concatStringsSep "\n"
(lib.mapAttrsToList (n: v: decryptCheckScript n v.source) cfg.file)
(lib.mapAttrsToList (n: v: decryptCheckScript n v.source) cfg.secrets)
}
if [ ! -x $DECRYPTION ]; then
printf "''${errorColor}''${DECRYPTION}[homeage] Check homage.identityPaths to either add an identity or remove a broken one\n''${normalColor}" 1>&2
Expand All @@ -299,7 +299,7 @@ in {
(builtins.toJSON
(map
(secret: secret)
(builtins.attrValues cfg.file)));
(builtins.attrValues cfg.secrets)));
in ''
mkdir -p $(dirname $out/${statePath})
ln -s ${stateFile} $out/${statePath}
Expand All @@ -312,7 +312,7 @@ in {
hm.dag.entryBetween ["homeageDecrypt"] ["writeBoundary"] fileCleanup;

homeageDecrypt = let
activationScript = builtins.concatStringsSep "\n" (lib.attrsets.mapAttrsToList decryptSecret cfg.file);
activationScript = builtins.concatStringsSep "\n" (lib.attrsets.mapAttrsToList decryptSecret cfg.secrets);
in
hm.dag.entryBetween ["reloadSystemd"] ["writeBoundary"] activationScript;
};
Expand Down Expand Up @@ -364,7 +364,7 @@ in {
};
}
)
cfg.file;
cfg.secrets;
in
mkServices;
})
Expand Down

0 comments on commit 61665ae

Please sign in to comment.