mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-11-23 00:13:02 +03:00
feat(mach-nix): use drv-parts for dependencies.
This commit is contained in:
parent
52a6fc802a
commit
71c396138c
@ -65,13 +65,11 @@
|
||||
sdistsToBuild = filterAttrs sdistInfos (name: ver: (! substitutions ? ${name}) && name != packageName);
|
||||
builtWheels = mapAttrs sdistsToBuild (name: ver: mkWheelDist name ver (getDistDir name));
|
||||
|
||||
wheelsToPatch = builtWheels // substitutions;
|
||||
|
||||
# patch wheels to ensure build inputs are propagated for autopPatchelfHook
|
||||
# TODO: explain why this is necessary
|
||||
patchedWheels = mapAttrs wheelsToPatch (name: dist: dist.overridePythonAttrs (old: {postFixup = "ln -s $out $dist/out";}));
|
||||
patchedWheels = mapAttrs substitutions (name: dist: dist.overridePythonAttrs (old: {postFixup = "ln -s $out $dist/out";}));
|
||||
in
|
||||
{ inherit patchedWheels downloadedWheels; };
|
||||
{ inherit patchedWheels downloadedWheels builtWheels; };
|
||||
|
||||
# The final dists we want to install.
|
||||
# A mix of:
|
||||
@ -79,46 +77,57 @@
|
||||
# - downloaded sdists built into wheels (see above)
|
||||
# - substitutions from nixpkgs patched for compat with autoPatchelfHook
|
||||
finalDistsPaths =
|
||||
preparedWheels.downloadedWheels // (l.mapAttrs (_: drv: drv.public.dist) config.mach-nix.drvs);
|
||||
preparedWheels.downloadedWheels // (l.mapAttrs (_: drv: drv.public.out.dist) config.mach-nix.drvs);
|
||||
|
||||
|
||||
# build a wheel for a given sdist
|
||||
mkWheelDist = pname: version: distDir: let
|
||||
# re-use package attrs from nixpkgs
|
||||
mkWheelDist = name: version: distDir: let
|
||||
#TODO re-use package attrs from nixpkgs
|
||||
# (treat nixpkgs as a source of community overrides)
|
||||
extractedAttrs = l.optionalAttrs (python.pkgs ? ${pname})
|
||||
config.attrs-from-nixpkgs.lib.extractPythonAttrs python.pkgs.${pname};
|
||||
#extractedAttrs = l.optionalAttrs (python.pkgs ? ${name})
|
||||
# config.attrs-from-nixpkgs.lib.extractPythonAttrs python.pkgs.${name};
|
||||
manualSetupDeps =
|
||||
lib.mapAttrs
|
||||
(name: deps: map (dep: finalDistsPaths.${dep}) deps)
|
||||
cfg.manualSetupDeps;
|
||||
in
|
||||
python.pkgs.buildPythonPackage (
|
||||
# nixpkgs attrs
|
||||
extractedAttrs
|
||||
in {config, ...}: {
|
||||
imports = [
|
||||
drv-parts.modules.drv-parts.mkDerivation
|
||||
../buildPythonPackage
|
||||
./interface.nix
|
||||
../eval-cache
|
||||
../attrs-from-nixpkgs
|
||||
];
|
||||
config = {
|
||||
deps = {nixpkgs, ...}: l.mapAttrs (_: l.mkDefault) ({
|
||||
inherit python;
|
||||
inherit (nixpkgs)
|
||||
autoPatchelfHook
|
||||
stdenv
|
||||
;
|
||||
});
|
||||
|
||||
# package attributes
|
||||
// {
|
||||
inherit pname;
|
||||
inherit version;
|
||||
public = {
|
||||
inherit name version;
|
||||
};
|
||||
buildPythonPackage = {
|
||||
format = "setuptools";
|
||||
pipInstallFlags =
|
||||
(map (distDir: "--find-links ${distDir}") manualSetupDeps.${name} or [])
|
||||
++ (map (dep: "--find-links ${finalDistsPaths.${dep}}") dependencyTree.${name} or []);
|
||||
};
|
||||
mkDerivation = {
|
||||
# distDir will contain a single file which is the src
|
||||
preUnpack = ''export src="${distDir}"/*'';
|
||||
# install manualSetupDeps
|
||||
pipInstallFlags =
|
||||
(map (distDir: "--find-links ${distDir}") manualSetupDeps.${pname} or [])
|
||||
++ (map (dep: "--find-links ${finalDistsPaths.${dep}}") dependencyTree.${pname} or []);
|
||||
nativeBuildInputs =
|
||||
extractedAttrs.nativeBuildInputs or []
|
||||
++ [config.deps.autoPatchelfHook];
|
||||
}
|
||||
|
||||
# If setup deps have been specified manually, we need to remove the
|
||||
nativeBuildInputs = [config.deps.autoPatchelfHook];
|
||||
};
|
||||
# TODO If setup deps have been specified manually, we need to remove the
|
||||
# propagatedBuildInputs from nixpkgs to prevent collisions.
|
||||
// lib.optionalAttrs (manualSetupDeps ? ${pname}) {
|
||||
propagatedBuildInputs = [];
|
||||
}
|
||||
);
|
||||
#// lib.optionalAttrs (manualSetupDeps ? ${name}) {
|
||||
# propagatedBuildInputs = [];
|
||||
#};
|
||||
};
|
||||
};
|
||||
|
||||
dependenciesFile = "${cfg.pythonSources}/dependencies.json";
|
||||
dependencies = l.filter (d: d.name != packageName) (l.fromJSON (l.readFile dependenciesFile));
|
||||
@ -150,7 +159,7 @@ in {
|
||||
|
||||
config = {
|
||||
|
||||
mach-nix.drvs = l.mapAttrs makeModuleFromDerivation preparedWheels.patchedWheels;
|
||||
mach-nix.drvs = (l.mapAttrs makeModuleFromDerivation preparedWheels.patchedWheels) // preparedWheels.builtWheels;
|
||||
mach-nix.dists =
|
||||
l.mapAttrs
|
||||
(name: _: getDistInfo name)
|
||||
|
Loading…
Reference in New Issue
Block a user