mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-12-24 15:01:56 +03:00
feat(mach-nix): wip, split nixpkgsAttrs -> module
This commit is contained in:
parent
169da1c545
commit
173d76b688
34
v1/nix/modules/drv-parts/attrs-from-nixpkgs/default.nix
Normal file
34
v1/nix/modules/drv-parts/attrs-from-nixpkgs/default.nix
Normal file
@ -0,0 +1,34 @@
|
||||
{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; };
|
||||
}
|
26
v1/nix/modules/drv-parts/attrs-from-nixpkgs/interface.nix
Normal file
26
v1/nix/modules/drv-parts/attrs-from-nixpkgs/interface.nix
Normal file
@ -0,0 +1,26 @@
|
||||
{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;
|
||||
};
|
||||
|
||||
};
|
||||
}
|
@ -87,36 +87,12 @@
|
||||
(name: deps: map (dep: finalDistsPaths.${dep}) deps)
|
||||
cfg.manualSetupDeps;
|
||||
|
||||
# Attributes we never want to copy from nixpkgs
|
||||
excludedNixpkgsAttrs = l.genAttrs
|
||||
[
|
||||
"all"
|
||||
"args"
|
||||
"builder"
|
||||
"name"
|
||||
"pname"
|
||||
"version"
|
||||
"src"
|
||||
"outputs"
|
||||
]
|
||||
(name: null);
|
||||
|
||||
# Extracts derivation args from a nixpkgs python package.
|
||||
extractPythonAttrs = pythonPackage: let
|
||||
extractOverrideAttrs = overrideFunc:
|
||||
(pythonPackage.${overrideFunc} (old: {passthru.old = old;}))
|
||||
.old;
|
||||
pythonAttrs = extractOverrideAttrs "overridePythonAttrs";
|
||||
allAttrs = pythonAttrs;
|
||||
in
|
||||
l.filterAttrs (name: _: ! excludedNixpkgsAttrs ? ${name}) allAttrs;
|
||||
|
||||
# build a wheel for a given sdist
|
||||
mkWheelDist = pname: version: distDir: let
|
||||
# re-use package attrs from nixpkgs
|
||||
# (treat nixpkgs as a source of community overrides)
|
||||
extractedAttrs = l.optionalAttrs (python.pkgs ? ${pname})
|
||||
extractPythonAttrs python.pkgs.${pname};
|
||||
config.attrs-from-nixpkgs.lib.extractPythonAttrs python.pkgs.${pname};
|
||||
in
|
||||
python.pkgs.buildPythonPackage (
|
||||
# nixpkgs attrs
|
||||
@ -158,12 +134,11 @@ in {
|
||||
../buildPythonPackage
|
||||
./interface.nix
|
||||
../eval-cache
|
||||
../attrs-from-nixpkgs
|
||||
];
|
||||
|
||||
config = {
|
||||
|
||||
mach-nix.lib = {inherit extractPythonAttrs;};
|
||||
|
||||
mach-nix.drvs = l.flip l.mapAttrs preparedWheels.patchedWheels (name: dist:
|
||||
drv-parts.lib.makeModule {
|
||||
packageFunc = dist;
|
||||
|
@ -48,16 +48,6 @@ in {
|
||||
description = "drv-parts modules that define python dependencies";
|
||||
};
|
||||
|
||||
# LIB
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
# INTERNAL
|
||||
|
||||
dists = l.mkOption {
|
||||
|
@ -1,7 +1,7 @@
|
||||
{config, lib, drv-parts, ...}: let
|
||||
l = lib // builtins;
|
||||
python = config.deps.python;
|
||||
extractPythonAttrs = config.mach-nix.lib.extractPythonAttrs;
|
||||
extractPythonAttrs = config.attrs-from-nixpkgs.lib.extractPythonAttrs;
|
||||
|
||||
nixpkgsAttrs = extractPythonAttrs python.pkgs.apache-airflow;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user