NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.32k stars 14.29k forks source link

/etc/nixos symlink no longer works on nixos-unstable-small #350036

Open aij opened 1 month ago

aij commented 1 month ago

Describe the bug

I have /etc/nixos symlinked to a directory with my system's NixOs configuration, so I can keep the config on my /home filesystem and in a subdirectory of a git repo. This lets me run nixos-rebuild build or nixos-rebuild switch without needing to specify an alternative location for the configs. I know others are doing similar as discussed on reddit.

After updating nixpkgs from 0b4d07d75e3baccf90c4766fead9ca6e24ce1741 to 61253596816c4cd65e2a0f474cbc0ac0c6e0f7cf, nixos-rebuild now starts failing with

error: path '/etc/nixos' is a symlink

Steps To Reproduce

Steps to reproduce the behavior:

  1. Symlink /etc/nixos/ to a directory with your nixos configuration.nix
  2. Run nixos-rebuild build

Expected behavior

The nixos system should be built successfully from the configuration, as it has in versions past.

Screenshots

ivan@tobati:~/nixops/aij$ nixos-rebuild build --show-trace
building Nix...
building the system configuration...
evaluation warning: zfs.latestCompatibleLinuxPackages is deprecated and is now pointing at the default kernel. If using the stable LTS kernel (default `linuxPackages` is not possible then you must explicitly pin a specific kernel release. For example, `boot.kernelPackages = pkgs.linuxPackages_6_6`. Please be aware that non-LTS kernels are likely to go EOL before ZFS supports the latest supported non-LTS release, requiring manual intervention.
error:
       … from call site
         at /etc/nixos/aij/unstable/nixos/default.nix:1:273:
       … while calling anonymous lambda
         at /etc/nixos/aij/unstable/lib/attrsets.nix:1:35642:
       … while calling the 'head' builtin
         at /etc/nixos/aij/unstable/lib/attrsets.nix:1:35787:
       … while calling anonymous lambda
         at /etc/nixos/aij/unstable/lib/attrsets.nix:1:27677:
       … from call site
         at /etc/nixos/aij/unstable/lib/attrsets.nix:1:27794:
       … while calling anonymous lambda
         at /etc/nixos/aij/unstable/lib/modules.nix:1:9031:
       … while evaluating the attribute 'value'
         at /etc/nixos/aij/unstable/lib/modules.nix:1:33591:
       … while evaluating the option `system.build.toplevel':

       … while evaluating the attribute 'mergedValue'
         at /etc/nixos/aij/unstable/lib/modules.nix:1:34959:
       … while evaluating a branch condition
         at /etc/nixos/aij/unstable/lib/modules.nix:1:34979:
       … while evaluating the attribute 'values'
         at /etc/nixos/aij/unstable/lib/modules.nix:1:34766:
       … while evaluating a branch condition
         at /etc/nixos/aij/unstable/lib/modules.nix:1:34612:
       … while calling the 'any' builtin
         at /etc/nixos/aij/unstable/lib/modules.nix:1:34615:
       … while evaluating the attribute 'values'
         at /etc/nixos/aij/unstable/lib/modules.nix:1:38484:
       … while calling the 'concatMap' builtin
         at /etc/nixos/aij/unstable/lib/modules.nix:1:38493:
       … while calling the 'concatMap' builtin
         at /etc/nixos/aij/unstable/lib/modules.nix:1:34231:
       … while calling anonymous lambda
         at /etc/nixos/aij/unstable/lib/modules.nix:1:34242:
       … while calling the 'map' builtin
         at /etc/nixos/aij/unstable/lib/modules.nix:1:34255:
       … while evaluating definitions from `/etc/nixos/aij/unstable/nixos/modules/system/activation/top-level.nix':

       … from call site
         at /etc/nixos/aij/unstable/lib/modules.nix:1:34372:
       … while calling 'dischargeProperties'
         at /etc/nixos/aij/unstable/lib/modules.nix:1:37119:
       … while evaluating a branch condition
         at /etc/nixos/aij/unstable/lib/modules.nix:1:37128:
       … while evaluating the attribute 'value'
         at /etc/nixos/aij/unstable/lib/modules.nix:1:24665:
       … from call site
         at /etc/nixos/aij/unstable/nixos/modules/system/activation/top-level.nix:1:2760:
       … while calling 'showWarnings'
         at /etc/nixos/aij/unstable/lib/trivial.nix:1:16786:
       … from call site
         at /etc/nixos/aij/unstable/lib/trivial.nix:1:16791:
       … while calling 'foldr'
         at /etc/nixos/aij/unstable/lib/lists.nix:1:1920:
       … from call site
         at /etc/nixos/aij/unstable/lib/lists.nix:1:2069:
       … while calling 'fold''
         at /etc/nixos/aij/unstable/lib/lists.nix:1:1973:
       … from call site
         at /etc/nixos/aij/unstable/nixos/modules/system/activation/top-level.nix:1:2057:
       … while calling 'mkDerivation'
         at /etc/nixos/aij/unstable/pkgs/stdenv/generic/make-derivation.nix:1:1800:
       … while evaluating a branch condition
         at /etc/nixos/aij/unstable/pkgs/stdenv/generic/make-derivation.nix:1:1817:
       … while calling the 'isFunction' builtin
         at /etc/nixos/aij/unstable/pkgs/stdenv/generic/make-derivation.nix:1:1820:
       … in the right operand of the update (//) operator
         at /etc/nixos/aij/unstable/nixos/modules/system/activation/top-level.nix:1:2438:
       … from call site
         at /etc/nixos/aij/unstable/nixos/modules/system/activation/top-level.nix:1:2441:
       … while calling anonymous lambda
         at /etc/nixos/aij/unstable/lib/attrsets.nix:1:27677:
       … from call site
         at /etc/nixos/aij/unstable/lib/attrsets.nix:1:27794:
       … while calling anonymous lambda
         at /etc/nixos/aij/unstable/lib/modules.nix:1:9031:
       … while evaluating the attribute 'value'
         at /etc/nixos/aij/unstable/lib/modules.nix:1:33591:
       … while evaluating the option `system.systemBuilderArgs':

       … while evaluating the attribute 'mergedValue'
         at /etc/nixos/aij/unstable/lib/modules.nix:1:34959:
       … from call site
         at /etc/nixos/aij/unstable/lib/modules.nix:1:35055:
       … while calling 'merge'
         at /etc/nixos/aij/unstable/lib/types.nix:1:19811:
       … while calling the 'mapAttrs' builtin
         at /etc/nixos/aij/unstable/lib/types.nix:1:19825:
       … from call site
         at /etc/nixos/aij/unstable/lib/types.nix:1:19851:
       … while calling 'filterAttrs'
         at /etc/nixos/aij/unstable/lib/attrsets.nix:1:15884:
       … while calling the 'listToAttrs' builtin
         at /etc/nixos/aij/unstable/lib/attrsets.nix:1:15893:
       … while calling the 'concatMap' builtin
         at /etc/nixos/aij/unstable/lib/attrsets.nix:1:15906:
       … while calling anonymous lambda
         at /etc/nixos/aij/unstable/lib/attrsets.nix:1:15917:
       … while evaluating a branch condition
         at /etc/nixos/aij/unstable/lib/attrsets.nix:1:15947:
       … from call site
         at /etc/nixos/aij/unstable/lib/attrsets.nix:1:15950:
       … while calling anonymous lambda
         at /etc/nixos/aij/unstable/lib/types.nix:1:19867:
       … from call site
         at /etc/nixos/aij/unstable/lib/attrsets.nix:1:15931:
       … while calling anonymous lambda
         at /etc/nixos/aij/unstable/lib/types.nix:1:19902:
       … while evaluating the attribute 'optionalValue'
         at /etc/nixos/aij/unstable/lib/modules.nix:1:35609:
       … while evaluating a branch condition
         at /etc/nixos/aij/unstable/lib/modules.nix:1:35631:
       (8 duplicate frames omitted)

       … while evaluating definitions from `/etc/nixos/aij/unstable/nixos/modules/system/activation/activatable-system.nix':

       … from call site
         at /etc/nixos/aij/unstable/lib/modules.nix:1:34372:
       … while calling 'dischargeProperties'
         at /etc/nixos/aij/unstable/lib/modules.nix:1:37119:
       … while evaluating a branch condition
         at /etc/nixos/aij/unstable/lib/modules.nix:1:37128:
       … while evaluating the attribute 'value'
         at /etc/nixos/aij/unstable/lib/types.nix:1:20091:
       … while evaluating the attribute 'system.activationScripts.script'
         at /etc/nixos/aij/unstable/nixos/modules/system/activation/activation-script.nix:1:4216:
       … from call site
         at /etc/nixos/aij/unstable/nixos/modules/system/activation/activation-script.nix:1:4225:
       … while calling 'systemActivationScript'
         at /etc/nixos/aij/unstable/nixos/modules/system/activation/activation-script.nix:1:422:
       … from call site
         at /etc/nixos/aij/unstable/nixos/modules/system/activation/activation-script.nix:1:1569:
       … while calling 'textClosureMap'
         at /etc/nixos/aij/unstable/lib/strings-with-deps.nix:1:2263:
       … while calling the 'concatStringsSep' builtin
         at /etc/nixos/aij/unstable/lib/strings-with-deps.nix:1:2274:
       … while calling 'id'
         at /etc/nixos/aij/unstable/lib/trivial.nix:1:463:
       … while evaluating the attribute 'text'
         at /etc/nixos/aij/unstable/nixos/modules/system/activation/activation-script.nix:1:152:
       … from call site
         at /etc/nixos/aij/unstable/nixos/modules/system/activation/activation-script.nix:1:234:
       … while calling anonymous lambda
         at /etc/nixos/aij/unstable/lib/attrsets.nix:1:27677:
       … from call site
         at /etc/nixos/aij/unstable/lib/attrsets.nix:1:27794:
       … while calling anonymous lambda
         at /etc/nixos/aij/unstable/lib/modules.nix:1:9031:
       … while evaluating the attribute 'value'
         at /etc/nixos/aij/unstable/lib/modules.nix:1:33591:
       … while evaluating the option `system.activationScripts.etc.text':

       (10 duplicate frames omitted)

       … while evaluating definitions from `/etc/nixos/aij/unstable/nixos/modules/system/etc/etc-activation.nix':

       … from call site
         at /etc/nixos/aij/unstable/lib/modules.nix:1:34372:
       … while calling 'dischargeProperties'
         at /etc/nixos/aij/unstable/lib/modules.nix:1:37119:
       … while evaluating a branch condition
         at /etc/nixos/aij/unstable/lib/modules.nix:1:37128:
       … while evaluating the attribute 'value'
         at /etc/nixos/aij/unstable/lib/modules.nix:1:24665:
       … from call site
         at /etc/nixos/aij/unstable/nixos/modules/system/etc/etc-activation.nix:1:175:
       … while calling anonymous lambda
         at /etc/nixos/aij/unstable/lib/attrsets.nix:1:35642:
       … while calling the 'head' builtin
         at /etc/nixos/aij/unstable/lib/attrsets.nix:1:35787:
       … while calling anonymous lambda
         at /etc/nixos/aij/unstable/lib/types.nix:1:21175:
       … while evaluating the attribute 'optionalValue.value'
         at /etc/nixos/aij/unstable/lib/modules.nix:1:35609:
       (9 duplicate frames omitted)

       … while evaluating definitions from `/etc/nixos/aij/unstable/nixos/modules/system/etc/etc.nix':

       … from call site
         at /etc/nixos/aij/unstable/lib/modules.nix:1:34372:
       … while calling 'dischargeProperties'
         at /etc/nixos/aij/unstable/lib/modules.nix:1:37119:
       … while evaluating a branch condition
         at /etc/nixos/aij/unstable/lib/modules.nix:1:37128:
       … while evaluating the attribute 'value'
         at /etc/nixos/aij/unstable/lib/types.nix:1:21517:
       … from call site
         at /etc/nixos/aij/unstable/lib/attrsets.nix:1:6537:
       … while calling 'atDepth'
         at /etc/nixos/aij/unstable/lib/attrsets.nix:1:6457:
       … while evaluating the attribute 'value'
         at /etc/nixos/aij/unstable/lib/modules.nix:1:24665:
       … while calling the 'getAttr' builtin
         at <nix/derivation-internal.nix>:44:19:
           43|       value = commonAttrs // {
           44|         outPath = builtins.getAttr outputName strict;
             |                   ^
           45|         drvPath = strict.drvPath;

       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:34:12:
           33|
           34|   strict = derivationStrict drvAttrs;
             |            ^
           35|

       … while evaluating derivation 'etc'
         whose name attribute is located at /etc/nixos/aij/unstable/pkgs/stdenv/generic/make-derivation.nix:1:12605

       … while evaluating attribute 'buildCommand' of derivation 'etc'
         at /etc/nixos/aij/unstable/pkgs/build-support/trivial-builders/default.nix:1:1874:
       … from call site
         at /etc/nixos/aij/unstable/nixos/modules/system/etc/etc.nix:1:1306:
       … while calling 'concatMapStringsSep'
         at /etc/nixos/aij/unstable/lib/strings.nix:1:3621:
       … while calling the 'concatStringsSep' builtin
         at /etc/nixos/aij/unstable/lib/strings.nix:1:3627:
       … while calling anonymous lambda
         at /etc/nixos/aij/unstable/nixos/modules/system/etc/etc.nix:1:1336:
       … from call site
         at /etc/nixos/aij/unstable/nixos/modules/system/etc/etc.nix:1:1346:
       … while calling 'concatMapStringsSep'
         at /etc/nixos/aij/unstable/lib/strings.nix:1:3621:
       … while calling the 'concatStringsSep' builtin
         at /etc/nixos/aij/unstable/lib/strings.nix:1:3627:
       … while calling 'escapeShellArg'
         at /etc/nixos/aij/unstable/lib/strings.nix:1:20784:
       … while evaluating a branch condition
         at /etc/nixos/aij/unstable/lib/strings.nix:1:20839:
       … while calling the 'match' builtin
         at /etc/nixos/aij/unstable/lib/strings.nix:1:20842:
       … while evaluating the second argument passed to builtins.match

       … while calling the 'toString' builtin
         at /etc/nixos/aij/unstable/lib/strings.nix:1:20812:
       … from call site
         at /etc/nixos/aij/unstable/nixos/modules/system/etc/etc.nix:1:1456:
       … while calling anonymous lambda
         at /etc/nixos/aij/unstable/lib/attrsets.nix:1:27677:
       … from call site
         at /etc/nixos/aij/unstable/lib/attrsets.nix:1:27794:
       … while calling anonymous lambda
         at /etc/nixos/aij/unstable/lib/modules.nix:1:9031:
       … while evaluating the attribute 'value'
         at /etc/nixos/aij/unstable/lib/modules.nix:1:33591:
       … while evaluating the option `environment.etc.dbus-1.source':

       … while evaluating the attribute 'mergedValue'
         at /etc/nixos/aij/unstable/lib/modules.nix:1:34959:
       … while evaluating a branch condition
         at /etc/nixos/aij/unstable/lib/modules.nix:1:35005:
       … while calling the 'all' builtin
         at /etc/nixos/aij/unstable/lib/modules.nix:1:35008:
       … while calling anonymous lambda
         at /etc/nixos/aij/unstable/lib/modules.nix:1:35013:
       … from call site
         at /etc/nixos/aij/unstable/lib/modules.nix:1:35018:
       … while calling 'check'
         at /etc/nixos/aij/unstable/lib/types.nix:1:17855:
       … in the right operand of the AND (&&) operator
         at /etc/nixos/aij/unstable/lib/types.nix:1:17873:
       … while calling the 'substring' builtin
         at /etc/nixos/aij/unstable/lib/types.nix:1:17876:
       … while calling the 'toString' builtin
         at /etc/nixos/aij/unstable/lib/types.nix:1:17900:
       … while calling the 'getAttr' builtin
         at <nix/derivation-internal.nix>:44:19:
           43|       value = commonAttrs // {
           44|         outPath = builtins.getAttr outputName strict;
             |                   ^
           45|         drvPath = strict.drvPath;

       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:34:12:
           33|
           34|   strict = derivationStrict drvAttrs;
             |            ^
           35|

       … while evaluating derivation 'dbus-1'
         whose name attribute is located at /etc/nixos/aij/unstable/pkgs/stdenv/generic/make-derivation.nix:1:12605

       … while evaluating attribute 'serviceDirectories' of derivation 'dbus-1'
         at /etc/nixos/aij/unstable/pkgs/development/libraries/dbus/make-dbus-conf.nix:1:529:
       … while calling anonymous lambda
         at /etc/nixos/aij/unstable/lib/types.nix:1:18520:
       … while evaluating the attribute 'value'
         at /etc/nixos/aij/unstable/lib/modules.nix:1:35651:
       (10 duplicate frames omitted)

       … while evaluating derivation 'system-path'
         whose name attribute is located at /etc/nixos/aij/unstable/pkgs/stdenv/generic/make-derivation.nix:1:12605

       … while evaluating attribute 'passAsFile' of derivation 'system-path'
         at /etc/nixos/aij/unstable/pkgs/build-support/trivial-builders/default.nix:1:1901:
       … while evaluating the attribute 'passAsFile'
         at /etc/nixos/aij/unstable/pkgs/build-support/buildenv/default.nix:1:2730:
       … while evaluating a branch condition
         at /etc/nixos/aij/unstable/pkgs/build-support/buildenv/default.nix:1:2743:
       … in the argument of the not operator
         at /etc/nixos/aij/unstable/pkgs/build-support/buildenv/default.nix:1:2773:
       … while calling the 'lessThan' builtin
         at /etc/nixos/aij/unstable/pkgs/build-support/buildenv/default.nix:1:2773:
       … while calling the 'stringLength' builtin
         at /etc/nixos/aij/unstable/pkgs/build-support/buildenv/default.nix:1:2746:
       … while calling the 'toJSON' builtin
         at /etc/nixos/aij/unstable/pkgs/build-support/buildenv/default.nix:1:2512:
       … while evaluating list element at index 209

       … while evaluating attribute 'paths'
         at /etc/nixos/aij/unstable/pkgs/build-support/buildenv/default.nix:1:1438:
       … while evaluating list element at index 0
         at /etc/nixos/aij/unstable/pkgs/build-support/buildenv/default.nix:1:1438:
       … while calling the 'getAttr' builtin
         at <nix/derivation-internal.nix>:44:19:
           43|       value = commonAttrs // {
           44|         outPath = builtins.getAttr outputName strict;
             |                   ^
           45|         drvPath = strict.drvPath;

       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:34:12:
           33|
           34|   strict = derivationStrict drvAttrs;
             |            ^
           35|

       … while evaluating derivation 'nixos-version'
         whose name attribute is located at /etc/nixos/aij/unstable/pkgs/stdenv/generic/make-derivation.nix:1:12605

       … while evaluating attribute 'json' of derivation 'nixos-version'
         at /etc/nixos/aij/unstable/nixos/modules/installer/tools/tools.nix:1:1130:
       … while calling the 'toJSON' builtin
         at /etc/nixos/aij/unstable/nixos/modules/installer/tools/tools.nix:1:1137:
       … in the right operand of the update (//) operator
         at /etc/nixos/aij/unstable/nixos/modules/installer/tools/tools.nix:1:1212:
       … in the left operand of the update (//) operator
         at /etc/nixos/aij/unstable/nixos/modules/installer/tools/tools.nix:1:1334:
       … from call site
         at /etc/nixos/aij/unstable/nixos/modules/installer/tools/tools.nix:1:1215:
       … while calling 'optionalAttrs'
         at /etc/nixos/aij/unstable/lib/attrsets.nix:1:30186:
       … while evaluating a branch condition
         at /etc/nixos/aij/unstable/lib/attrsets.nix:1:30194:
       … from call site
         at /etc/nixos/aij/unstable/nixos/modules/installer/tools/tools.nix:1:1234:
       … while calling anonymous lambda
         at /etc/nixos/aij/unstable/lib/attrsets.nix:1:27677:
       … from call site
         at /etc/nixos/aij/unstable/lib/attrsets.nix:1:27794:
       … while calling anonymous lambda
         at /etc/nixos/aij/unstable/lib/modules.nix:1:9031:
       … while evaluating the attribute 'value'
         at /etc/nixos/aij/unstable/lib/modules.nix:1:33591:
       … while evaluating the option `system.nixos.revision':

       … while evaluating the attribute 'mergedValue'
         at /etc/nixos/aij/unstable/lib/modules.nix:1:34959:
       … while evaluating a branch condition
         at /etc/nixos/aij/unstable/lib/modules.nix:1:34979:
       … while evaluating the attribute 'values'
         at /etc/nixos/aij/unstable/lib/modules.nix:1:34766:
       … while evaluating a branch condition
         at /etc/nixos/aij/unstable/lib/modules.nix:1:34612:
       … while calling the 'any' builtin
         at /etc/nixos/aij/unstable/lib/modules.nix:1:34615:
       … while calling anonymous lambda
         at /etc/nixos/aij/unstable/lib/modules.nix:1:34620:
       … while evaluating the attribute 'value._type'
         at /etc/nixos/aij/unstable/lib/modules.nix:1:38430:
       … while evaluating the attribute 'value.content'
         at /etc/nixos/aij/unstable/lib/modules.nix:1:41110:
       … while evaluating the attribute 'default'
         at /etc/nixos/aij/unstable/nixos/modules/misc/version.nix:1:3073:
       … from call site
         at /etc/nixos/aij/unstable/nixos/modules/misc/version.nix:1:3083:
       … while calling 'revisionWithDefault'
         at /etc/nixos/aij/unstable/lib/trivial.nix:1:7709:
       … while evaluating a branch condition
         at /etc/nixos/aij/unstable/lib/trivial.nix:1:7834:
       … from call site
         at /etc/nixos/aij/unstable/lib/trivial.nix:1:7837:
       … while calling 'pathIsGitRepo'
         at /etc/nixos/aij/unstable/lib/sources.nix:1:4695:
       … from call site
         at /etc/nixos/aij/unstable/lib/sources.nix:1:4702:
       … while calling 'readCommitFromFile'
         at /etc/nixos/aij/unstable/lib/sources.nix:1:5268:
       … while evaluating a branch condition
         at /etc/nixos/aij/unstable/lib/sources.nix:1:5544:
       … from call site
         at /etc/nixos/aij/unstable/lib/sources.nix:1:5547:
       … while calling 'pathIsRegularFile'
         at /etc/nixos/aij/unstable/lib/filesystem.nix:1:2619:
       … in the right operand of the AND (&&) operator
         at /etc/nixos/aij/unstable/lib/filesystem.nix:1:2645:
       … while calling the 'readFileType' builtin
         at /etc/nixos/aij/unstable/lib/filesystem.nix:1:2648:
       error: path '/etc/nixos' is a symlink
1 ivan@tobati:~/nixops/aij$ 

Additional context

As a workaround, I was able to specify paths via -I:

nixos-rebuild build -I nixos-config=$PWD/configuration.nix -I nixpkgs=$PWD/aij/unstable

My configuration is here: https://github.com/aij/aij-nixos-config/commit/6bab12822f4a2463941a9b20f0a32a24da10bd62

I probably should consider switching to flakes...

Notify maintainers

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

ivan@tobati:~/nixops/aij$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.54, NixOS, 24.11 (Vicuna), 24.11.git.61253596816c`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.24.9`
 - channels(root): `""`
 - nixpkgs: `/etc/nixos/aij/unstable`

Add a :+1: reaction to issues you find important.

Frontear commented 1 month ago

I believe this change is related to the updating of Nix to 2.24. IIRC this behaviour is either considered a regression or a bug upstream at https://github.com/NixOS/nix