mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-09-11 14:35:30 +03:00
mkDerivation: stop depending on all core modules
mkDerivation should be minimal, but currently it always pulls in modules like `lock` and `paths` etc. despite those not being needed for many instances, like when mkDerivation is imported by a dependency. Modules like pip which do need some of these core modules, now need to directly depend on them. This will remove a bunch of unneeded options which currently pollute the manual. The remaining core dependencies of mkDerivation are now: deps, env, ui
This commit is contained in:
parent
c4e13905aa
commit
f017de2de4
@ -32,9 +32,12 @@ in {
|
|||||||
default = {};
|
default = {};
|
||||||
};
|
};
|
||||||
overrides = lib.mkOption {
|
overrides = lib.mkOption {
|
||||||
|
# TODO: This version of deferredModuleWith might lead to an infinite
|
||||||
|
# recursion because it doesn't support specialArgs
|
||||||
|
# (see custom deferredModuleWith in ../overrides/default.nix)
|
||||||
type = t.lazyAttrsOf (t.deferredModuleWith {
|
type = t.lazyAttrsOf (t.deferredModuleWith {
|
||||||
staticModules = [
|
staticModules = [
|
||||||
{_module.args = specialArgs;}
|
{_module.args = specialArgs // {inherit specialArgs;};}
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
description = ''
|
description = ''
|
||||||
|
@ -289,6 +289,7 @@ in {
|
|||||||
|
|
||||||
imports = [
|
imports = [
|
||||||
./interface.nix
|
./interface.nix
|
||||||
|
dream2nix.modules.dream2nix.core
|
||||||
dream2nix.modules.dream2nix.mkDerivation
|
dream2nix.modules.dream2nix.mkDerivation
|
||||||
dream2nix.modules.dream2nix.WIP-groups
|
dream2nix.modules.dream2nix.WIP-groups
|
||||||
];
|
];
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
else config.deps.python.pkgs.setuptools;
|
else config.deps.python.pkgs.setuptools;
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
dream2nix.modules.dream2nix.mkDerivation
|
dream2nix.modules.dream2nix.buildPythonPackage
|
||||||
];
|
];
|
||||||
config.mkDerivation.buildInputs =
|
config.mkDerivation.buildInputs =
|
||||||
lib.optionals
|
lib.optionals
|
||||||
@ -56,8 +56,6 @@
|
|||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
dream2nix.modules.dream2nix.buildPythonPackage
|
|
||||||
../core/deps
|
|
||||||
../overrides
|
../overrides
|
||||||
./interface.nix
|
./interface.nix
|
||||||
./lock.nix
|
./lock.nix
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
|
dream2nix,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
pdmConfig = config.deps.writeText "pdm-config.toml" ''
|
pdmConfig = config.deps.writeText "pdm-config.toml" ''
|
||||||
@ -32,6 +33,9 @@
|
|||||||
popd
|
popd
|
||||||
'';
|
'';
|
||||||
in {
|
in {
|
||||||
|
imports = [
|
||||||
|
dream2nix.modules.dream2nix.lock
|
||||||
|
];
|
||||||
lock.extraScripts = [script];
|
lock.extraScripts = [script];
|
||||||
deps = {nixpkgs, ...}:
|
deps = {nixpkgs, ...}:
|
||||||
lib.mapAttrs (_: lib.mkDefault) {
|
lib.mapAttrs (_: lib.mkDefault) {
|
||||||
|
@ -8,7 +8,8 @@
|
|||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
./interface.nix
|
./interface.nix
|
||||||
../mkDerivation
|
dream2nix.modules.dream2nix.mkDerivation
|
||||||
|
dream2nix.modules.dream2nix.deps
|
||||||
];
|
];
|
||||||
config = {
|
config = {
|
||||||
package-func.func = config.deps.python.pkgs.buildPythonPackage;
|
package-func.func = config.deps.python.pkgs.buildPythonPackage;
|
||||||
|
@ -146,6 +146,7 @@
|
|||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
dream2nix.modules.dream2nix.mkDerivation
|
dream2nix.modules.dream2nix.mkDerivation
|
||||||
|
dream2nix.modules.dream2nix.core
|
||||||
./interface.nix
|
./interface.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
|
dream2nix,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
l = lib // builtins;
|
l = lib // builtins;
|
||||||
t = l.types;
|
|
||||||
|
|
||||||
cfg = config.mkDerivation;
|
cfg = config.mkDerivation;
|
||||||
|
|
||||||
@ -42,8 +42,10 @@
|
|||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
./interface.nix
|
./interface.nix
|
||||||
../core
|
|
||||||
../package-func
|
../package-func
|
||||||
|
dream2nix.modules.dream2nix.deps
|
||||||
|
dream2nix.modules.dream2nix.env
|
||||||
|
dream2nix.modules.dream2nix.ui
|
||||||
];
|
];
|
||||||
|
|
||||||
config.package-func.outputs = cfg.outputs;
|
config.package-func.outputs = cfg.outputs;
|
||||||
|
@ -291,6 +291,7 @@ in {
|
|||||||
imports = [
|
imports = [
|
||||||
./interface.nix
|
./interface.nix
|
||||||
dream2nix.modules.dream2nix.mkDerivation
|
dream2nix.modules.dream2nix.mkDerivation
|
||||||
|
dream2nix.modules.dream2nix.core
|
||||||
(commonModule defaultPackageName defaultPackageVersion)
|
(commonModule defaultPackageName defaultPackageVersion)
|
||||||
];
|
];
|
||||||
deps = {nixpkgs, ...}:
|
deps = {nixpkgs, ...}:
|
||||||
|
@ -18,6 +18,7 @@ in {
|
|||||||
config.overrideType = {
|
config.overrideType = {
|
||||||
imports = [
|
imports = [
|
||||||
dream2nix.modules.dream2nix.mkDerivation
|
dream2nix.modules.dream2nix.mkDerivation
|
||||||
|
dream2nix.modules.dream2nix.core
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
options = l.mapAttrs (_: l.mkOption) {
|
options = l.mapAttrs (_: l.mkOption) {
|
||||||
@ -49,10 +50,11 @@ in {
|
|||||||
internal = true;
|
internal = true;
|
||||||
# hack because internal doesn't propagate to submodule options
|
# hack because internal doesn't propagate to submodule options
|
||||||
visible = "shallow";
|
visible = "shallow";
|
||||||
type = t.attrsOf (t.attrsOf (t.submodule {
|
type = t.attrsOf (t.attrsOf (t.submoduleWith {
|
||||||
imports = [
|
modules = [
|
||||||
cfg.overrideType
|
cfg.overrideType
|
||||||
];
|
];
|
||||||
|
inherit specialArgs;
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -281,6 +281,7 @@ in {
|
|||||||
imports = [
|
imports = [
|
||||||
./interface.nix
|
./interface.nix
|
||||||
dream2nix.modules.dream2nix.mkDerivation
|
dream2nix.modules.dream2nix.mkDerivation
|
||||||
|
dream2nix.modules.dream2nix.core
|
||||||
(commonModule defaultPackageName defaultPackageVersion)
|
(commonModule defaultPackageName defaultPackageVersion)
|
||||||
];
|
];
|
||||||
deps = {nixpkgs, ...}:
|
deps = {nixpkgs, ...}:
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
dream2nix,
|
dream2nix,
|
||||||
packageSets,
|
specialArgs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
l = lib // builtins;
|
l = lib // builtins;
|
||||||
@ -34,12 +34,12 @@ in {
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
deps = {
|
deps = {
|
||||||
type = t.lazyAttrsOf (t.lazyAttrsOf (t.submodule {
|
type = t.lazyAttrsOf (t.lazyAttrsOf (t.submoduleWith {
|
||||||
imports = [
|
modules = [
|
||||||
dream2nix.modules.dream2nix.core
|
dream2nix.modules.dream2nix.core
|
||||||
dream2nix.modules.dream2nix.mkDerivation
|
dream2nix.modules.dream2nix.mkDerivation
|
||||||
];
|
];
|
||||||
_module.args = {inherit dream2nix packageSets;};
|
inherit specialArgs;
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
./interface.nix
|
./interface.nix
|
||||||
|
dream2nix.modules.dream2nix.core
|
||||||
dream2nix.modules.dream2nix.mkDerivation
|
dream2nix.modules.dream2nix.mkDerivation
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -5,14 +5,36 @@
|
|||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
t = lib.types;
|
t = lib.types;
|
||||||
staticModules = [
|
|
||||||
{_module.args = specialArgs;}
|
# Monkey patch deferredModuleWith to accept specialArgs
|
||||||
config.overrideType
|
# TODO: upstream specialArgs to deferredModuleWith in nixpkgs
|
||||||
];
|
deferredModuleWith = attrs @ {
|
||||||
|
staticModules ? [],
|
||||||
|
specialArgs ? {},
|
||||||
|
}:
|
||||||
|
t.deferredModuleWith {inherit staticModules;}
|
||||||
|
// {
|
||||||
|
inherit
|
||||||
|
(t.submoduleWith {
|
||||||
|
modules = staticModules;
|
||||||
|
inherit specialArgs;
|
||||||
|
})
|
||||||
|
getSubOptions
|
||||||
|
getSubModules
|
||||||
|
;
|
||||||
|
substSubModules = m:
|
||||||
|
deferredModuleWith (attrs
|
||||||
|
// {
|
||||||
|
staticModules = m;
|
||||||
|
});
|
||||||
|
};
|
||||||
in {
|
in {
|
||||||
options = {
|
options = {
|
||||||
overrideAll = lib.mkOption {
|
overrideAll = lib.mkOption {
|
||||||
type = t.deferredModuleWith {inherit staticModules;};
|
type = deferredModuleWith {
|
||||||
|
inherit specialArgs;
|
||||||
|
staticModules = [config.overrideType];
|
||||||
|
};
|
||||||
description = ''
|
description = ''
|
||||||
Overrides applied on all dependencies.
|
Overrides applied on all dependencies.
|
||||||
'';
|
'';
|
||||||
@ -23,7 +45,10 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
overrides = lib.mkOption {
|
overrides = lib.mkOption {
|
||||||
type = t.attrsOf (t.deferredModuleWith {inherit staticModules;});
|
type = t.attrsOf (deferredModuleWith {
|
||||||
|
inherit specialArgs;
|
||||||
|
staticModules = [config.overrideType];
|
||||||
|
});
|
||||||
description = ''
|
description = ''
|
||||||
Overrides applied only on dependencies matching the specified name.
|
Overrides applied only on dependencies matching the specified name.
|
||||||
'';
|
'';
|
||||||
@ -37,7 +62,9 @@ in {
|
|||||||
|
|
||||||
## INTERNAL
|
## INTERNAL
|
||||||
overrideType = lib.mkOption {
|
overrideType = lib.mkOption {
|
||||||
type = t.deferredModule;
|
type = deferredModuleWith {
|
||||||
|
inherit specialArgs;
|
||||||
|
};
|
||||||
default = {};
|
default = {};
|
||||||
internal = true;
|
internal = true;
|
||||||
};
|
};
|
||||||
|
@ -30,6 +30,7 @@ in {
|
|||||||
imports = [
|
imports = [
|
||||||
./interface.nix
|
./interface.nix
|
||||||
dream2nix.modules.dream2nix.mkDerivation
|
dream2nix.modules.dream2nix.mkDerivation
|
||||||
|
dream2nix.modules.dream2nix.core
|
||||||
];
|
];
|
||||||
|
|
||||||
# declare external dependencies
|
# declare external dependencies
|
||||||
|
@ -169,6 +169,7 @@
|
|||||||
{config, ...}: {
|
{config, ...}: {
|
||||||
imports = [
|
imports = [
|
||||||
dream2nix.modules.dream2nix.mkDerivation
|
dream2nix.modules.dream2nix.mkDerivation
|
||||||
|
dream2nix.modules.dream2nix.core
|
||||||
];
|
];
|
||||||
deps = {nixpkgs, ...}:
|
deps = {nixpkgs, ...}:
|
||||||
l.mapAttrs (_: l.mkDefault) {
|
l.mapAttrs (_: l.mkDefault) {
|
||||||
|
@ -24,11 +24,12 @@ in {
|
|||||||
deps = {
|
deps = {
|
||||||
internal = true;
|
internal = true;
|
||||||
visible = "shallow";
|
visible = "shallow";
|
||||||
type = t.lazyAttrsOf (t.lazyAttrsOf (t.submodule {
|
type = t.lazyAttrsOf (t.lazyAttrsOf (t.submoduleWith {
|
||||||
imports = [
|
modules = [
|
||||||
dream2nix.modules.dream2nix.core
|
dream2nix.modules.dream2nix.core
|
||||||
cfg.overrideType
|
cfg.overrideType
|
||||||
];
|
];
|
||||||
|
inherit specialArgs;
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
composerInstallFlags = {
|
composerInstallFlags = {
|
||||||
|
@ -76,6 +76,7 @@
|
|||||||
commonModule = {config, ...}: {
|
commonModule = {config, ...}: {
|
||||||
imports = [
|
imports = [
|
||||||
dream2nix.modules.dream2nix.mkDerivation
|
dream2nix.modules.dream2nix.mkDerivation
|
||||||
|
dream2nix.modules.dream2nix.core
|
||||||
../buildPythonPackage
|
../buildPythonPackage
|
||||||
];
|
];
|
||||||
config = {
|
config = {
|
||||||
|
@ -139,8 +139,8 @@ in {
|
|||||||
# hack because internal=true doesn't propagate to the submodule options
|
# hack because internal=true doesn't propagate to the submodule options
|
||||||
visible = "shallow";
|
visible = "shallow";
|
||||||
type = t.lazyAttrsOf (t.submoduleWith {
|
type = t.lazyAttrsOf (t.submoduleWith {
|
||||||
|
inherit specialArgs;
|
||||||
modules = [dream2nix.modules.dream2nix.core];
|
modules = [dream2nix.modules.dream2nix.core];
|
||||||
specialArgs = {inherit packageSets dream2nix;};
|
|
||||||
});
|
});
|
||||||
description = "drv-parts modules that define python dependencies";
|
description = "drv-parts modules that define python dependencies";
|
||||||
};
|
};
|
||||||
|
@ -22,7 +22,6 @@ in {
|
|||||||
version = "0.13.0";
|
version = "0.13.0";
|
||||||
|
|
||||||
deps = {nixpkgs, ...}: {
|
deps = {nixpkgs, ...}: {
|
||||||
stdenv = lib.mkForce nixpkgs.stdenv;
|
|
||||||
jq = lib.mkForce nixpkgs.jq;
|
jq = lib.mkForce nixpkgs.jq;
|
||||||
fetchFromGitHub = nixpkgs.fetchFromGitHub;
|
fetchFromGitHub = nixpkgs.fetchFromGitHub;
|
||||||
python = nixpkgs.python310;
|
python = nixpkgs.python310;
|
||||||
|
@ -185,6 +185,7 @@ in {
|
|||||||
imports = [
|
imports = [
|
||||||
./interface.nix
|
./interface.nix
|
||||||
dream2nix.modules.dream2nix.mkDerivation
|
dream2nix.modules.dream2nix.mkDerivation
|
||||||
|
dream2nix.modules.dream2nix.core
|
||||||
];
|
];
|
||||||
|
|
||||||
rust-crane.depsDrv = {
|
rust-crane.depsDrv = {
|
||||||
|
@ -83,7 +83,10 @@ in {
|
|||||||
# version = "dummy-version";
|
# version = "dummy-version";
|
||||||
# }
|
# }
|
||||||
];
|
];
|
||||||
specialArgs.dream2nix = self;
|
specialArgs.dream2nix =
|
||||||
|
# trace website modules
|
||||||
|
# lib.trace modules
|
||||||
|
self;
|
||||||
specialArgs.packageSets.nixpkgs = pkgs;
|
specialArgs.packageSets.nixpkgs = pkgs;
|
||||||
};
|
};
|
||||||
# inputs.flake-parts.lib.evalFlakeModule
|
# inputs.flake-parts.lib.evalFlakeModule
|
||||||
|
Loading…
Reference in New Issue
Block a user