17 enableParallelBuilding = true;
21 export NIX_NIM_BUILD_INPUTS=''${pkgsHostTarget[@]} $NIX_NIM_BUILD_INPUTS
22 nim_builder --phase:configure
27 nim_builder --phase:build
32 nim_builder --phase:check
37 nim_builder --phase:install
40 meta = { inherit (nim2.meta) maintainers platforms; };
48 buildPackages.fetchzip {
61 buildPackages.fetchgit {
72 attrs@{ method, ... }:
74 fod = methods.${method} attrs;
76 ''--path:"${fod.outPath}/${attrs.srcDir}"'';
78 asFunc = x: if builtins.isFunction x then x else (_: x);
86 postPkg = baseAttrs // (asFunc ((asFunc buildNimPackageArgs) finalAttrs)) baseAttrs;
88 lockAttrs = lib.attrsets.optionalAttrs (builtins.hasAttr "lockFile" postPkg) (
89 builtins.fromJSON (builtins.readFile postPkg.lockFile)
92 lockDepends = lockAttrs.depends or [ ];
94 lockFileNimFlags = map fodFromLockEntry lockDepends;
96 postNimOverrides = builtins.foldl' (
98 { packages, ... }@lockAttrs:
101 if (builtins.hasAttr name nimOverrides) then
102 (prevAttrs // (nimOverrides.${name} lockAttrs prevAttrs))
106 ) postPkg lockDepends;
110 depsBuildBuild ? [ ],
111 nativeBuildInputs ? [ ],
113 requiredNimVersion ? defaultNimVersion,
118 if requiredNimVersion == 1 then
120 depsBuildBuild = [ nim_builder ] ++ depsBuildBuild;
121 nativeBuildInputs = [ nim1 ] ++ nativeBuildInputs;
123 else if requiredNimVersion == 2 then
125 depsBuildBuild = [ nim_builder ] ++ depsBuildBuild;
126 nativeBuildInputs = [ nim2 ] ++ nativeBuildInputs;
129 throw "requiredNimVersion ${toString requiredNimVersion} is not valid"
132 nimFlags = lockFileNimFlags ++ nimFlags;
133 passthru = passthru // {
134 # allow overriding the result of buildNimPackageArgs before this composition is applied
135 # this allows overriding the lockFile for packages built using buildNimPackage
136 # this is adapted from mkDerivationExtensible in stdenv.mkDerivation
145 if builtins.isFunction x then f0 self super else x;
150 super = (asFunc ((asFunc buildNimPackageArgs) self)) baseAttrs;
152 super // (if builtins.isFunction f0 || f0 ? __functor then f self super else f0)
157 attrs = postNimOverrides // finalOverride postNimOverrides;
159 lib.trivial.warnIf (builtins.hasAttr "nimBinOnly" attrs)
160 "the nimBinOnly attribute is deprecated for buildNimPackage"
164 stdenv.mkDerivation composition