diff --git a/flake.nix b/flake.nix index 9863aa27..21771781 100644 --- a/flake.nix +++ b/flake.nix @@ -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; diff --git a/nix/generic.nix b/nix/generic.nix new file mode 100644 index 00000000..469f609f --- /dev/null +++ b/nix/generic.nix @@ -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)); +} diff --git a/nix/vlsisapd.nix b/nix/vlsisapd.nix index 2e35e2cc..51b99378 100644 --- a/nix/vlsisapd.nix +++ b/nix/vlsisapd.nix @@ -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