2023-11-20 08:12:30 +00:00
|
|
|
{ lib, stdenv, nim1, nim2, nim_builder, defaultNimVersion ? 2 }:
|
2023-06-14 09:43:26 +00:00
|
|
|
pkgArgs:
|
2021-09-02 17:03:01 +00:00
|
|
|
|
2023-06-14 09:43:26 +00:00
|
|
|
let
|
|
|
|
baseAttrs = {
|
|
|
|
strictDeps = true;
|
|
|
|
enableParallelBuilding = true;
|
2023-06-14 11:11:20 +00:00
|
|
|
doCheck = true;
|
2023-06-14 09:43:26 +00:00
|
|
|
configurePhase = ''
|
|
|
|
runHook preConfigure
|
|
|
|
export NIX_NIM_BUILD_INPUTS=''${pkgsHostTarget[@]} $NIX_NIM_BUILD_INPUTS
|
|
|
|
nim_builder --phase:configure
|
|
|
|
runHook postConfigure
|
|
|
|
'';
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
nim_builder --phase:build
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
nim_builder --phase:check
|
|
|
|
runHook postCheck
|
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
nim_builder --phase:install
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
2023-11-20 08:12:30 +00:00
|
|
|
meta = { inherit (nim2.meta) maintainers platforms; };
|
2023-06-14 09:43:26 +00:00
|
|
|
};
|
2021-09-02 17:03:01 +00:00
|
|
|
|
2023-11-20 08:12:30 +00:00
|
|
|
inputsOverride = { depsBuildBuild ? [ ], nativeBuildInputs ? [ ]
|
|
|
|
, requiredNimVersion ? defaultNimVersion, ... }:
|
|
|
|
(if requiredNimVersion == 1 then {
|
|
|
|
nativeBuildInputs = [ nim1 ] ++ nativeBuildInputs;
|
|
|
|
} else if requiredNimVersion == 2 then {
|
|
|
|
nativeBuildInputs = [ nim2 ] ++ nativeBuildInputs;
|
|
|
|
} else
|
|
|
|
throw "requiredNimVersion ${toString requiredNimVersion} is not valid")
|
|
|
|
// {
|
2023-06-14 09:43:26 +00:00
|
|
|
depsBuildBuild = [ nim_builder ] ++ depsBuildBuild;
|
|
|
|
};
|
2021-09-02 17:03:01 +00:00
|
|
|
|
2023-06-14 09:43:26 +00:00
|
|
|
composition = finalAttrs:
|
|
|
|
let
|
|
|
|
asFunc = x: if builtins.isFunction x then x else (_: x);
|
|
|
|
prev = baseAttrs // (asFunc ((asFunc pkgArgs) finalAttrs)) baseAttrs;
|
|
|
|
in prev // inputsOverride prev;
|
2021-09-02 17:03:01 +00:00
|
|
|
|
2023-06-14 09:43:26 +00:00
|
|
|
in stdenv.mkDerivation composition
|