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:
parent
3433ea14fb
commit
8d13626351
3 changed files with 11 additions and 4 deletions
|
@ -99,6 +99,7 @@ let
|
||||||
sshKeyPaths = cfg.gnupg.sshKeyPaths;
|
sshKeyPaths = cfg.gnupg.sshKeyPaths;
|
||||||
ageKeyFile = cfg.age.keyFile;
|
ageKeyFile = cfg.age.keyFile;
|
||||||
ageSshKeyPaths = cfg.age.sshKeyPaths;
|
ageSshKeyPaths = cfg.age.sshKeyPaths;
|
||||||
|
placeholderBySecretName = cfg.placeholder;
|
||||||
userMode = true;
|
userMode = true;
|
||||||
logging = {
|
logging = {
|
||||||
keyImport = builtins.elem "keyImport" cfg.log;
|
keyImport = builtins.elem "keyImport" cfg.log;
|
||||||
|
|
|
@ -12,6 +12,8 @@ let
|
||||||
mapAttrs
|
mapAttrs
|
||||||
types
|
types
|
||||||
;
|
;
|
||||||
|
|
||||||
|
hmConfig = config;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.sops = {
|
options.sops = {
|
||||||
|
@ -33,7 +35,7 @@ in
|
||||||
description = "Path where the rendered file will be placed";
|
description = "Path where the rendered file will be placed";
|
||||||
type = types.singleLineStr;
|
type = types.singleLineStr;
|
||||||
# Keep this in sync with `RenderedSubdir` in `pkgs/sops-install-secrets/main.go`
|
# 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 {
|
content = mkOption {
|
||||||
type = types.lines;
|
type = types.lines;
|
||||||
|
@ -97,10 +99,10 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.optionalAttrs (options ? sops.secrets) (
|
config = lib.optionalAttrs (options ? sops.secrets) (
|
||||||
lib.mkIf (config.sops.templates != { }) {
|
lib.mkIf (hmConfig.sops.templates != { }) {
|
||||||
sops.placeholder = mapAttrs (
|
sops.placeholder = mapAttrs (
|
||||||
name: _: mkDefault "<SOPS:${builtins.hashString "sha256" name}:PLACEHOLDER>"
|
name: _: mkDefault "<SOPS:${builtins.hashString "sha256" name}:PLACEHOLDER>"
|
||||||
) config.sops.secrets;
|
) hmConfig.sops.secrets;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -698,7 +698,11 @@ func (app *appContext) validateManifest() error {
|
||||||
// The Nix module only defines placeholders for secrets if there are
|
// The Nix module only defines placeholders for secrets if there are
|
||||||
// templates.
|
// templates.
|
||||||
if len(m.Templates) > 0 {
|
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
|
app.secretByPlaceholder[placeholder] = secret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue