mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-11-22 06:32:21 +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 =
|
||||||
specialArgs
|
specialArgs
|
||||||
|
// {inherit packageSets;}
|
||||||
// {
|
// {
|
||||||
inherit packageSets;
|
|
||||||
dream2nix.modules.dream2nix = dream2nix.modules.dream2nix;
|
dream2nix.modules.dream2nix = dream2nix.modules.dream2nix;
|
||||||
dream2nix.overrides = dream2nix.overrides;
|
dream2nix.overrides = dream2nix.overrides;
|
||||||
dream2nix.lib.evalModules = evalModules;
|
dream2nix.lib.evalModules = evalModules;
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
lib,
|
lib,
|
||||||
dream2nix,
|
dream2nix,
|
||||||
config,
|
config,
|
||||||
packageSets,
|
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
cfg = config.haskell-cabal;
|
cfg = config.haskell-cabal;
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
lib,
|
lib,
|
||||||
dream2nix,
|
dream2nix,
|
||||||
config,
|
config,
|
||||||
packageSets,
|
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
l = lib // builtins;
|
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`.
|
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 {
|
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;}];
|
modules = [{freeformType = t.lazyAttrsOf t.raw;}];
|
||||||
specialArgs = packageSets;
|
specialArgs = packageSets;
|
||||||
};
|
};
|
||||||
@ -36,4 +34,11 @@ in {
|
|||||||
default = {};
|
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,
|
config,
|
||||||
lib,
|
lib,
|
||||||
packageSets,
|
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
l = lib // builtins;
|
l = lib // builtins;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
packageSets,
|
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
l = lib // builtins;
|
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,
|
config,
|
||||||
lib,
|
lib,
|
||||||
dream2nix,
|
dream2nix,
|
||||||
packageSets,
|
|
||||||
specialArgs,
|
specialArgs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
config,
|
config,
|
||||||
dream2nix,
|
dream2nix,
|
||||||
lib,
|
lib,
|
||||||
packageSets,
|
|
||||||
specialArgs,
|
specialArgs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
|
Loading…
Reference in New Issue
Block a user