diff --git a/lib/default.nix b/lib/default.nix index 01c86fd350..d44d57a0f3 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -67,8 +67,8 @@ ]; specialArgs = specialArgs + // {inherit packageSets;} // { - inherit packageSets; dream2nix.modules.dream2nix = dream2nix.modules.dream2nix; dream2nix.overrides = dream2nix.overrides; dream2nix.lib.evalModules = evalModules; diff --git a/modules/dream2nix/WIP-haskell-cabal/default.nix b/modules/dream2nix/WIP-haskell-cabal/default.nix index 8f20666ebd..cdedec2f91 100644 --- a/modules/dream2nix/WIP-haskell-cabal/default.nix +++ b/modules/dream2nix/WIP-haskell-cabal/default.nix @@ -2,7 +2,6 @@ lib, dream2nix, config, - packageSets, ... }: let cfg = config.haskell-cabal; diff --git a/modules/dream2nix/WIP-spago/default.nix b/modules/dream2nix/WIP-spago/default.nix index a828fefc95..fa8229d5f2 100644 --- a/modules/dream2nix/WIP-spago/default.nix +++ b/modules/dream2nix/WIP-spago/default.nix @@ -2,7 +2,6 @@ lib, dream2nix, config, - packageSets, ... }: let l = lib // builtins; diff --git a/modules/dream2nix/core/deps/default.nix b/modules/dream2nix/core/deps/default.nix index 1e92b58152..91ca9bc7cc 100644 --- a/modules/dream2nix/core/deps/default.nix +++ b/modules/dream2nix/core/deps/default.nix @@ -22,8 +22,6 @@ in { So deps should be specific, but not overly specific. For instance, the caller shouldn't have to know the version of a dependency in order to override it. The name should suffice. (e.g. `nix = nixVersions.nix_2_12` instead of `inherit (nixVersions) nix_2_12`. ''; type = t.submoduleWith { - # TODO: This could be made stricter by removing the freeformType - # Maybe add option `strictDeps = true/false` ? ;P modules = [{freeformType = t.lazyAttrsOf t.raw;}]; specialArgs = packageSets; }; @@ -36,4 +34,11 @@ in { default = {}; }; }; + config._module.args.pkgs = + config.deps + // lib.optionalAttrs (packageSets ? nixpkgs) ( + builtins.mapAttrs + (name: pkg: config.deps.${name} or pkg) + packageSets.nixpkgs + ); } diff --git a/modules/dream2nix/core/env/default.nix b/modules/dream2nix/core/env/default.nix index 814c7257fe..8252e81c73 100644 --- a/modules/dream2nix/core/env/default.nix +++ b/modules/dream2nix/core/env/default.nix @@ -1,7 +1,6 @@ { config, lib, - packageSets, ... }: let l = lib // builtins; diff --git a/modules/dream2nix/core/public/interface.nix b/modules/dream2nix/core/public/interface.nix index 2ded6bbc04..6d24cfd78e 100644 --- a/modules/dream2nix/core/public/interface.nix +++ b/modules/dream2nix/core/public/interface.nix @@ -1,7 +1,6 @@ { config, lib, - packageSets, ... }: let l = lib // builtins; diff --git a/modules/dream2nix/nodejs-granular-v3/interface.nix b/modules/dream2nix/nodejs-granular-v3/interface.nix index 2a558d1804..4a6f0d2f75 100644 --- a/modules/dream2nix/nodejs-granular-v3/interface.nix +++ b/modules/dream2nix/nodejs-granular-v3/interface.nix @@ -2,7 +2,6 @@ config, lib, dream2nix, - packageSets, specialArgs, ... }: let diff --git a/modules/dream2nix/php-granular/interface.nix b/modules/dream2nix/php-granular/interface.nix index 8f5dd3ad52..be0f9f6664 100644 --- a/modules/dream2nix/php-granular/interface.nix +++ b/modules/dream2nix/php-granular/interface.nix @@ -2,7 +2,6 @@ config, dream2nix, lib, - packageSets, specialArgs, ... }: let diff --git a/tests/nix-unit/nixpkgs/default.nix b/tests/nix-unit/nixpkgs/default.nix new file mode 100644 index 0000000000..b29226bc42 --- /dev/null +++ b/tests/nix-unit/nixpkgs/default.nix @@ -0,0 +1,50 @@ +{ + pkgs ? import {}, + lib ? import , + inputs ? {}, + dream2nix ? import ../../.. inputs, +}: let + eval = module: + (lib.evalModules { + modules = [ + dream2nix.modules.dream2nix.WIP-groups + module + ]; + specialArgs = { + inherit dream2nix; + packageSets.nixpkgs = pkgs; + }; + }) + .config; +in { + test_old = let + config = eval ( + {pkgs, ...}: { + imports = [ + dream2nix.modules.dream2nix.mkDerivation-mixin + dream2nix.modules.dream2nix.deps + ]; + deps = {nixpkgs, ...}: { + foo = nixpkgs.hello.overrideAttrs (old: { + pname = "foo"; + }); + }; + name = "test"; + version = "0.0.0"; + phases = ["buildPhase"]; + buildPhase = '' + # explicit package + echo ${pkgs.foo} >> $out + # implicit package + echo ${pkgs.hello} >> $out + ''; + } + ); + in { + expr = builtins.readFile config.public; + expected = '' + ${config.deps.foo} + ${pkgs.hello} + ''; + }; +}