Agenix references store path but does not not copy file

NixOS 25.11

age.secrets.ldap.file = ./ldap.age;

References a store path for ldap.age, but does not copy the file into the store.

What am I missing?

building the system configuration...
error:
       … while calling the 'head' builtin
         at /nix/store/cz5w8pifhg0srsqggxhhk6dp2j1zk01r-source/lib/attrsets.nix:1696:13:
         1695|           if length values == 1 || pred here (elemAt values 1) (head values) then
         1696|             head values
             |             ^
         1697|           else

       … while evaluating the attribute 'value'
         at /nix/store/cz5w8pifhg0srsqggxhhk6dp2j1zk01r-source/lib/modules.nix:1118:7:
         1117|     // {
         1118|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |       ^
         1119|       inherit (res.defsFinal') highestPrio;

       … while evaluating the option `system.build.toplevel':

       … while evaluating definitions from `/nix/store/cz5w8pifhg0srsqggxhhk6dp2j1zk01r-source/nixos/modules/system/activation/top-level.nix':

       … while evaluating the option `system.systemBuilderArgs':

       … while evaluating definitions from `/nix/store/cz5w8pifhg0srsqggxhhk6dp2j1zk01r-source/nixos/modules/system/activation/activatable-system.nix':

       … while evaluating the option `system.activationScripts.agenixInstall.text':

       … while evaluating definitions from `/nix/store/h3iilgx83as6hkb3lcclaqvqz6hwnmwq-source/modules/age.nix':

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: path '/nix/store/60fmhcs84bw4zqqkcfan08mgj905v8zi-source/workstation/ldap.age' does not exist
Command 'nix --extra-experimental-features 'nix-command flakes' build --print-out-paths '.#nixosConfigurations."tim-desktop".config.system.build.toplevel' --no-link' returned non-zero exit status 1.
tim@tim-desktop ~/N/N/nixos> ls -l /nix/store/60fmhcs84bw4zqqkcfan08mgj905v8zi-source/workstation/
total 56
-r--r--r-- 1 root root 55129 Dec 31  1969 configuration.nix
tim@tim-desktop ~/N/N/nixos>

You are using flakes and need to track the file in git. git add . is sufficient.

I added this to a git repository and committed it, but I still seem to have the same problem.

Does that file/folder exist in your source and is it definitely tracked by git?

I found it. I had the ldap.age one directory up from the file I was trying to use it in.
It still isn’t working, but it does look like it is copying the file and decrypting it correctly now.

1 Like