nix/home/core/sops.nix
{config, ...}: {
sops = {
defaultSopsFile = ../../secrets/secrets.yaml;
defaultSopsFormat = "yaml";
age = {
keyFile = "${config.xdg.configHome}/sops/age/keys.txt";
generateKey = false;
};
};
}
Where secrets.yaml is at: nix/secrets/secrets.yaml
Error:
error:
… while calling the 'derivationStrict' builtin
at <nix/derivation-internal.nix>:37:12:
36|
37| strict = derivationStrict drvAttrs;
| ^
38|
… while evaluating derivation 'home-manager-generation'
whose name attribute is located at /nix/store/kzqqrhnhh9q3dnrj3x10cdihmj09yc8p-source/pkgs/stdenv/generic/make-derivation.nix:536:13
… while evaluating attribute 'buildCommand' of derivation 'home-manager-generation'
at /nix/store/kzqqrhnhh9q3dnrj3x10cdihmj09yc8p-source/pkgs/build-support/trivial-builders/default.nix:80:17:
79| enableParallelBuilding = true;
80| inherit buildCommand name;
| ^
81| passAsFile = [ "buildCommand" ] ++ (derivationArgs.passAsFile or [ ]);
… while evaluating the option `home.file."/home/safri/.config/systemd/user/default.target.wants/sops-nix.service".source':
… while evaluating definitions from `/nix/store/bn63ba3kmrsicpc9ss8cyafqdcywbi20-source/modules/misc/xdg.nix':
… while evaluating the option `xdg.configFile."systemd/user/default.target.wants/sops-nix.service".source':
… while evaluating definitions from `/nix/store/bn63ba3kmrsicpc9ss8cyafqdcywbi20-source/modules/systemd.nix':
… while evaluating the option `systemd.user.services.sops-nix.Service.ExecStart':
… while evaluating definitions from `/nix/store/ri0m6qhhhc8n55fjwll9icrsnjgpws60-source/modules/home-manager/sops.nix':
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: access to absolute path '/nix/store/secrets' is forbidden in pure evaluation mode (use '--impure' to override)
Whereas a temporary fix is to create a sops.nix in the parent directory of the secrets.yaml and then import that both as a home-manager and nixos module.
I’m also having this issue in other areas:
Trying to import my bookmarks.nix (in home-manager) from a nixos module spits out a very similar error. While the sops case isn’t the end of the world, the point of this bookmarks.nix is that I only have to declare it once and then the same file is used both system and home wide. I’m also just curious as to why this is happening because I didn’t have this issue before.
Any help would be appreciated!