Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use same option names as agenix #18

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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