Merge pull request #5008 from NixOS/flake-devShells-attribute

Add a `devShells` attribute to the flake schema
This commit is contained in:
Eelco Dolstra 2021-07-13 23:27:55 +02:00 committed by GitHub
commit bee71d692a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 3 deletions

View file

@ -326,6 +326,12 @@ struct Common : InstallableCommand, MixProfile
{ {
return {"devShell." + settings.thisSystem.get(), "defaultPackage." + settings.thisSystem.get()}; 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> store) StorePath getShellOutPath(ref<Store> store)
{ {

View file

@ -84,11 +84,20 @@ the flake's `nixConfig` attribute.
# Flake output attributes # 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: flake output attributes:
* `devShell.<system>` * `devShell.<system>`
* `defaultPackage.<system>` * `defaultPackage.<system>`
If a flake output *name* is given, `nix develop` tries the following flake
output attributes:
* `devShells.<system>.<name>`
* `packages.<system>.<name>`
* `legacyPackages.<system>.<name>`
)"" )""

View file

@ -33,6 +33,7 @@ The following flake output attributes must be derivations:
* `checks.`*system*`.`*name* * `checks.`*system*`.`*name*
* `defaultPackage.`*system*` * `defaultPackage.`*system*`
* `devShell.`*system*` * `devShell.`*system*`
* `devShells.`*system*`.`*name*`
* `nixosConfigurations.`*name*`.config.system.build.toplevel * `nixosConfigurations.`*name*`.config.system.build.toplevel
* `packages.`*system*`.`*name* * `packages.`*system*`.`*name*

View file

@ -486,7 +486,7 @@ struct CmdFlakeCheck : FlakeCommand
} }
} }
else if (name == "packages") { else if (name == "packages" || name == "devShells") {
state->forceAttrs(vOutput, pos); state->forceAttrs(vOutput, pos);
for (auto & attr : *vOutput.attrs) { for (auto & attr : *vOutput.attrs) {
checkSystemName(attr.name, *attr.pos); checkSystemName(attr.name, *attr.pos);
@ -914,6 +914,7 @@ struct CmdFlakeShow : FlakeCommand
logger->cout("%s: %s '%s'", logger->cout("%s: %s '%s'",
headerPrefix, headerPrefix,
attrPath.size() == 2 && attrPath[0] == "devShell" ? "development environment" : 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() == 3 && attrPath[0] == "checks" ? "derivation" :
attrPath.size() >= 1 && attrPath[0] == "hydraJobs" ? "derivation" : attrPath.size() >= 1 && attrPath[0] == "hydraJobs" ? "derivation" :
"package", "package",
@ -932,6 +933,7 @@ struct CmdFlakeShow : FlakeCommand
|| ((attrPath.size() == 1 || attrPath.size() == 2) || ((attrPath.size() == 1 || attrPath.size() == 2)
&& (attrPath[0] == "checks" && (attrPath[0] == "checks"
|| attrPath[0] == "packages" || attrPath[0] == "packages"
|| attrPath[0] == "devShells"
|| attrPath[0] == "apps")) || attrPath[0] == "apps"))
) )
{ {
@ -940,7 +942,7 @@ struct CmdFlakeShow : FlakeCommand
else if ( else if (
(attrPath.size() == 2 && (attrPath[0] == "defaultPackage" || attrPath[0] == "devShell")) (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()) if (visitor.isDerivation())