@@ -1,7 +1,7 @@
11# https://nim-lang.github.io/Nim/packaging.html
22
3−{ stdenv, lib, fetchgit, fetchurl, makeWrapper, gdb, openssl, pcre, readline
4−, boehmgc, sqlite, nim-unwrapped, nim }:
3+{ stdenv, lib, fetchurl, fetchgit, fetchFromGitHub, makeWrapper, gdb, openssl
4+, pcre, readline, boehmgc, sqlite, nim-unwrapped, nimble-unwrapped }:
55
66let
77 version = "1.4.0";
@@ -153,21 +153,52 @@ let
153153
154154 inherit meta;
155155 };
156+
157+ nimble-unwrapped = stdenv.mkDerivation rec {
158+ pname = "nimble-unwrapped";
159+ version = "0.12.0";
160+
161+ src = fetchFromGitHub {
162+ owner = "nim-lang";
163+ repo = "nimble";
164+ rev = "v" + version;
165+ sha256 = "0vx0mdk31n00dr2rhiip6f4x7aa3z3mnblnmwk7f65ixd5hayq6y";
166+ };
167+
168+ nativeBuildInputs = [ nim-unwrapped ];
169+ buildInputs = [ openssl ];
170+
171+ nimFlags = [ "--cpu:${nimHost.cpu}" "--os:${nimHost.os}" "-d:release" ];
172+
173+ buildPhase = ''
174+ runHook preBuild
175+ HOME=$NIX_BUILD_TOP nim c $nimFlags src/nimble
176+ runHook postBuild
177+ '';
178+
179+ installPhase = ''
180+ runHook preBuild
181+ install -Dt $out/bin src/nimble
182+ runHook postBuild
183+ '';
184+ };
185+
156186 };
157187
158188 wrapped = let
159− nim = nim-unwrapped;
189+ nim' = nim-unwrapped;
190+ nimble' = nimble-unwrapped;
160191 inherit (stdenv) targetPlatform;
161192 in stdenv.mkDerivation {
162− name = "${targetPlatform.config}-nim-wrapper-${nim.version}";
163− inherit (nim) version;
193+ name = "${targetPlatform.config}-nim-wrapper-${nim'.version}";
194+ inherit (nim') version;
164195 preferLocalBuild = true;
165196
166197 nativeBuildInputs = [ makeWrapper ];
167198
168199 unpackPhase = ''
169200 runHook preUnpack
170− tar xf ${nim.src} nim-$version/config/nim.cfg
201+ tar xf ${nim'.src} nim-$version/config/nim.cfg
171202 cd nim-$version
172203 runHook postUnpack
173204 '';
@@ -210,7 +241,7 @@ let
210241 substituteAll config/nim.cfg $out/etc/nim/nim.cfg \
211242 --replace "cc = gcc" ""
212243
213− for binpath in ${nim}/bin/nim?*; do
244+ for binpath in ${nim'}/bin/nim?*; do
214245 local binname=`basename $binpath`
215246 makeWrapper \
216247 $binpath $out/bin/${targetPlatform.config}-$binname \
@@ -219,21 +250,25 @@ let
219250 done
220251
221252 makeWrapper \
222− ${nim}/nim/bin/nim $out/bin/${targetPlatform.config}-nim \
253+ ${nim'}/nim/bin/nim $out/bin/${targetPlatform.config}-nim \
223254 $wrapperArgs
224255 ln -s $out/bin/${targetPlatform.config}-nim $out/bin/nim
225256
257+ makeWrapper \
258+ ${nimble'}/bin/nimble $out/bin/${targetPlatform.config}-nimble \
259+ --suffix PATH : $out/bin
260+ ln -s $out/bin/${targetPlatform.config}-nimble $out/bin/nimble
261+
226262 runHook postBuild
227263 '';
228264
229265 dontInstall = true;
230266
231267 meta = meta // {
232− description = nim.meta.description
268+ description = nim'.meta.description
233269 + " (${targetPlatform.config} wrapper)";
234270 platforms = lib.platforms.unix;
235271 };
236−
237272 };
238273
239274in wrapped // wrapperInputs