Add generic helper

This commit is contained in:
Las Safin 2021-08-29 17:36:58 +00:00
parent 7105a5aea4
commit 41665edfed
No known key found for this signature in database
GPG Key ID: E7FA928911B61ED6
3 changed files with 52 additions and 19 deletions

View File

@ -33,6 +33,10 @@
cmakeFlags = [ "-DBUILD_DOC=ON" ] ++ (o.cmakeFlags or []);
});
generic = import ./nix/generic.nix { inherit version meta; };
# not generic: solstice lefdef equinox knik coloquinte bootstrap
components = [
"vlsisapd" "lefdef" "bootstrap" "hurricane" "crlcore"
"cumulus" "flute" "etesian" "anabatic" "coloquinte"
@ -42,6 +46,8 @@
"unittests"
];
commonArgs = { inherit version meta generic; };
in
rec {
@ -49,7 +55,8 @@
builtins.foldl'
(acc: elem: acc // {
"coriolis-${elem}" = override (final.callPackage (
import "${self}/nix/${elem}.nix" { inherit version meta; }
let f = import (./nix + "/${elem}.nix"); in
f (builtins.intersectAttrs (builtins.functionArgs f) commonArgs)
) {});
}) {} components;

33
nix/generic.nix Normal file
View File

@ -0,0 +1,33 @@
{ version, meta }:
let f =
{ lib, stdenv, cmake, ninja, boost
, coriolis-bootstrap, python2Packages }:
{ name
, src
, buildInputs ? []
, nativeBuildInputs ? []
, pythonImportsCheck
}:
let
boostWithPython = boost.override { enablePython = true; inherit (python2Packages) python; };
drv = stdenv.mkDerivation {
pname = "coriolis-${name}";
buildInputs = [ python2Packages.python boostWithPython coriolis-bootstrap ] ++ buildInputs;
nativeBuildInputs = [ cmake ninja python2Packages.pythonImportsCheckHook ] ++ nativeBuildInputs;
preInstall = ''
export PYTHONPATH="$out/${python2Packages.python.sitePackages}:$PYTHONPATH"
'';
inherit version meta src pythonImportsCheck;
};
in python2Packages.toPythonModule drv;
in
pkg:
{
__functionArgs = builtins.functionArgs f // builtins.functionArgs pkg;
__functor = self: args: f (builtins.intersectAttrs (builtins.functionArgs f) args) (pkg (builtins.intersectAttrs (builtins.functionArgs pkg) args));
}

View File

@ -1,18 +1,11 @@
{ version, meta }:
{ lib, stdenv, cmake, boost, bison, flex
, libxml2, qt4, ninja, coriolis-bootstrap, doxygen
, python2Packages }:
let boostWithPython = boost.override { enablePython = true; inherit (python2Packages) python; }; in
python2Packages.toPythonModule (stdenv.mkDerivation {
pname = "coriolis-vlsisapd";
src = ../vlsisapd;
buildInputs = [ python2Packages.python boostWithPython coriolis-bootstrap libxml2 bison flex qt4 ];
nativeBuildInputs = [ cmake ninja doxygen ];
inherit version meta;
})
{ version, meta, generic, ... }:
let pkg =
{ libxml2, qt4, bison, flex, doxygen }:
{
name = "vlsisapd";
src = ../vlsisapd;
buildInputs = [ libxml2 qt4 ];
nativeBuildInputs = [ bison flex doxygen ];
pythonImportsCheck = [ "SPICE" "LIBERTY" "DTR" "Cfg" "CIF" "AGDS" ];
};
in generic pkg