cachix / devenv

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

Template issues for `nix flake show` #1337

Open anntnzrb opened 2 months ago

anntnzrb commented 2 months ago

Describe the bug There is an issue with the simple and flake-parts templates in the repository. When running the nix flake show command, it results in an error related to the update (//) operator.

To reproduce Steps to reproduce:

  1. Clone the Devenv repository from https://github.com/cachix/devenv.
    • Or simply nix flake new -t <...>
  2. Navigate to either the simple or flake-parts template directory.
  3. Run the nix flake show command.

Error Message:

error:
       … in the left operand of the update (//) operator
         at /nix/store/yyx6cfswkz9n0lf8wdj3zpy42xrznv7f-source/flake.nix:166:24:
          165|           in
          166|           config.shell // {
             |                        ^
          167|             ci = config.ciDerivation;

       … while evaluating the attribute 'value'
         at /nix/store/mnfbbcdbbwh3iif9m9xp8jnsgys65f2g-source/lib/modules.nix:809:9:
          808|     in warnDeprecation opt //
          809|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          810|         inherit (res.defsFinal') highestPrio;

       … while evaluating the option `shell':

       … while evaluating definitions from `/nix/store/yyx6cfswkz9n0lf8wdj3zpy42xrznv7f-source/src/modules/top-level.nix':

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

       error: Failed assertions:
       - devenv was not able to determine the current directory.

         See https://devenv.sh/guides/using-with-flakes/ how to use it with flakes.

Version

Tested on WSL, NixOS, and Nix-Darwin environments.

MaxDaten commented 2 months ago

Hi had the same problem, just today. But this worked for me:

nix flake show . --impure # mark the dot

I think this is a quirk which requires to use . with --impure.

I'm using the flake-parts template

Doosty commented 2 months ago

Just needs --impure.

anntnzrb commented 2 months ago

Hi had the same problem, just today. But this worked for me:

nix flake show . --impure # mark the dot

I think this is a quirk which requires to use . with --impure.

I'm using the flake-parts template

Just needs --impure.

This should theoretically solve this issue, however, what about #1018 ?

brianmay commented 3 weeks ago

My vague understanding with #1018 is that you have to modify your flake to add a new input.