-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mkDerivation/builtins-derivation: refactor: implementation.nix -> def…
…ault.nix
- Loading branch information
Showing
4 changed files
with
108 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,50 @@ | ||
{ | ||
config, | ||
lib, | ||
... | ||
}: let | ||
l = lib // builtins; | ||
t = l.types; | ||
|
||
cfg = config.builtins-derivation; | ||
|
||
outputs = l.unique cfg.outputs; | ||
|
||
keepArg = key: val: val != null; | ||
|
||
finalArgs = l.filterAttrs keepArg cfg; | ||
|
||
# ensure that none of the env variables collide with the top-level options | ||
envChecked = | ||
l.mapAttrs | ||
(key: val: | ||
if config.builtins-derivation.${key} or false | ||
then throw (envCollisionError key) | ||
else val) | ||
config.env; | ||
|
||
# generates error message for env variable collision | ||
envCollisionError = key: '' | ||
Error while evaluating definitions for derivation ${config.name} | ||
The environment variable defined via `env.${key}' collides with the option builtins-derivation.`${key}'. | ||
Specify the top-level option instead, or rename the environment variable. | ||
''; | ||
in { | ||
imports = [ | ||
./implementation.nix | ||
./interface.nix | ||
../core | ||
../package-func | ||
]; | ||
|
||
config.package-func.outputs = cfg.outputs; | ||
|
||
config.package-func.func = lib.mkDefault builtins.derivation; | ||
|
||
config.package-func.args = | ||
envChecked | ||
// finalArgs | ||
// { | ||
inherit outputs; | ||
inherit (config.public) name; | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,68 @@ | ||
{ | ||
config, | ||
lib, | ||
... | ||
}: let | ||
l = lib // builtins; | ||
t = l.types; | ||
|
||
cfg = config.mkDerivation; | ||
|
||
outputs = l.unique cfg.outputs; | ||
|
||
keepArg = key: val: val != null; | ||
|
||
finalArgs = l.filterAttrs keepArg cfg; | ||
|
||
# ensure that none of the env variables collide with the top-level options | ||
envChecked = | ||
l.mapAttrs | ||
(key: val: | ||
if config.mkDerivation ? ${key} | ||
then throw (envCollisionError key) | ||
else val) | ||
config.env; | ||
|
||
# generates error message for env variable collision | ||
envCollisionError = key: '' | ||
Error while evaluating definitions for derivation ${config.name} | ||
The environment variable defined via `env.${key}' collides with the option mkDerivation.`${key}'. | ||
Specify the top-level option instead, or rename the environment variable. | ||
''; | ||
|
||
public = | ||
# meta | ||
(l.optionalAttrs (cfg.passthru ? meta) { | ||
inherit (cfg.passthru) meta; | ||
}) | ||
# tests | ||
// (l.optionalAttrs (cfg.passthru ? tests) { | ||
inherit (cfg.passthru) tests; | ||
}); | ||
in { | ||
imports = [ | ||
./implementation.nix | ||
./interface.nix | ||
../core | ||
../package-func | ||
]; | ||
|
||
config.package-func.outputs = cfg.outputs; | ||
|
||
config.package-func.func = lib.mkDefault config.deps.stdenv.mkDerivation; | ||
|
||
# add mkDerivation specific derivation attributes | ||
config.public = public; | ||
|
||
config.package-func.args = | ||
envChecked | ||
// finalArgs | ||
// { | ||
inherit outputs; | ||
inherit (config.public) version; | ||
pname = config.name; | ||
}; | ||
|
||
config.deps = {nixpkgs, ...}: { | ||
stdenv = lib.mkOverride 1050 nixpkgs.stdenv; | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.