2021-09-23 15:35:13 +00:00
|
|
|
{ lib, stdenv, nim, nim_builder }:
|
2023-07-15 17:15:38 +00:00
|
|
|
pkgArgs:
|
2021-09-23 15:35:13 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
let
|
|
|
|
baseAttrs = {
|
|
|
|
strictDeps = true;
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
doCheck = true;
|
|
|
|
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
|
|
|
|
'';
|
|
|
|
meta = { inherit (nim.meta) maintainers platforms; };
|
|
|
|
};
|
2021-09-23 15:35:13 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
inputsOverride =
|
|
|
|
{ depsBuildBuild ? [ ], nativeBuildInputs ? [ ], ... }: {
|
|
|
|
depsBuildBuild = [ nim_builder ] ++ depsBuildBuild;
|
|
|
|
nativeBuildInputs = [ nim ] ++ nativeBuildInputs;
|
|
|
|
};
|
2021-09-23 15:35:13 +00:00
|
|
|
|
2023-07-15 17:15:38 +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-23 15:35:13 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
in stdenv.mkDerivation composition
|