Suggested upgrade-nix install method fails on macOS #431

Closed
opened 2024-07-05 13:24:05 +00:00 by sersorrel · 1 comment

Describe the bug

I tried running the recommended install command for macOS systems with existing nix installations:

sudo env PATH="$PATH" nix run \
     --experimental-features "nix-command flakes" \
     --extra-substituters https://cache.lix.systems --extra-trusted-public-keys "cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o=" \
     'git+https://git@git.lix.systems/lix-project/lix?ref=refs/tags/2.90.0-rc1' -- \
     upgrade-nix \
     --extra-substituters https://cache.lix.systems --extra-trusted-public-keys "cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o="

(adjusted slightly to work around frustrating sudo config that appears to break --preserve-env)

but I got the following error:

error: access to absolute path '/nix/store' is forbidden in pure eval mode (use '--impure' to override)

Steps To Reproduce

  1. Run the install command
  2. It doesn't work

Expected behavior

I wanted lix to be installed :(

nix --version output

nix (Nix) 2.11.0

Additional context

--show-trace output:
error: access to absolute path '/nix/store' is forbidden in pure eval mode (use '--impure' to override)

       … while realising the context of path '/nix/store'

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/filesystem.nix:59:13:

           58|       then "directory"
           59|       else (readDir (dirOf path)).${baseNameOf path}
             |             ^
           60|     );

       … while evaluating anonymous lambda

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/filesystem.nix:49:6:

           48|     # Nix <2.14 compatibility shim
           49|     (path:
             |      ^
           50|       if ! pathExists path

       … from call site

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/internal.nix:854:18:

          853|
          854|       rootType = pathType root;
             |                  ^
          855|     in

       … while evaluating '_fileFilter'

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/internal.nix:825:28:

          824|   # Type: ({ name, type, ... } -> Bool) -> Path -> FileSet
          825|   _fileFilter = predicate: root:
             |                            ^
          826|     let

       … from call site

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/default.nix:847:7:

          846|     else
          847|       _fileFilter predicate path;
             |       ^
          848|

       … while evaluating 'fileFilter'

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/default.nix:831:5:

          830|     predicate:
          831|     path:
             |     ^
          832|     if ! isFunction predicate then

       … from call site

       at /nix/store/83j54gqqfz9ikypz8as6rdclg7jk3ibj-source/package.nix:137:15:

          136|   # that would interfere with repo semantics.
          137|   baseFiles = fileset.fileFilter (f: f.name != ".gitignore") ./.;
             |               ^
          138|

       … while evaluating '_coerce'

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/internal.nix:165:22:

          164|   # Type: String -> (fileset | Path) -> fileset
          165|   _coerce = context: value:
             |                      ^
          166|     if value._type or "" == "fileset" then

       … from call site

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/internal.nix:207:9:

          206|       filesets = map ({ context, value }:
          207|         _coerce "${functionContext}: ${context}" value
             |         ^
          208|       ) list;

       … while evaluating anonymous lambda

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/internal.nix:206:23:

          205|     let
          206|       filesets = map ({ context, value }:
             |                       ^
          207|         _coerce "${functionContext}: ${context}" value

       … from call site

       … while evaluating anonymous lambda

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/internal.nix:211:34:

          210|       # Find the first value with a base, there may be none!
          211|       firstWithBase = findFirst (fileset: ! fileset._internalIsEmptyWithoutBase) null filesets;
             |                                  ^
          212|       # This value is only accessed if first != null

       … from call site

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/lists.nix:585:14:

          584|           # No match yet before the current index, we need to check the element
          585|           if pred el then
             |              ^
          586|             # We have a match! Turn it into the actual index to prevent future iterations from modifying it

       … while evaluating anonymous lambda

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/lists.nix:582:36:

          581|       # We start with index -1 and the 0'th element of the list, which satisfies the invariant
          582|       resultIndex = foldl' (index: el:
             |                                    ^
          583|         if index < 0 then

       … from call site

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/lists.nix:582:21:

          581|       # We start with index -1 and the 0'th element of the list, which satisfies the invariant
          582|       resultIndex = foldl' (index: el:
             |                     ^
          583|         if index < 0 then

       … while evaluating 'findFirstIndex'

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/lists.nix:567:5:

          566|     default:
          567|     list:
             |     ^
          568|     let

       … from call site

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/lists.nix:643:15:

          642|     let
          643|       index = findFirstIndex pred null list;
             |               ^
          644|     in

       … while evaluating 'findFirst'

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/lists.nix:641:5:

          640|     default:
          641|     list:
             |     ^
          642|     let

       … from call site

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/internal.nix:211:23:

          210|       # Find the first value with a base, there may be none!
          211|       firstWithBase = findFirst (fileset: ! fileset._internalIsEmptyWithoutBase) null filesets;
             |                       ^
          212|       # This value is only accessed if first != null

       … while evaluating '_coerceMany'

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/internal.nix:204:34:

          203|   # Type: String -> [ { context :: String, value :: fileset | Path } ] -> [ fileset ]
          204|   _coerceMany = functionContext: list:
             |                                  ^
          205|     let

       … from call site

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/default.nix:687:18:

          686|     let
          687|       filesets = _coerceMany "lib.fileset.intersection" [
             |                  ^
          688|         {

       … while evaluating '_intersection'

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/internal.nix:674:29:

          673|   # Type: Fileset -> Fileset -> Fileset
          674|   _intersection = fileset1: fileset2:
             |                             ^
          675|     let

       … from call site

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/default.nix:698:5:

          697|     in
          698|     _intersection
             |     ^
          699|       (elemAt filesets 0)

       … while evaluating 'intersection'

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/default.nix:685:5:

          684|     fileset1:
          685|     fileset2:
             |     ^
          686|     let

       … from call site

       at /nix/store/83j54gqqfz9ikypz8as6rdclg7jk3ibj-source/package.nix:160:15:

          159|     root = ./.;
          160|     fileset = fileset.intersection baseFiles (
             |               ^
          161|       fileset.unions (

       … while evaluating '_coerce'

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/internal.nix:165:22:

          164|   # Type: String -> (fileset | Path) -> fileset
          165|   _coerce = context: value:
             |                      ^
          166|     if value._type or "" == "fileset" then

       … from call site

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/default.nix:435:17:

          434|     let
          435|       fileset = _coerce "lib.fileset.toSource: `fileset`" filesetArg;
             |                 ^
          436|       rootFilesystemRoot = (splitRoot root).root;

       … while evaluating 'toSource'

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/default.nix:426:14:

          425|   */
          426|   toSource = {
             |              ^
          427|     root,

       … from call site

       at /nix/store/83j54gqqfz9ikypz8as6rdclg7jk3ibj-source/package.nix:158:9:

          157|
          158|   src = fileset.toSource {
             |         ^
          159|     root = ./.;

       … while evaluating the attribute 'src' of the derivation 'lix-2.90.0-rc1'

       at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/pkgs/stdenv/generic/make-derivation.nix:331:7:

          330|     // (optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          331|       name =
             |       ^
          332|         let
## Describe the bug I tried running the recommended install command for macOS systems with existing nix installations: ``` sudo env PATH="$PATH" nix run \ --experimental-features "nix-command flakes" \ --extra-substituters https://cache.lix.systems --extra-trusted-public-keys "cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o=" \ 'git+https://git@git.lix.systems/lix-project/lix?ref=refs/tags/2.90.0-rc1' -- \ upgrade-nix \ --extra-substituters https://cache.lix.systems --extra-trusted-public-keys "cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o=" ``` (adjusted slightly to work around frustrating sudo config that appears to break `--preserve-env`) but I got the following error: ``` error: access to absolute path '/nix/store' is forbidden in pure eval mode (use '--impure' to override) ``` ## Steps To Reproduce 1. Run the install command 2. It doesn't work ## Expected behavior I wanted lix to be installed :( ## `nix --version` output ``` nix (Nix) 2.11.0 ``` ## Additional context <details><summary>--show-trace output:</summary> ``` error: access to absolute path '/nix/store' is forbidden in pure eval mode (use '--impure' to override) … while realising the context of path '/nix/store' at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/filesystem.nix:59:13: 58| then "directory" 59| else (readDir (dirOf path)).${baseNameOf path} | ^ 60| ); … while evaluating anonymous lambda at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/filesystem.nix:49:6: 48| # Nix <2.14 compatibility shim 49| (path: | ^ 50| if ! pathExists path … from call site at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/internal.nix:854:18: 853| 854| rootType = pathType root; | ^ 855| in … while evaluating '_fileFilter' at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/internal.nix:825:28: 824| # Type: ({ name, type, ... } -> Bool) -> Path -> FileSet 825| _fileFilter = predicate: root: | ^ 826| let … from call site at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/default.nix:847:7: 846| else 847| _fileFilter predicate path; | ^ 848| … while evaluating 'fileFilter' at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/default.nix:831:5: 830| predicate: 831| path: | ^ 832| if ! isFunction predicate then … from call site at /nix/store/83j54gqqfz9ikypz8as6rdclg7jk3ibj-source/package.nix:137:15: 136| # that would interfere with repo semantics. 137| baseFiles = fileset.fileFilter (f: f.name != ".gitignore") ./.; | ^ 138| … while evaluating '_coerce' at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/internal.nix:165:22: 164| # Type: String -> (fileset | Path) -> fileset 165| _coerce = context: value: | ^ 166| if value._type or "" == "fileset" then … from call site at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/internal.nix:207:9: 206| filesets = map ({ context, value }: 207| _coerce "${functionContext}: ${context}" value | ^ 208| ) list; … while evaluating anonymous lambda at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/internal.nix:206:23: 205| let 206| filesets = map ({ context, value }: | ^ 207| _coerce "${functionContext}: ${context}" value … from call site … while evaluating anonymous lambda at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/internal.nix:211:34: 210| # Find the first value with a base, there may be none! 211| firstWithBase = findFirst (fileset: ! fileset._internalIsEmptyWithoutBase) null filesets; | ^ 212| # This value is only accessed if first != null … from call site at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/lists.nix:585:14: 584| # No match yet before the current index, we need to check the element 585| if pred el then | ^ 586| # We have a match! Turn it into the actual index to prevent future iterations from modifying it … while evaluating anonymous lambda at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/lists.nix:582:36: 581| # We start with index -1 and the 0'th element of the list, which satisfies the invariant 582| resultIndex = foldl' (index: el: | ^ 583| if index < 0 then … from call site at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/lists.nix:582:21: 581| # We start with index -1 and the 0'th element of the list, which satisfies the invariant 582| resultIndex = foldl' (index: el: | ^ 583| if index < 0 then … while evaluating 'findFirstIndex' at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/lists.nix:567:5: 566| default: 567| list: | ^ 568| let … from call site at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/lists.nix:643:15: 642| let 643| index = findFirstIndex pred null list; | ^ 644| in … while evaluating 'findFirst' at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/lists.nix:641:5: 640| default: 641| list: | ^ 642| let … from call site at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/internal.nix:211:23: 210| # Find the first value with a base, there may be none! 211| firstWithBase = findFirst (fileset: ! fileset._internalIsEmptyWithoutBase) null filesets; | ^ 212| # This value is only accessed if first != null … while evaluating '_coerceMany' at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/internal.nix:204:34: 203| # Type: String -> [ { context :: String, value :: fileset | Path } ] -> [ fileset ] 204| _coerceMany = functionContext: list: | ^ 205| let … from call site at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/default.nix:687:18: 686| let 687| filesets = _coerceMany "lib.fileset.intersection" [ | ^ 688| { … while evaluating '_intersection' at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/internal.nix:674:29: 673| # Type: Fileset -> Fileset -> Fileset 674| _intersection = fileset1: fileset2: | ^ 675| let … from call site at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/default.nix:698:5: 697| in 698| _intersection | ^ 699| (elemAt filesets 0) … while evaluating 'intersection' at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/default.nix:685:5: 684| fileset1: 685| fileset2: | ^ 686| let … from call site at /nix/store/83j54gqqfz9ikypz8as6rdclg7jk3ibj-source/package.nix:160:15: 159| root = ./.; 160| fileset = fileset.intersection baseFiles ( | ^ 161| fileset.unions ( … while evaluating '_coerce' at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/internal.nix:165:22: 164| # Type: String -> (fileset | Path) -> fileset 165| _coerce = context: value: | ^ 166| if value._type or "" == "fileset" then … from call site at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/default.nix:435:17: 434| let 435| fileset = _coerce "lib.fileset.toSource: `fileset`" filesetArg; | ^ 436| rootFilesystemRoot = (splitRoot root).root; … while evaluating 'toSource' at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/lib/fileset/default.nix:426:14: 425| */ 426| toSource = { | ^ 427| root, … from call site at /nix/store/83j54gqqfz9ikypz8as6rdclg7jk3ibj-source/package.nix:158:9: 157| 158| src = fileset.toSource { | ^ 159| root = ./.; … while evaluating the attribute 'src' of the derivation 'lix-2.90.0-rc1' at /nix/store/dl7iffd3sa1y4zayhpjj8k54qnzsx5x9-source/pkgs/stdenv/generic/make-derivation.nix:331:7: 330| // (optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) { 331| name = | ^ 332| let ``` </details>
sersorrel added the
bug
label 2024-07-05 13:24:05 +00:00
Owner

Triaged to being that the nix run command, regardless of upgrade-nix, does not work, because it cannot successfully evaluate the lix derivation itself. This is probably a bug or behaviour change in Nix 2.11, which we probably should not bother to root cause because 2.11 is so old.

In a similar situation to this, you can probably run the installer to perform the upgrade by that way instead.

It should probably fix things in this exact situation if you pass --impure, even if really it should not be necessary; on matrix we found that it fixes the nix run.

Triaged to being that the `nix run` command, regardless of `upgrade-nix`, does not work, because it cannot successfully evaluate the lix derivation itself. This is probably a bug or behaviour change in Nix 2.11, which we probably should not bother to root cause because 2.11 is so old. In a similar situation to this, you can probably run the installer to perform the upgrade by that way instead. It should probably fix things in this exact situation if you pass `--impure`, even if really it should not be necessary; on matrix we found that it fixes the `nix run`.
jade closed this issue 2024-07-05 13:35:16 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#431
No description provided.