cachix / devenv

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

Avoid --impure in flake-parts based projects #1018

Closed Atry closed 4 weeks ago

Atry commented 1 month ago

Let .envrc generate the devenv.root

domenkozar commented 1 month ago

We should probably make it a JSON to pass other things like devenv.tmpdir?

Atry commented 1 month ago

We should probably make it a JSON to pass other things like devenv.tmpdir?

I think one value per input approach would be nice, otherwise we will have to deal with JSON escape things in .envrc

Atry commented 1 month ago

@domenkozar Would you like to approve the CI workflows?

khaled commented 1 month ago

Without these changes I get:

error:
       … while evaluating the attribute 'optionalValue.value'

         at /nix/store/lwyjz70qh12nq6cb7fixl85vryzxqm3c-source/lib/modules.nix:856:5:

          855|
          856|     optionalValue =
             |     ^
          857|       if isDefined then { value = mergedValue; }

       … while evaluating a branch condition

         at /nix/store/lwyjz70qh12nq6cb7fixl85vryzxqm3c-source/lib/modules.nix:857:7:

          856|     optionalValue =
          857|       if isDefined then { value = mergedValue; }
             |       ^
          858|       else {};

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

       error: unable to download 'file://file:/dev/fd/63': URL using bad/illegal format or missing URL (3)

With the changes I get a further, but apparently there is still a problem:

$direnv allow
...
Hello, world!
ln: failed to create symbolic link '/Users/khaled/path/to/project'$'\n''/.devenv/run': No such file or directory

Oddly, the /path/to/project printed in the error message isn't the current path as output by pwd, but a different directory in which I previously tried the same experiment...

Atry commented 1 month ago

@khaled Fixed

khaled commented 1 month ago

Thanks @Atry!

FYI, this probably belongs in a separate bug, but the existence of the packages.devenv-up package definition seems to actually break devenv up:

       error: attribute 'config' missing

       at /nix/store/86gyzipyn7zzp4nrnanz0sl5r6cps63v-source/flake.nix:48:30:

           47|         packages.default = pkgs.hello;
           48|         packages.devenv-up = self'.devShells.default.config.procfileScript;
             |                              ^
           49|         devenv.shells.default = let

Simply removing the package definition resolves it.

Atry commented 1 month ago

@domenkozar I don't understand the CI failure message. Could you help me understanding why?

Atry commented 1 month ago

@domenkozar I rebased this PR. Would you mind approving the CI workflows?

Atry commented 1 month ago

@domenkozar I think the CI failure is not due to this PR. The main branch is broken.

lopter commented 1 month ago

I am wondering if it would make sense to also update the flake integration wrapper to not use --impure anymore and maybe re-export other nix commands from there (e.g. the flake nix command).

Atry commented 1 month ago

@domenkozar could you trigger CI for this PR?