From 037c86ee04d681170cedaf71f9d75c186abe9719 Mon Sep 17 00:00:00 2001 From: regnat Date: Tue, 13 Jul 2021 11:44:19 +0200 Subject: [PATCH 1/3] nix develop: Search in `devShells.${system}` by default Make `nix develop .#foo` search `.#devShells.${system}.foo` first --- src/nix/develop.cc | 6 ++++++ src/nix/develop.md | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/nix/develop.cc b/src/nix/develop.cc index 26f53db09..9ac2791f8 100644 --- a/src/nix/develop.cc +++ b/src/nix/develop.cc @@ -326,6 +326,12 @@ struct Common : InstallableCommand, MixProfile { return {"devShell." + settings.thisSystem.get(), "defaultPackage." + settings.thisSystem.get()}; } + Strings getDefaultFlakeAttrPathPrefixes() override + { + auto res = SourceExprCommand::getDefaultFlakeAttrPathPrefixes(); + res.emplace_front("devShells." + settings.thisSystem.get()); + return res; + } StorePath getShellOutPath(ref store) { diff --git a/src/nix/develop.md b/src/nix/develop.md index e71d9f8aa..c86c4872b 100644 --- a/src/nix/develop.md +++ b/src/nix/develop.md @@ -84,11 +84,20 @@ the flake's `nixConfig` attribute. # Flake output attributes -If no flake output attribute is given, `nix run` tries the following +If no flake output attribute is given, `nix develop` tries the following flake output attributes: * `devShell.` * `defaultPackage.` +If a flake output *name* is given, `nix develop` tries the following flake +output attributes: + +* `devShells..` + +* `packages..` + +* `legacyPackages..` + )"" From 43d5c5f87b0f1cc9405709a777d66496b4ca4e21 Mon Sep 17 00:00:00 2001 From: regnat Date: Tue, 13 Jul 2021 13:44:47 +0200 Subject: [PATCH 2/3] Make `nix flake show` display the `devShells` --- src/nix/flake.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/nix/flake.cc b/src/nix/flake.cc index 9055b07eb..ce82eb8e8 100644 --- a/src/nix/flake.cc +++ b/src/nix/flake.cc @@ -914,6 +914,7 @@ struct CmdFlakeShow : FlakeCommand logger->cout("%s: %s '%s'", headerPrefix, attrPath.size() == 2 && attrPath[0] == "devShell" ? "development environment" : + attrPath.size() >= 2 && attrPath[0] == "devShells" ? "development environment" : attrPath.size() == 3 && attrPath[0] == "checks" ? "derivation" : attrPath.size() >= 1 && attrPath[0] == "hydraJobs" ? "derivation" : "package", @@ -932,6 +933,7 @@ struct CmdFlakeShow : FlakeCommand || ((attrPath.size() == 1 || attrPath.size() == 2) && (attrPath[0] == "checks" || attrPath[0] == "packages" + || attrPath[0] == "devShells" || attrPath[0] == "apps")) ) { @@ -940,7 +942,7 @@ struct CmdFlakeShow : FlakeCommand else if ( (attrPath.size() == 2 && (attrPath[0] == "defaultPackage" || attrPath[0] == "devShell")) - || (attrPath.size() == 3 && (attrPath[0] == "checks" || attrPath[0] == "packages")) + || (attrPath.size() == 3 && (attrPath[0] == "checks" || attrPath[0] == "packages" || attrPath[0] == "devShells")) ) { if (visitor.isDerivation()) From 797e260e3a322937bd31f94d166beafc283f6ed7 Mon Sep 17 00:00:00 2001 From: regnat Date: Tue, 13 Jul 2021 17:23:29 +0200 Subject: [PATCH 3/3] Make `nix flake check` aware of `devShells` --- src/nix/flake-check.md | 1 + src/nix/flake.cc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/nix/flake-check.md b/src/nix/flake-check.md index 8ef932954..d995d6274 100644 --- a/src/nix/flake-check.md +++ b/src/nix/flake-check.md @@ -33,6 +33,7 @@ The following flake output attributes must be derivations: * `checks.`*system*`.`*name* * `defaultPackage.`*system*` * `devShell.`*system*` +* `devShells.`*system*`.`*name*` * `nixosConfigurations.`*name*`.config.system.build.toplevel * `packages.`*system*`.`*name* diff --git a/src/nix/flake.cc b/src/nix/flake.cc index ce82eb8e8..23feed24b 100644 --- a/src/nix/flake.cc +++ b/src/nix/flake.cc @@ -486,7 +486,7 @@ struct CmdFlakeCheck : FlakeCommand } } - else if (name == "packages") { + else if (name == "packages" || name == "devShells") { state->forceAttrs(vOutput, pos); for (auto & attr : *vOutput.attrs) { checkSystemName(attr.name, *attr.pos);