Hello there i need some help, mainly its about setting sops variables in home manager.
new error: error: attribute ‘“email/realName”’ missing
i havent put here but the file modules/home/email/default.nix
defines sops.secrets."email/realName"
right
this is the module that is using the sops secrets
modules/home/email/gmail_main.nix
{ lib, config, ... }:
{
options.modules.email.enableAccounts.gmail_main =
lib.mkEnableOption "config gmail_main account";
config = lib.mkIf config.modules.email.enableAccounts.gmail_main {
sops.secrets."email/gmail_main/address" = { sopsFile = ../../../secrets/email.yaml; };
sops.secrets."email/gmail_main/pass" = { sopsFile = ../../../secrets/email.yaml; };
accounts.email.accounts.gmail_main = let
realName = config.sops.secrets."email/realName";
address = config.sops.secrets."email/gmail_main/address";
pass = config.sops.secrets."email/gmail_main/pass";
in {
address = address;
userName = address;
passwordCommand = pass;
inherit realName;
# gpg
gpg.key = config.programs.git.signing.key;
gpg.signByDefault = true;
# settings
primary = true;
msmtp.enable = true;
notmuch.enable = true;
mbsync.enable = true;
mbsync.create = "maildir";
imap.host = "gmail.com";
smtp.host = "gmail.com";
# signature
signature = {
text = ''
${realName}
'';
showSignature = "append";
};
};
};
}
sops in home manager is configured on this file modules/home/sops.nix
updated content
{ lib, config, inputs, ... }:
{
imports = [
inputs.sops-nix.homeManagerModules.sops
];
config = {
sops = {
defaultSopsFormat = "yaml";
# This will add secrets.yml to the nix store
# You can avoid this by adding a string to the full path instead, i.e.
# defaultSopsFile = ../../../secrets/secrets.yaml;
defaultSopsFile = "/root/.sops/secrets/secrets.yaml";
# defaultSopsFile = ./secrets/example.yaml;
# This will automatically import SSH keys as age keys
age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
# This is using an age key that is expected to already be in the filesystem
age.keyFile = "/var/lib/sops-nix/key.txt";
# This will generate a new key if the key specified above does not exist
age.generateKey = true;
};
};
}```
the file `modules/core/security/sops.nix`
```nix
{ lib, config, inputs, pkgs, ... }:
{
imports = [ inputs.sops-nix.nixosModules.sops ];
options.modules.security.sops.enable =
lib.mkEnableOption "enable sops module";
config = lib.mkIf config.modules.security.sops.enable {
environment.systemPackages = [ pkgs.sops ];
sops = {
defaultSopsFormat = "yaml";
# This will add secrets.yml to the nix store
# You can avoid this by adding a string to the full path instead, i.e.
# defaultSopsFile = ../../../secrets/secrets.yaml;
defaultSopsFile = "/root/.sops/secrets/secrets.yaml";
# defaultSopsFile = ./secrets/example.yaml;
# This will automatically import SSH keys as age keys
age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
# This is using an age key that is expected to already be in the filesystem
age.keyFile = "/var/lib/sops-nix/key.txt";
# This will generate a new key if the key specified above does not exist
age.generateKey = true;
};
};
}