mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-11-21 13:02:34 +03:00
add module arg pkgs
This change adds a `pkgs` arguments to the module args. Accessing packages from nixpkgs becomes easier as the user is not forced to go through `config.deps` anymore. `config.deps` can still be used to override packages from `pkgs`.
This commit is contained in:
parent
c7cb1c48c3
commit
94db134353
@ -67,8 +67,8 @@
|
||||
];
|
||||
specialArgs =
|
||||
specialArgs
|
||||
// {inherit packageSets;}
|
||||
// {
|
||||
inherit packageSets;
|
||||
dream2nix.modules.dream2nix = dream2nix.modules.dream2nix;
|
||||
dream2nix.overrides = dream2nix.overrides;
|
||||
dream2nix.lib.evalModules = evalModules;
|
||||
|
@ -2,7 +2,6 @@
|
||||
lib,
|
||||
dream2nix,
|
||||
config,
|
||||
packageSets,
|
||||
...
|
||||
}: let
|
||||
cfg = config.haskell-cabal;
|
||||
|
@ -2,7 +2,6 @@
|
||||
lib,
|
||||
dream2nix,
|
||||
config,
|
||||
packageSets,
|
||||
...
|
||||
}: let
|
||||
l = lib // builtins;
|
||||
|
@ -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
|
||||
);
|
||||
}
|
||||
|
1
modules/dream2nix/core/env/default.nix
vendored
1
modules/dream2nix/core/env/default.nix
vendored
@ -1,7 +1,6 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
packageSets,
|
||||
...
|
||||
}: let
|
||||
l = lib // builtins;
|
||||
|
@ -1,7 +1,6 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
packageSets,
|
||||
...
|
||||
}: let
|
||||
l = lib // builtins;
|
||||
|
32
modules/dream2nix/core/tests/packages/nixpkgs/default.nix
Normal file
32
modules/dream2nix/core/tests/packages/nixpkgs/default.nix
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
dream2nix,
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
dream2nix.modules.dream2nix.mkDerivation-mixin
|
||||
dream2nix.modules.dream2nix.core
|
||||
];
|
||||
deps = {nixpkgs, ...}: {
|
||||
foo = nixpkgs.hello.overrideAttrs (old: {
|
||||
pname = "foo";
|
||||
phases = ["buildPhase"];
|
||||
buildPhase = "echo -n hello > $out";
|
||||
});
|
||||
};
|
||||
name = "test";
|
||||
version = "0.0.0";
|
||||
phases = ["buildPhase"];
|
||||
buildPhase = ''
|
||||
# explicit package
|
||||
echo ${pkgs.foo} >> $out
|
||||
# implicit package
|
||||
echo ${pkgs.hello} >> $out
|
||||
|
||||
if [ "${pkgs.foo}" != "${config.deps.foo}" ]; then
|
||||
echo "foo mismatch: ${pkgs.foo} != ${config.deps.foo}" >&2
|
||||
exit 1
|
||||
fi
|
||||
'';
|
||||
}
|
@ -2,7 +2,6 @@
|
||||
config,
|
||||
lib,
|
||||
dream2nix,
|
||||
packageSets,
|
||||
specialArgs,
|
||||
...
|
||||
}: let
|
||||
|
@ -2,7 +2,6 @@
|
||||
config,
|
||||
dream2nix,
|
||||
lib,
|
||||
packageSets,
|
||||
specialArgs,
|
||||
...
|
||||
}: let
|
||||
|
Loading…
Reference in New Issue
Block a user