mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-11-25 22:13:34 +03:00
feat: merge attrs-from-... into nixpkgs-overrides
This commit is contained in:
parent
1d36c7f3ce
commit
0007206ea1
@ -1,38 +0,0 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
l = lib // builtins;
|
||||
t = l.types;
|
||||
|
||||
# Attributes we never want to copy from nixpkgs
|
||||
excludedNixpkgsAttrs =
|
||||
l.genAttrs
|
||||
[
|
||||
"all"
|
||||
"args"
|
||||
"builder"
|
||||
"name"
|
||||
"pname"
|
||||
"version"
|
||||
"src"
|
||||
"outputs"
|
||||
]
|
||||
(name: null);
|
||||
|
||||
extractOverrideAttrs = overrideFunc:
|
||||
(overrideFunc (old: {passthru.old = old;}))
|
||||
.old;
|
||||
|
||||
extractPythonAttrs = pythonPackage: let
|
||||
pythonAttrs = extractOverrideAttrs pythonPackage.overridePythonAttrs;
|
||||
in
|
||||
l.filterAttrs (name: _: ! excludedNixpkgsAttrs ? ${name}) pythonAttrs;
|
||||
in {
|
||||
imports = [
|
||||
./interface.nix
|
||||
];
|
||||
|
||||
config.attrs-from-nixpkgs.lib = {inherit extractOverrideAttrs extractPythonAttrs;};
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
l = lib // builtins;
|
||||
t = l.types;
|
||||
in {
|
||||
options.attrs-from-nixpkgs = {
|
||||
lib.extractOverrideAttrs = l.mkOption {
|
||||
type = t.functionTo t.attrs;
|
||||
description = ''
|
||||
Helper function to extract attrs from nixpkgs to be re-used as overrides.
|
||||
'';
|
||||
readOnly = true;
|
||||
};
|
||||
|
||||
# Extracts derivation args from a nixpkgs python package.
|
||||
lib.extractPythonAttrs = l.mkOption {
|
||||
type = t.functionTo t.attrs;
|
||||
description = ''
|
||||
Helper function to extract python attrs from nixpkgs to be re-used as overrides.
|
||||
'';
|
||||
readOnly = true;
|
||||
};
|
||||
};
|
||||
}
|
@ -7,20 +7,8 @@
|
||||
l = lib // builtins;
|
||||
cfg = config.nixpkgs-overrides;
|
||||
|
||||
# Attributes we never want to copy from nixpkgs
|
||||
excludedNixpkgsAttrs =
|
||||
l.genAttrs
|
||||
[
|
||||
"all"
|
||||
"args"
|
||||
"builder"
|
||||
"name"
|
||||
"pname"
|
||||
"version"
|
||||
"src"
|
||||
"outputs"
|
||||
]
|
||||
(name: null);
|
||||
l.genAttrs cfg.excludedNixpkgsAttrs (name: null);
|
||||
|
||||
extractOverrideAttrs = overrideFunc:
|
||||
(overrideFunc (old: {passthru.old = old;}))
|
||||
@ -37,7 +25,12 @@ in {
|
||||
./interface.nix
|
||||
];
|
||||
|
||||
config = l.mkIf cfg.enable {
|
||||
package-func.args = extracted;
|
||||
};
|
||||
config = l.mkMerge [
|
||||
(l.mkIf cfg.enable {
|
||||
package-func.args = extracted;
|
||||
})
|
||||
{
|
||||
nixpkgs-overrides.lib = {inherit extractOverrideAttrs extractPythonAttrs;};
|
||||
}
|
||||
];
|
||||
}
|
||||
|
@ -7,6 +7,38 @@
|
||||
t = l.types;
|
||||
in {
|
||||
options.nixpkgs-overrides = {
|
||||
enable = l.mkEnableOption "Whether to apply override from nixpkgs";
|
||||
enable = l.mkEnableOption "Whether to copy attributes, except those in `excludedNixpkgsAttrs` from nixpkgs";
|
||||
|
||||
excludedNixpkgsAttrs = l.mkOption {
|
||||
type = t.listOf t.str;
|
||||
description = "Attributes we do not want to copy from nixpkgs";
|
||||
default = [
|
||||
"all"
|
||||
"args"
|
||||
"builder"
|
||||
"name"
|
||||
"pname"
|
||||
"version"
|
||||
"src"
|
||||
"outputs"
|
||||
];
|
||||
};
|
||||
|
||||
lib.extractOverrideAttrs = l.mkOption {
|
||||
type = t.functionTo t.attrs;
|
||||
description = ''
|
||||
Helper function to extract attrs from nixpkgs to be re-used as overrides.
|
||||
'';
|
||||
readOnly = true;
|
||||
};
|
||||
|
||||
# Extracts derivation args from a nixpkgs python package.
|
||||
lib.extractPythonAttrs = l.mkOption {
|
||||
type = t.functionTo t.attrs;
|
||||
description = ''
|
||||
Helper function to extract python attrs from nixpkgs to be re-used as overrides.
|
||||
'';
|
||||
readOnly = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -6,13 +6,12 @@
|
||||
}: let
|
||||
l = lib // builtins;
|
||||
python = config.deps.python;
|
||||
extractPythonAttrs = config.attrs-from-nixpkgs.lib.extractPythonAttrs;
|
||||
|
||||
extractPythonAttrs = config.nixpkgs-overrides.lib.extractPythonAttrs;
|
||||
nixpkgsAttrs = extractPythonAttrs python.pkgs.apache-airflow;
|
||||
in {
|
||||
imports = [
|
||||
../../drv-parts/mach-nix-xs
|
||||
../../drv-parts/attrs-from-nixpkgs
|
||||
../../drv-parts/nixpkgs-overrides
|
||||
];
|
||||
|
||||
deps = {
|
||||
|
Loading…
Reference in New Issue
Block a user