cachix / devenv

Fast, Declarative, Reproducible, and Composable Developer Environments
https://devenv.sh
Apache License 2.0
4.46k stars 335 forks source link

Installing external Flakes partly broken since 1.1/ devenv-2.24 #1456

Open Zaunei opened 1 month ago

Zaunei commented 1 month ago

Describe the bug

After upgrading devenv from version v1.0.8 to v1.1.0, devenv stopped working with my devenv.nix with the following error:

evaluating derivation 'git+file:///Users/Zaunei/repos/devenv-flake-import#devShells.aarch64-darwin.default'Assertion failed: (false), function operator(), file src/libexpr/primops.cc, line 76.

Since the error message was not informative for me, I started to remove parts of the config to find the cause.

It happens with some packages that are referenced by inputs, but not with all of them. I noticed it with flakes in private Git repos, but I found the sshuttle Flake with the same behavior, so I can offer a test repo to reproduce it. The sshuttle Flake is also very similar to mine. Installing colmena using the flake in devenv still works with 1.1.0.

Both flakes build without Devenv without any problems.

I am still quite new to Nix, maybe I am doing something wrong, but so far it has worked well and colmena is still working therefore I am opening a bug report.

To reproduce

Repository for reproduction: https://github.com/Zaunei/devenv-flake-import

Running devenv shell with devenv 1.0.x: works Running devenv shell with devenv 1.1.0 leads to the following error:

❯ devenv shell
• Building shell ...
• Using Cachix: devenv
evaluating derivation 'git+file:///Users/Zaunei/repos/devenv-flake-import#devShells.aarch64-darwin.default'Assertion failed: (false), function operator(), file src/libexpr/primops.cc, line 76.

✖ Command produced the following output:

✔ Building shell in 6.6s.
Error:   × Command `/nix/store/7n0ymzncvaj1rv98k7r0mr4rgagpqq1i-nix-2.24-devenv/bin/nix --show-trace --extra-experimental-features nix-command --extra-experimental-features flakes --option
  │ warn-dirty false --keep-going --max-jobs 5 --option eval-cache false print-dev-env --profile /Users/Zaunei/repos/devenv-flake-import/.devenv/gc/shell --option
  │ extra-substituters https://devenv.cachix.org --option extra-trusted-public-keys devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw= nixpkgs-python.cachix.org-
  │ 1:hxjI7pFxTyuTHn2NkvWCrAUcNZLNS3ZAvfYNuYifcEU=` failed with without exit code

After removing sshuttle.sshuttle, devenv shell also works with devenv 1.1.0 again.

Version

devenv 1.1.0 (aarch64-darwin) installed with nix-darwin, but I was also able to reproduce it with a nix profiles installation. Also tested with NixOS 24.05, x86_64-linux.

Zaunei commented 1 month ago

I have just checked whether there is a general problem with Nix 2.24 with this Flake. But without devenv the build works for me with both, 2.18.5 and 2.24.6.

Zaunei commented 1 month ago

I am currently trying to narrow down with overlays starting from which change the error occurs. With an overlay that only overrides parts of buildRustPackage, I could produce the same error with devenv 1.0.8, installed from the latest nixpkgs-unstable(28b5b8af91ffd2623e995e20aee56510db49001a).

So I suspect the error comes from the Nix 2.24 version installed from the devenv nixpkgs. Update 27.9: That doesn't seem to be the problem.

Overlay:

(self: super: {
  devenv-debug = super.devenv.override {
    rustPlatform = super.rustPlatform // {
      buildRustPackage =
        args:
        super.rustPlatform.buildRustPackage (
          args
          // {
            version = "debug";
            src = super.fetchFromGitHub {
              owner = "cachix";
              repo = "devenv";
              rev = "8c115a9222133af25fa08330982c4ceae9e24563";
              #hash= "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
              hash = "sha256-q/ERT4Ui315opFz4h4+BsJ/zrTYdXkwq13vvrpL+KzM=";
            };
            cargoHash = "sha256-D05hjH9Io1h7Yn8CQabHbiXXLXj2Bf5nksJMKublmPU=";
          }
        );
    };
  };
})
Zaunei commented 1 month ago

Yes, its the switch from nix devenv-2.21 to devenv-2.24, that breaks my setup. Devenv 1.0.8, 1.1 and 1.2 all work fine, then pinning devenv_nix to devenv-2.21.

Without Devenv, but with upstream Nix 2.24.6, building the sshuttle Falkes works. Therefore I assume that it is not a general Nix 2.24 problem 🤔

Update: devenv 1.2 with dev-env-2.21 nix has the same behaviour, then build from the latest nixpkgs-unstable (28b5b8af91ffd2623e995e20aee56510db49001a). Therefore I assume that the used Nix version is not the problem here?

bobvanderlinden commented 1 month ago

I think I run into the same issue, but with other errors. I have a really hard time to figure out what is going wrong, as with a normal flake.nix it works fine.

devenv.yaml:

inputs:
  ...
  autopatchelf:
    url: github:bobvanderlinden/autopatchelf

devenv.nix:

  packages = [ inputs.autopatchelf.packages.x86_64-linux.default ];

The error:

       error: evaluation aborted with the following error message: 'Function called without required argument "fetchPypiLegacy" at «github:nix-community/poetry2nix/ef877b8e159b23f36ebc39155021657bed744a68»/mk-poetry-dep.nix:9'

It seems devenv overrides inputs/nixpkgs in some places?

Zaunei commented 1 month ago

With devenv 1.3 the error message is now less verbose:

❯ devenv shell
• Building shell ...
• Using Cachix: devenv
✔ Building shell in 3.8s.
Error:   × Failed to run command `/nix/store/m16x8dlzwhp7sx570h82h3x5332ldbfs-nix-2.24-devenv/bin/nix --show-trace --extra-experimental-features nix-command --extra-experimental-features flakes --option warn-dirty false --keep-going --max-jobs 5 --option eval-cache false --option extra-substituters https://devenv.cachix.org --option extra-trusted-public-keys devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=
  │ nixpkgs-python.cachix.org-1:hxjI7pFxTyuTHn2NkvWCrAUcNZLNS3ZAvfYNuYifcEU= print-dev-env --profile /Users/Zaunei/repos/devenv-flake-import/.devenv/gc/shell -vv --log-format internal-json`
  ╰─▶ Nix command failed: signal: 6 (SIGABRT)
domenkozar commented 1 month ago

The reason why this is failing is because lazy-trees branch is incomplete now, give me ~week to come up with a plan how we will properly address this.

bobvanderlinden commented 1 month ago

Aah I wasn't aware that was used. That certainly explains the behaviour 👍