Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nix-shell -p is broken when using nixpkgs.lib.nixosSystem #318300

Open
arianvp opened this issue Jun 8, 2024 · 5 comments
Open

nix-shell -p is broken when using nixpkgs.lib.nixosSystem #318300

arianvp opened this issue Jun 8, 2024 · 5 comments
Labels
0.kind: bug Something is broken

Comments

@arianvp
Copy link
Member

arianvp commented Jun 8, 2024

Describe the bug

It seems nix-shell -p stopped working in 24.05 for me.

Steps To Reproduce

  1. Build a nixos VM using nixpkgs.lib.nixosSystem
  2. Run nix-shell -p aws
  3. Run nix-shell -p aws --show-trace and the stack trace becomes shorter
[ssm-user@ip-172-31-1-45:/var/log]$ nix-shell -p aws
error:
       … <borked>

         at «none»:0: (source not available)

       … while calling the 'import' builtin

         at «string»:1:18:

            1| {...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [ (aws) ]; } ""
             |                  ^

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

       error: experimental Nix feature 'flakes' is disabled; use '--extra-experimental-features flakes' to override

[ssm-user@ip-172-31-1-45:/var/log]$ nix-shell -p aws --show-trace
error:
       … while calling anonymous lambda

         at «string»:1:1:

            1| {...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [ (aws) ]; } ""
             | ^

       error: experimental Nix feature 'flakes' is disabled; use '--extra-experimental-features flakes' to override

Expected behavior

nix-shell -p

works

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

Notify maintainers

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
output here

Add a 👍 reaction to issues you find important.

@arianvp arianvp added the 0.kind: bug Something is broken label Jun 8, 2024
@arianvp arianvp changed the title nix-shell -p is broken on 24.05. Complains that I don't have flakes enabled <<borked>> at <<none>>:0: (source not available) nix-shell -p is broken on 24.05 AWS. Complains that I don't have flakes enabled <<borked>> at <<none>>:0: (source not available) Jun 8, 2024
@arianvp
Copy link
Member Author

arianvp commented Jun 8, 2024

Weirdly enough I can not reproduce this in a local VM? It only seems broken in the AMI? did we break something with make-disk-image.nix ?

@arianvp arianvp changed the title nix-shell -p is broken on 24.05 AWS. Complains that I don't have flakes enabled <<borked>> at <<none>>:0: (source not available) nix-shell -p is broken on 24.05 AWS. Complains that I don't have flakes enabled <borked> at <<none>>:0: (source not available) Jun 8, 2024
@arianvp
Copy link
Member Author

arianvp commented Jun 8, 2024

Debugging further. Somehow this slipped in:

$ echo $NIX_PATH
nixpkgs=flake:nixpkgs:/nix/var/nix/profiles/per-user/root/channels

@arianvp arianvp changed the title nix-shell -p is broken on 24.05 AWS. Complains that I don't have flakes enabled <borked> at <<none>>:0: (source not available) nix-shell -p is broken when using nixpkgs.lib.nixosSystem Jun 8, 2024
@arianvp
Copy link
Member Author

arianvp commented Jun 8, 2024

This happened after I pushed a flake-built NixOS Config to my machine and it turns out we set this new NIX_PATH since #254405 landed. But that PR does not enable flakes. So you get this very obscure error message.

@Qyriad
Copy link
Member

Qyriad commented Jun 9, 2024

That PR is only supposed to apply when using a flake-based NixOS configuration, and nixpkgs.lib.nixosSystem is only defined in Nixpkgs' flake in the first place, so I am a little confused on how this could even come up.

@arianvp
Copy link
Member Author

arianvp commented Jun 9, 2024

Because nixpkgs.lib.nixosSystem is just using flakes on the host system. But that doesn't mean the target system it builds has flakes enabled. (And by default it doesn't).

The PR unconditionally sets the setting whether flakes is enabled or not. I think we should make it conditional instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

No branches or pull requests

2 participants