mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 14:06:16 +02:00
Merge pull request #6089 from edolstra/dot-default
Replace defaultBla.$system with bla.$system.default
This commit is contained in:
commit
59683733f5
19 changed files with 114 additions and 67 deletions
|
@ -1,5 +1,18 @@
|
||||||
# Release X.Y (202?-??-??)
|
# Release X.Y (202?-??-??)
|
||||||
|
|
||||||
|
* A number of "default" flake output attributes have been
|
||||||
|
renamed. These are:
|
||||||
|
|
||||||
|
* `defaultPackage.<system>` → `packages.<system>.default`
|
||||||
|
* `defaultApps.<system>` → `apps.<system>.default`
|
||||||
|
* `defaultTemplate` → `templates.default`
|
||||||
|
* `defaultBundler.<system>` → `bundlers.<system>.default`
|
||||||
|
* `overlay` → `overlays.default`
|
||||||
|
* `devShell.<system>` → `devShells.<system>.default`
|
||||||
|
|
||||||
|
The old flake output attributes still work, but `nix flake check`
|
||||||
|
will warn about them.
|
||||||
|
|
||||||
* `nix bundle` breaking API change now supports bundlers of the form
|
* `nix bundle` breaking API change now supports bundlers of the form
|
||||||
`bundler.<system>.<name>= derivation: another-derivation;`. This supports
|
`bundler.<system>.<name>= derivation: another-derivation;`. This supports
|
||||||
additional functionality to inspect evaluation information during bundling. A
|
additional functionality to inspect evaluation information during bundling. A
|
||||||
|
|
|
@ -158,7 +158,10 @@ SourceExprCommand::SourceExprCommand()
|
||||||
|
|
||||||
Strings SourceExprCommand::getDefaultFlakeAttrPaths()
|
Strings SourceExprCommand::getDefaultFlakeAttrPaths()
|
||||||
{
|
{
|
||||||
return {"defaultPackage." + settings.thisSystem.get()};
|
return {
|
||||||
|
"packages." + settings.thisSystem.get() + ".default",
|
||||||
|
"defaultPackage." + settings.thisSystem.get()
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Strings SourceExprCommand::getDefaultFlakeAttrPathPrefixes()
|
Strings SourceExprCommand::getDefaultFlakeAttrPathPrefixes()
|
||||||
|
|
|
@ -49,9 +49,11 @@ struct CmdBundle : InstallableCommand
|
||||||
|
|
||||||
Category category() override { return catSecondary; }
|
Category category() override { return catSecondary; }
|
||||||
|
|
||||||
|
// FIXME: cut&paste from CmdRun.
|
||||||
Strings getDefaultFlakeAttrPaths() override
|
Strings getDefaultFlakeAttrPaths() override
|
||||||
{
|
{
|
||||||
Strings res{
|
Strings res{
|
||||||
|
"apps." + settings.thisSystem.get() + ".default",
|
||||||
"defaultApp." + settings.thisSystem.get()
|
"defaultApp." + settings.thisSystem.get()
|
||||||
};
|
};
|
||||||
for (auto & s : SourceExprCommand::getDefaultFlakeAttrPaths())
|
for (auto & s : SourceExprCommand::getDefaultFlakeAttrPaths())
|
||||||
|
@ -61,10 +63,7 @@ struct CmdBundle : InstallableCommand
|
||||||
|
|
||||||
Strings getDefaultFlakeAttrPathPrefixes() override
|
Strings getDefaultFlakeAttrPathPrefixes() override
|
||||||
{
|
{
|
||||||
Strings res{
|
Strings res{"apps." + settings.thisSystem.get() + "."};
|
||||||
"apps." + settings.thisSystem.get() + "."
|
|
||||||
|
|
||||||
};
|
|
||||||
for (auto & s : SourceExprCommand::getDefaultFlakeAttrPathPrefixes())
|
for (auto & s : SourceExprCommand::getDefaultFlakeAttrPathPrefixes())
|
||||||
res.push_back(s);
|
res.push_back(s);
|
||||||
return res;
|
return res;
|
||||||
|
@ -80,7 +79,9 @@ struct CmdBundle : InstallableCommand
|
||||||
const flake::LockFlags lockFlags{ .writeLockFile = false };
|
const flake::LockFlags lockFlags{ .writeLockFile = false };
|
||||||
InstallableFlake bundler{this,
|
InstallableFlake bundler{this,
|
||||||
evalState, std::move(bundlerFlakeRef), bundlerName,
|
evalState, std::move(bundlerFlakeRef), bundlerName,
|
||||||
{"defaultBundler." + settings.thisSystem.get()},
|
{"bundlers." + settings.thisSystem.get() + ".default",
|
||||||
|
"defaultBundler." + settings.thisSystem.get()
|
||||||
|
},
|
||||||
{"bundlers." + settings.thisSystem.get() + "."},
|
{"bundlers." + settings.thisSystem.get() + "."},
|
||||||
lockFlags
|
lockFlags
|
||||||
};
|
};
|
||||||
|
|
|
@ -42,24 +42,26 @@ homepage](https://github.com/NixOS/bundlers) for more details.
|
||||||
If no flake output attribute is given, `nix bundle` tries the following
|
If no flake output attribute is given, `nix bundle` tries the following
|
||||||
flake output attributes:
|
flake output attributes:
|
||||||
|
|
||||||
* `defaultBundler.<system>`
|
* `bundlers.<system>.default`
|
||||||
|
|
||||||
If an attribute *name* is given, `nix run` tries the following flake
|
If an attribute *name* is given, `nix run` tries the following flake
|
||||||
output attributes:
|
output attributes:
|
||||||
|
|
||||||
* `bundler.<system>.<name>`
|
* `bundlers.<system>.<name>`
|
||||||
|
|
||||||
# Bundlers
|
# Bundlers
|
||||||
|
|
||||||
A bundler is specified by a flake output attribute named
|
A bundler is specified by a flake output attribute named
|
||||||
`bundlers.<system>.<name>` or `defaultBundler.<system>`. It looks like this:
|
`bundlers.<system>.<name>`. It looks like this:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
bundlers.x86_64-linux.identity = drv: drv;
|
bundlers.x86_64-linux = rec {
|
||||||
|
identity = drv: drv;
|
||||||
|
|
||||||
bundlers.x86_64-linux.blender_2_79 = drv: self.packages.x86_64-linux.blender_2_79;
|
blender_2_79 = drv: self.packages.x86_64-linux.blender_2_79;
|
||||||
|
|
||||||
defaultBundler.x86_64-linux = drv: drv;
|
default = identity;
|
||||||
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
A bundler must be a function that accepts an arbitrary value (typically a
|
A bundler must be a function that accepts an arbitrary value (typically a
|
||||||
|
|
|
@ -325,8 +325,15 @@ struct Common : InstallableCommand, MixProfile
|
||||||
|
|
||||||
Strings getDefaultFlakeAttrPaths() override
|
Strings getDefaultFlakeAttrPaths() override
|
||||||
{
|
{
|
||||||
return {"devShell." + settings.thisSystem.get(), "defaultPackage." + settings.thisSystem.get()};
|
Strings paths{
|
||||||
|
"devShells." + settings.thisSystem.get() + ".default",
|
||||||
|
"devShell." + settings.thisSystem.get(),
|
||||||
|
};
|
||||||
|
for (auto & p : SourceExprCommand::getDefaultFlakeAttrPaths())
|
||||||
|
paths.push_back(p);
|
||||||
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
Strings getDefaultFlakeAttrPathPrefixes() override
|
Strings getDefaultFlakeAttrPathPrefixes() override
|
||||||
{
|
{
|
||||||
auto res = SourceExprCommand::getDefaultFlakeAttrPathPrefixes();
|
auto res = SourceExprCommand::getDefaultFlakeAttrPathPrefixes();
|
||||||
|
|
|
@ -88,9 +88,9 @@ the flake's `nixConfig` attribute.
|
||||||
If no flake output attribute is given, `nix develop` tries the following
|
If no flake output attribute is given, `nix develop` tries the following
|
||||||
flake output attributes:
|
flake output attributes:
|
||||||
|
|
||||||
* `devShell.<system>`
|
* `devShells.<system>.default`
|
||||||
|
|
||||||
* `defaultPackage.<system>`
|
* `packages.<system>.default`
|
||||||
|
|
||||||
If a flake output *name* is given, `nix develop` tries the following flake
|
If a flake output *name* is given, `nix develop` tries the following flake
|
||||||
output attributes:
|
output attributes:
|
||||||
|
|
|
@ -24,13 +24,13 @@ R""(
|
||||||
|
|
||||||
This command creates a flake in the current directory by copying the
|
This command creates a flake in the current directory by copying the
|
||||||
files of a template. It will not overwrite existing files. The default
|
files of a template. It will not overwrite existing files. The default
|
||||||
template is `templates#defaultTemplate`, but this can be overridden
|
template is `templates#templates.default`, but this can be overridden
|
||||||
using `-t`.
|
using `-t`.
|
||||||
|
|
||||||
# Template definitions
|
# Template definitions
|
||||||
|
|
||||||
A flake can declare templates through its `templates` and
|
A flake can declare templates through its `templates` output
|
||||||
`defaultTemplate` output attributes. A template has two attributes:
|
attribute. A template has two attributes:
|
||||||
|
|
||||||
* `description`: A one-line description of the template, in CommonMark
|
* `description`: A one-line description of the template, in CommonMark
|
||||||
syntax.
|
syntax.
|
||||||
|
@ -61,7 +61,7 @@ outputs = { self }: {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
templates.defaultTemplate = self.templates.rust;
|
templates.default = self.templates.rust;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -13,10 +13,13 @@ R""(
|
||||||
│ │ └───build: derivation 'patchelf-0.12.20201207.f34751b'
|
│ │ └───build: derivation 'patchelf-0.12.20201207.f34751b'
|
||||||
│ └───x86_64-linux
|
│ └───x86_64-linux
|
||||||
│ └───build: derivation 'patchelf-0.12.20201207.f34751b'
|
│ └───build: derivation 'patchelf-0.12.20201207.f34751b'
|
||||||
├───defaultPackage
|
├───packages
|
||||||
│ ├───aarch64-linux: package 'patchelf-0.12.20201207.f34751b'
|
│ ├───aarch64-linux
|
||||||
│ ├───i686-linux: package 'patchelf-0.12.20201207.f34751b'
|
│ │ └───default: package 'patchelf-0.12.20201207.f34751b'
|
||||||
│ └───x86_64-linux: package 'patchelf-0.12.20201207.f34751b'
|
│ ├───i686-linux
|
||||||
|
│ │ └───default: package 'patchelf-0.12.20201207.f34751b'
|
||||||
|
│ └───x86_64-linux
|
||||||
|
│ └───default: package 'patchelf-0.12.20201207.f34751b'
|
||||||
├───hydraJobs
|
├───hydraJobs
|
||||||
│ ├───build
|
│ ├───build
|
||||||
│ │ ├───aarch64-linux: derivation 'patchelf-0.12.20201207.f34751b'
|
│ │ ├───aarch64-linux: derivation 'patchelf-0.12.20201207.f34751b'
|
||||||
|
|
|
@ -501,6 +501,17 @@ struct CmdFlakeCheck : FlakeCommand
|
||||||
|
|
||||||
state->forceValue(vOutput, pos);
|
state->forceValue(vOutput, pos);
|
||||||
|
|
||||||
|
std::string_view replacement =
|
||||||
|
name == "defaultPackage" ? "packages.<system>.default" :
|
||||||
|
name == "defaultApps" ? "apps.<system>.default" :
|
||||||
|
name == "defaultTemplate" ? "templates.default" :
|
||||||
|
name == "defaultBundler" ? "bundlers.<system>.default" :
|
||||||
|
name == "overlay" ? "overlays.default" :
|
||||||
|
name == "devShell" ? "devShells.<system>.default" :
|
||||||
|
"";
|
||||||
|
if (replacement != "")
|
||||||
|
warn("flake output attribute '%s' is deprecated; use '%s' instead", name, replacement);
|
||||||
|
|
||||||
if (name == "checks") {
|
if (name == "checks") {
|
||||||
state->forceAttrs(vOutput, pos);
|
state->forceAttrs(vOutput, pos);
|
||||||
for (auto & attr : *vOutput.attrs) {
|
for (auto & attr : *vOutput.attrs) {
|
||||||
|
@ -651,7 +662,7 @@ struct CmdFlakeCheck : FlakeCommand
|
||||||
};
|
};
|
||||||
|
|
||||||
static Strings defaultTemplateAttrPathsPrefixes{"templates."};
|
static Strings defaultTemplateAttrPathsPrefixes{"templates."};
|
||||||
static Strings defaultTemplateAttrPaths = {"defaultTemplate"};
|
static Strings defaultTemplateAttrPaths = {"templates.default", "defaultTemplate"};
|
||||||
|
|
||||||
struct CmdFlakeInitCommon : virtual Args, EvalCommand
|
struct CmdFlakeInitCommon : virtual Args, EvalCommand
|
||||||
{
|
{
|
||||||
|
|
|
@ -268,7 +268,7 @@ derivation):
|
||||||
|
|
||||||
outputs = { self, nixpkgs }: {
|
outputs = { self, nixpkgs }: {
|
||||||
|
|
||||||
defaultPackage.x86_64-linux =
|
packages.x86_64-linux.default =
|
||||||
# Notice the reference to nixpkgs here.
|
# Notice the reference to nixpkgs here.
|
||||||
with import nixpkgs { system = "x86_64-linux"; };
|
with import nixpkgs { system = "x86_64-linux"; };
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
|
|
|
@ -97,11 +97,9 @@ the Nix store. Here are the recognised types of installables:
|
||||||
For example, if `/foo/bar/flake.nix` exists, then `/foo/bar/baz/` will resolve to
|
For example, if `/foo/bar/flake.nix` exists, then `/foo/bar/baz/` will resolve to
|
||||||
`path:/foo/bar`
|
`path:/foo/bar`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
If *attrpath* is omitted, Nix tries some default values; for most
|
If *attrpath* is omitted, Nix tries some default values; for most
|
||||||
subcommands, the default is `defaultPackage.`*system*
|
subcommands, the default is `packages.`*system*`.default`
|
||||||
(e.g. `defaultPackage.x86_64-linux`), but some subcommands have
|
(e.g. `packages.x86_64-linux.default`), but some subcommands have
|
||||||
other defaults. If *attrpath* *is* specified, *attrpath* is
|
other defaults. If *attrpath* *is* specified, *attrpath* is
|
||||||
interpreted as relative to one or more prefixes; for most
|
interpreted as relative to one or more prefixes; for most
|
||||||
subcommands, these are `packages.`*system*,
|
subcommands, these are `packages.`*system*,
|
||||||
|
|
|
@ -8,7 +8,7 @@ R""(
|
||||||
# nix profile list
|
# nix profile list
|
||||||
0 flake:nixpkgs#legacyPackages.x86_64-linux.spotify github:NixOS/nixpkgs/c23db78bbd474c4d0c5c3c551877523b4a50db06#legacyPackages.x86_64-linux.spotify /nix/store/akpdsid105phbbvknjsdh7hl4v3fhjkr-spotify-1.1.46.916.g416cacf1
|
0 flake:nixpkgs#legacyPackages.x86_64-linux.spotify github:NixOS/nixpkgs/c23db78bbd474c4d0c5c3c551877523b4a50db06#legacyPackages.x86_64-linux.spotify /nix/store/akpdsid105phbbvknjsdh7hl4v3fhjkr-spotify-1.1.46.916.g416cacf1
|
||||||
1 flake:nixpkgs#legacyPackages.x86_64-linux.zoom-us github:NixOS/nixpkgs/c23db78bbd474c4d0c5c3c551877523b4a50db06#legacyPackages.x86_64-linux.zoom-us /nix/store/89pmjmbih5qpi7accgacd17ybpgp4xfm-zoom-us-5.4.53350.1027
|
1 flake:nixpkgs#legacyPackages.x86_64-linux.zoom-us github:NixOS/nixpkgs/c23db78bbd474c4d0c5c3c551877523b4a50db06#legacyPackages.x86_64-linux.zoom-us /nix/store/89pmjmbih5qpi7accgacd17ybpgp4xfm-zoom-us-5.4.53350.1027
|
||||||
2 flake:blender-bin#defaultPackage.x86_64-linux github:edolstra/nix-warez/d09d7eea893dcb162e89bc67f6dc1ced14abfc27?dir=blender#defaultPackage.x86_64-linux /nix/store/zfgralhqjnam662kqsgq6isjw8lhrflz-blender-bin-2.91.0
|
2 flake:blender-bin#packages.x86_64-linux.default github:edolstra/nix-warez/d09d7eea893dcb162e89bc67f6dc1ced14abfc27?dir=blender#packages.x86_64-linux.default /nix/store/zfgralhqjnam662kqsgq6isjw8lhrflz-blender-bin-2.91.0
|
||||||
```
|
```
|
||||||
|
|
||||||
# Description
|
# Description
|
||||||
|
|
|
@ -96,7 +96,7 @@ has the following fields:
|
||||||
user specified, but the one resulting from applying the default
|
user specified, but the one resulting from applying the default
|
||||||
attribute paths and prefixes; for instance, `hello` might resolve to
|
attribute paths and prefixes; for instance, `hello` might resolve to
|
||||||
`packages.x86_64-linux.hello` and the empty string to
|
`packages.x86_64-linux.hello` and the empty string to
|
||||||
`defaultPackage.x86_64-linux`.
|
`packages.x86_64-linux.default`.
|
||||||
|
|
||||||
* `storePath`: The paths in the Nix store containing the package.
|
* `storePath`: The paths in the Nix store containing the package.
|
||||||
|
|
||||||
|
|
|
@ -158,7 +158,10 @@ struct CmdRun : InstallableCommand
|
||||||
|
|
||||||
Strings getDefaultFlakeAttrPaths() override
|
Strings getDefaultFlakeAttrPaths() override
|
||||||
{
|
{
|
||||||
Strings res{"defaultApp." + settings.thisSystem.get()};
|
Strings res{
|
||||||
|
"apps." + settings.thisSystem.get() + ".default",
|
||||||
|
"defaultApp." + settings.thisSystem.get(),
|
||||||
|
};
|
||||||
for (auto & s : SourceExprCommand::getDefaultFlakeAttrPaths())
|
for (auto & s : SourceExprCommand::getDefaultFlakeAttrPaths())
|
||||||
res.push_back(s);
|
res.push_back(s);
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -58,9 +58,9 @@ For instance, if `name` is set to `hello-1.10`, `nix run` will run
|
||||||
If no flake output attribute is given, `nix run` tries the following
|
If no flake output attribute is given, `nix run` tries the following
|
||||||
flake output attributes:
|
flake output attributes:
|
||||||
|
|
||||||
* `defaultApp.<system>`
|
* `apps.<system>.default`
|
||||||
|
|
||||||
* `defaultPackage.<system>`
|
* `packages.<system>.default`
|
||||||
|
|
||||||
If an attribute *name* is given, `nix run` tries the following flake
|
If an attribute *name* is given, `nix run` tries the following flake
|
||||||
output attributes:
|
output attributes:
|
||||||
|
@ -74,7 +74,7 @@ output attributes:
|
||||||
# Apps
|
# Apps
|
||||||
|
|
||||||
An app is specified by a flake output attribute named
|
An app is specified by a flake output attribute named
|
||||||
`apps.<system>.<name>` or `defaultApp.<system>`. It looks like this:
|
`apps.<system>.<name>`. It looks like this:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
apps.x86_64-linux.blender_2_79 = {
|
apps.x86_64-linux.blender_2_79 = {
|
||||||
|
|
|
@ -10,13 +10,15 @@ cd $TEST_HOME
|
||||||
cat <<EOF > flake.nix
|
cat <<EOF > flake.nix
|
||||||
{
|
{
|
||||||
outputs = {self}: {
|
outputs = {self}: {
|
||||||
bundlers.$system.simple = drv:
|
bundlers.$system = rec {
|
||||||
|
simple = drv:
|
||||||
if drv?type && drv.type == "derivation"
|
if drv?type && drv.type == "derivation"
|
||||||
then drv
|
then drv
|
||||||
else self.defaultPackage.$system;
|
else self.packages.$system.default;
|
||||||
defaultBundler.$system = self.bundlers.$system.simple;
|
default = simple;
|
||||||
defaultPackage.$system = import ./simple.nix;
|
};
|
||||||
defaultApp.$system = {
|
packages.$system.default = import ./simple.nix;
|
||||||
|
apps.$system.default = {
|
||||||
type = "app";
|
type = "app";
|
||||||
program = "\${import ./simple.nix}/hello";
|
program = "\${import ./simple.nix}/hello";
|
||||||
};
|
};
|
||||||
|
@ -25,11 +27,11 @@ cat <<EOF > flake.nix
|
||||||
EOF
|
EOF
|
||||||
nix build .#
|
nix build .#
|
||||||
nix bundle --bundler .# .#
|
nix bundle --bundler .# .#
|
||||||
nix bundle --bundler .#defaultBundler.$system .#defaultPackage.$system
|
nix bundle --bundler .#bundlers.$system.default .#packages.$system.default
|
||||||
nix bundle --bundler .#bundlers.$system.simple .#defaultPackage.$system
|
nix bundle --bundler .#bundlers.$system.simple .#packages.$system.default
|
||||||
|
|
||||||
nix bundle --bundler .#defaultBundler.$system .#defaultApp.$system
|
nix bundle --bundler .#bundlers.$system.default .#apps.$system.default
|
||||||
nix bundle --bundler .#bundlers.$system.simple .#defaultApp.$system
|
nix bundle --bundler .#bundlers.$system.simple .#apps.$system.default
|
||||||
|
|
||||||
clearStore
|
clearStore
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ cat <<EOF > flake.nix
|
||||||
nixConfig.allow-dirty = false; # See #5621
|
nixConfig.allow-dirty = false; # See #5621
|
||||||
|
|
||||||
outputs = a: {
|
outputs = a: {
|
||||||
defaultPackage.$system = import ./simple.nix;
|
packages.$system.default = import ./simple.nix;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
|
@ -15,8 +15,10 @@ cat <<EOF > flake.nix
|
||||||
{
|
{
|
||||||
inputs.foo.url = "$PWD/foo";
|
inputs.foo.url = "$PWD/foo";
|
||||||
outputs = a: {
|
outputs = a: {
|
||||||
defaultPackage.$system = import ./simple.nix;
|
packages.$system = rec {
|
||||||
packages.$system.test = import ./simple.nix;
|
test = import ./simple.nix;
|
||||||
|
default = test;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
|
@ -41,8 +41,10 @@ cat > $flake1Dir/flake.nix <<EOF
|
||||||
description = "Bla bla";
|
description = "Bla bla";
|
||||||
|
|
||||||
outputs = inputs: rec {
|
outputs = inputs: rec {
|
||||||
packages.$system.foo = import ./simple.nix;
|
packages.$system = rec {
|
||||||
defaultPackage.$system = packages.$system.foo;
|
foo = import ./simple.nix;
|
||||||
|
default = foo;
|
||||||
|
};
|
||||||
|
|
||||||
# To test "nix flake init".
|
# To test "nix flake init".
|
||||||
legacyPackages.x86_64-linux.hello = import ./simple.nix;
|
legacyPackages.x86_64-linux.hello = import ./simple.nix;
|
||||||
|
@ -128,7 +130,7 @@ hash2=$(nix flake metadata flake1 --json --refresh | jq -r .revision)
|
||||||
nix build -o $TEST_ROOT/result flake1#foo
|
nix build -o $TEST_ROOT/result flake1#foo
|
||||||
[[ -e $TEST_ROOT/result/hello ]]
|
[[ -e $TEST_ROOT/result/hello ]]
|
||||||
|
|
||||||
# Test defaultPackage.
|
# Test packages.default.
|
||||||
nix build -o $TEST_ROOT/result flake1
|
nix build -o $TEST_ROOT/result flake1
|
||||||
[[ -e $TEST_ROOT/result/hello ]]
|
[[ -e $TEST_ROOT/result/hello ]]
|
||||||
|
|
||||||
|
@ -140,11 +142,11 @@ nix build -o $flake1Dir/result git+file://$flake1Dir
|
||||||
nix path-info $flake1Dir/result
|
nix path-info $flake1Dir/result
|
||||||
|
|
||||||
# 'getFlake' on a mutable flakeref should fail in pure mode, but succeed in impure mode.
|
# 'getFlake' on a mutable flakeref should fail in pure mode, but succeed in impure mode.
|
||||||
(! nix build -o $TEST_ROOT/result --expr "(builtins.getFlake \"$flake1Dir\").defaultPackage.$system")
|
(! nix build -o $TEST_ROOT/result --expr "(builtins.getFlake \"$flake1Dir\").packages.$system.default")
|
||||||
nix build -o $TEST_ROOT/result --expr "(builtins.getFlake \"$flake1Dir\").defaultPackage.$system" --impure
|
nix build -o $TEST_ROOT/result --expr "(builtins.getFlake \"$flake1Dir\").packages.$system.default" --impure
|
||||||
|
|
||||||
# 'getFlake' on an immutable flakeref should succeed even in pure mode.
|
# 'getFlake' on an immutable flakeref should succeed even in pure mode.
|
||||||
nix build -o $TEST_ROOT/result --expr "(builtins.getFlake \"git+file://$flake1Dir?rev=$hash2\").defaultPackage.$system"
|
nix build -o $TEST_ROOT/result --expr "(builtins.getFlake \"git+file://$flake1Dir?rev=$hash2\").packages.$system.default"
|
||||||
|
|
||||||
# Building a flake with an unlocked dependency should fail in pure mode.
|
# Building a flake with an unlocked dependency should fail in pure mode.
|
||||||
(! nix build -o $TEST_ROOT/result flake2#bar --no-registries)
|
(! nix build -o $TEST_ROOT/result flake2#bar --no-registries)
|
||||||
|
@ -370,13 +372,13 @@ cat > $templatesDir/flake.nix <<EOF
|
||||||
description = "Some templates";
|
description = "Some templates";
|
||||||
|
|
||||||
outputs = { self }: {
|
outputs = { self }: {
|
||||||
templates = {
|
templates = rec {
|
||||||
trivial = {
|
trivial = {
|
||||||
path = ./trivial;
|
path = ./trivial;
|
||||||
description = "A trivial flake";
|
description = "A trivial flake";
|
||||||
};
|
};
|
||||||
|
default = trivial;
|
||||||
};
|
};
|
||||||
defaultTemplate = self.templates.trivial;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
@ -388,8 +390,10 @@ cat > $templatesDir/trivial/flake.nix <<EOF
|
||||||
description = "A flake for building Hello World";
|
description = "A flake for building Hello World";
|
||||||
|
|
||||||
outputs = { self, nixpkgs }: {
|
outputs = { self, nixpkgs }: {
|
||||||
packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello;
|
packages.x86_64-linux = rec {
|
||||||
defaultPackage.x86_64-linux = self.packages.x86_64-linux.hello;
|
hello = nixpkgs.legacyPackages.x86_64-linux.hello;
|
||||||
|
default = hello;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
@ -496,17 +500,15 @@ EOF
|
||||||
cat > $flake3Dir/flake.nix <<EOF
|
cat > $flake3Dir/flake.nix <<EOF
|
||||||
{
|
{
|
||||||
outputs = { flake1, self }: {
|
outputs = { flake1, self }: {
|
||||||
defaultPackage = {
|
packages.system-1.default = "foo";
|
||||||
system-1 = "foo";
|
packages.system-2.default = "bar";
|
||||||
system-2 = "bar";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
checkRes=$(nix flake check --keep-going $flake3Dir 2>&1 && fail "nix flake check should have failed" || true)
|
checkRes=$(nix flake check --keep-going $flake3Dir 2>&1 && fail "nix flake check should have failed" || true)
|
||||||
echo "$checkRes" | grep -q "defaultPackage.system-1"
|
echo "$checkRes" | grep -q "packages.system-1.default"
|
||||||
echo "$checkRes" | grep -q "defaultPackage.system-2"
|
echo "$checkRes" | grep -q "packages.system-2.default"
|
||||||
|
|
||||||
# Test 'follows' inputs.
|
# Test 'follows' inputs.
|
||||||
cat > $flake3Dir/flake.nix <<EOF
|
cat > $flake3Dir/flake.nix <<EOF
|
||||||
|
@ -591,7 +593,7 @@ mkdir $flake5Dir
|
||||||
cat > $flake5Dir/flake.nix <<EOF
|
cat > $flake5Dir/flake.nix <<EOF
|
||||||
{
|
{
|
||||||
outputs = { self, flake1 }: {
|
outputs = { self, flake1 }: {
|
||||||
defaultPackage.$system = flake1.defaultPackage.$system;
|
packages.$system.default = flake1.packages.$system.default;
|
||||||
expr = assert builtins.pathExists ./flake.lock; 123;
|
expr = assert builtins.pathExists ./flake.lock; 123;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue