1
0
Fork 0
mirror of https://github.com/Mic92/sops-nix.git synced 2024-12-14 11:57:52 +00:00

try fixing templates on home-manager

Update pkgs/sops-install-secrets/main.go
This commit is contained in:
jobs62 2024-11-28 16:38:51 +01:00 committed by Jörg Thalheim
parent 3433ea14fb
commit 8d13626351
3 changed files with 11 additions and 4 deletions

View file

@ -99,6 +99,7 @@ let
sshKeyPaths = cfg.gnupg.sshKeyPaths;
ageKeyFile = cfg.age.keyFile;
ageSshKeyPaths = cfg.age.sshKeyPaths;
placeholderBySecretName = cfg.placeholder;
userMode = true;
logging = {
keyImport = builtins.elem "keyImport" cfg.log;

View file

@ -12,6 +12,8 @@ let
mapAttrs
types
;
hmConfig = config;
in
{
options.sops = {
@ -33,7 +35,7 @@ in
description = "Path where the rendered file will be placed";
type = types.singleLineStr;
# Keep this in sync with `RenderedSubdir` in `pkgs/sops-install-secrets/main.go`
default = "${config.xdg.configHome}/sops-nix/secrets/rendered/${config.name}";
default = "${hmConfig.xdg.configHome}/sops-nix/secrets/rendered/${config.name}";
};
content = mkOption {
type = types.lines;
@ -97,10 +99,10 @@ in
};
config = lib.optionalAttrs (options ? sops.secrets) (
lib.mkIf (config.sops.templates != { }) {
lib.mkIf (hmConfig.sops.templates != { }) {
sops.placeholder = mapAttrs (
name: _: mkDefault "<SOPS:${builtins.hashString "sha256" name}:PLACEHOLDER>"
) config.sops.secrets;
) hmConfig.sops.secrets;
}
);
}

View file

@ -698,7 +698,11 @@ func (app *appContext) validateManifest() error {
// The Nix module only defines placeholders for secrets if there are
// templates.
if len(m.Templates) > 0 {
placeholder := m.PlaceholderBySecretName[secret.Name]
placeholder, present := m.PlaceholderBySecretName[secret.Name]
if !present {
return fmt.Errorf("placeholder for %s not found in manifest", secret.Name)
}
app.secretByPlaceholder[placeholder] = secret
}
}