From 8a1b2d9861edeb2696ce2a1872ea46592c816ed7 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 5 Apr 2026 11:31:17 +0200 Subject: [PATCH] nix develop: Respect legacyPackages --- src/libcmd/builtin-flake-schemas.nix | 1 + tests/functional/flakes/develop.sh | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/libcmd/builtin-flake-schemas.nix b/src/libcmd/builtin-flake-schemas.nix index 0ee6d8f5ae39..39f09d92fa29 100644 --- a/src/libcmd/builtin-flake-schemas.nix +++ b/src/libcmd/builtin-flake-schemas.nix @@ -137,6 +137,7 @@ roles.nix-build = { }; roles.nix-run = { }; roles.nix-search = { }; + roles.nix-develop = { }; appendSystem = true; inventory = output: diff --git a/tests/functional/flakes/develop.sh b/tests/functional/flakes/develop.sh index 0248adf49eaf..f37682be947f 100755 --- a/tests/functional/flakes/develop.sh +++ b/tests/functional/flakes/develop.sh @@ -192,3 +192,20 @@ sed -i "$TEST_HOME/flake.nix" -e 's/devShells/devShells2/' # remove devShells [[ $(nix develop . -L --command sh -c "echo \$x") == "bar" ]] sed -i "$TEST_HOME/flake.nix" -e 's/devShell/devShell2/' # remove devShell [[ $(nix develop . -L --command sh -c "echo \$x") == "xyzzy" ]] + +# Check that legacyPackages is used, but only when specifying an explicit package. +cat <"$TEST_HOME/flake.nix" +{ + inputs.nixpkgs.url = "$TEST_HOME/nixpkgs"; + outputs = {self, nixpkgs}: { + legacyPackages.$system.default = (import ./config.nix).mkDerivation { + name = "hello"; + buildCommand = "set -x; mkdir \$out"; + x = "foo"; + }; + }; +} +EOF + +(! nix develop . -L --command sh -c "echo \$x") +[[ $(nix develop .#default -L --command sh -c "echo \$x") == "foo" ]]