purebred-mua / purebred

A terminal based mail user agent based on notmuch
GNU Affero General Public License v3.0
139 stars 19 forks source link

Building via the nix flake fails #482

Closed lucc closed 1 year ago

lucc commented 1 year ago

Describe the bug

I am building with nix via the flake. This fails with the error message

error: getting status of '/nix/store/rldh08aady2kz9md2li14da1kd04pd07-source': No such file or directory

To Reproduce

Try to build any of the packages provided by the flake

$ nix build github:purebred-mua/purebred#purebred-with-packages-icu
error: getting status of '/nix/store/rldh08aady2kz9md2li14da1kd04pd07-source': No such file or directory
(use '--show-trace' to show detailed location information)
$ nix build github:purebred-mua/purebred#purebred-with-packages
error: getting status of '/nix/store/rldh08aady2kz9md2li14da1kd04pd07-source': No such file or directory
(use '--show-trace' to show detailed location information)
$ nix build github:purebred-mua/purebred#purebred
error: getting status of '/nix/store/rldh08aady2kz9md2li14da1kd04pd07-source': No such file or directory
(use '--show-trace' to show detailed location information)

Expected behavior The build should succeed.

Additional context

I bisected this problem and it exists since ff75f5b24bac09b311ac547637f62f4f86ebc287. Even nix flake show --show-trace fails.

output

git+file:///home/luc/vcs/purebred?ref=ff75f5b24bac09b311ac547637f62f4f86ebc287&rev=ff75f5b24bac09b311ac547637f62f4f86ebc287
├───defaultPackage
error: getting status of '/nix/store/rldh08aady2kz9md2li14da1kd04pd07-source': No such file or directory

       … while realising the context of path '/nix/store/rldh08aady2kz9md2li14da1kd04pd07-source/flake.nix'

       at «string»:20:19:

           19|
           20|           flake = import (sourceInfo + (if subdir != "" then "/" else "") + subdir + "/flake.nix");
             |                   ^
           21|

       … while evaluating anonymous lambda

       at «string»:10:13:

            9|     builtins.mapAttrs
           10|       (key: node:
             |             ^
           11|         let

       … from call site

       … while evaluating anonymous lambda

       at «string»:23:25:

           22|           inputs = builtins.mapAttrs
           23|             (inputName: inputSpec: allNodes.${resolveInput inputSpec})
             |                         ^
           24|             (node.inputs or {});

       … from call site

       … while realising the context of a path

       at /nix/store/nk3y50ba6m5adzz5f2v9ryy5l7rmh9mf-source/flake.nix:19:12:

           18|   let
           19|     pkgs = import nixpkgs { inherit system; overlays = [ self.overlay ]; };
             |            ^
           20|   in rec {

       … while evaluating the attribute 'purebred-with-packages-icu'

       at /nix/store/nk3y50ba6m5adzz5f2v9ryy5l7rmh9mf-source/flake.nix:23:7:

           22|       purebred-with-packages = pkgs.purebred-with-packages;
           23|       purebred-with-packages-icu = pkgs.purebred-with-packages-icu;
             |       ^
           24|       purebred = pkgs.haskellPackages.purebred;

       … while evaluating the attribute 'defaultPackage'

       at /nix/store/nk3y50ba6m5adzz5f2v9ryy5l7rmh9mf-source/flake.nix:33:5:

           32|     };
           33|     defaultPackage = packages.purebred-with-packages-icu;
             |     ^
           34|     devShell = packages.shell-without-icu;

frasertweedale commented 1 year ago

@romanofski PTAL when able.

lucc commented 1 year ago

I think the problem is in .nix/nixpkgs.nix because it happens when I load this file alone in a repl:

$ nix repl --show-trace
Welcome to Nix 2.11.0. Type :? for help.

nix-repl> :l .nix/nixpkgs.nix
error: getting status of '/nix/store/rldh08aady2kz9md2li14da1kd04pd07-source': No such file or directory

       … while evaluating anonymous lambda

       at /home/luc/vcs/purebred/.nix/nixpkgs.nix:1:1:

            1| { compiler ? null, nixpkgs ? null}:
             | ^
            2|

       … from call site

nix-repl>

But I do not understand how this can affect a build via the nix flake because this file is only used in the default.nix file.

I just noticed that building with nix-build instead of nix build gives the same error:

$ nix-build --show-trace
error: getting status of '/nix/store/rldh08aady2kz9md2li14da1kd04pd07-source': No such file or directory

       … while evaluating anonymous lambda

       at /home/luc/vcs/purebred/.nix/nixpkgs.nix:1:1:

            1| { compiler ? null, nixpkgs ? null}:
             | ^
            2|

       … from call site

       at /home/luc/vcs/purebred/default.nix:36:2:

           35|
           36| (import .nix/nixpkgs.nix args).purebred-with-packages
             |  ^

       … while evaluating anonymous lambda

       at /home/luc/vcs/purebred/default.nix:34:1:

           33| #
           34| { compiler ? null, nixpkgs ? null, with-icu ? false }@args:
             | ^
           35|

       … from call site
romanofski commented 1 year ago

Going out on a limb here, but do you have perhaps local modifications on the nix files? I can't reproduce your error, neither the CI, e.g.: https://github.com/purebred-mua/purebred/actions/runs/3063872557/jobs/4946426394

I do have trouble with the overlay and shell configuration (e.g. https://github.com/purebred-mua/purebred/action/runs/3063872556/jobs/4946426412#step:6:30703) but that seems to be only specific to the shell (dev env).

Are you able to build other flake based projects (e.g. https://github.com/cdepillabout/termonad) ?

lucc commented 1 year ago

I can nix build github:cdepillabout/termonad just fine. I also can build purebred in a podman container and on another machine. My current hypothesis is that it either depends on the version of the nix daemon or something about my machine is broken in a very strange and local way that just the building of this flake fails.

For reference:

$ podman run -it --rm nixos/nix nix --version
nix (Nix) 2.5.1
$ podman run -it --rm nixos/nix nix build github:purebred-mua/purebred

works.

On nixos-22.05 with nix 2.8.1

$ nix --version
nix (Nix) 2.8.1
$ nix build github:purebred-mua/purebred
$ nix run nixpkgs#nixUnstable -- --version
nix (Nix) 2.11.0
$ nix run nixpkgs#nixUnstable -- build github:purebred-mua/purebred

works.

On nixos unstable with nix 2.11.0

$ nix --version
nix (Nix) 2.11.0
$ nix build github:purebred-mua/purebred
error: failed to open archive: Failed to open '/nix/store/d23x1rqviw440581axnrywgqyzxwz3gg-source'
(use '--show-trace' to show detailed location information)
$ nix run nixpkgs/nixos-22.05#nix -- --version
nix (Nix) 2.8.1
$ nix run nixpkgs/nixos-22.05#nix -- build github:purebred-mua/purebred
error: failed to open archive: Failed to open '/nix/store/d23x1rqviw440581axnrywgqyzxwz3gg-source'
(use '--show-trace' to show detailed location information)

both fail.

I conclude that this is some problem on my machine and we can close this issue.

lucc commented 1 year ago

I found the root cause: I had some "valid" paths in my database at /nix/var/nix/db/db.sqlite that did not exist on disk. I fixed it with nix store verify and can now build purebred again.