diff --git a/modules/dream2nix/builtins-derivation/default.nix b/modules/dream2nix/builtins-derivation/default.nix index e0a7730f..e695cf67 100644 --- a/modules/dream2nix/builtins-derivation/default.nix +++ b/modules/dream2nix/builtins-derivation/default.nix @@ -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; + }; } diff --git a/modules/dream2nix/builtins-derivation/implementation.nix b/modules/dream2nix/builtins-derivation/implementation.nix deleted file mode 100644 index 633acc1b..00000000 --- a/modules/dream2nix/builtins-derivation/implementation.nix +++ /dev/null @@ -1,49 +0,0 @@ -{ - 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 = [ - ../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; - }; -} diff --git a/modules/dream2nix/mkDerivation/default.nix b/modules/dream2nix/mkDerivation/default.nix index e0a7730f..1ad09bce 100644 --- a/modules/dream2nix/mkDerivation/default.nix +++ b/modules/dream2nix/mkDerivation/default.nix @@ -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; + }; } diff --git a/modules/dream2nix/mkDerivation/implementation.nix b/modules/dream2nix/mkDerivation/implementation.nix deleted file mode 100644 index dae74a2c..00000000 --- a/modules/dream2nix/mkDerivation/implementation.nix +++ /dev/null @@ -1,67 +0,0 @@ -{ - 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 = [ - ../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; - }; -}