1 # When updating this package please check that all other versions of Nim
2 # evaluate because they reuse definitions from the latest compiler.
13 Security ? darwin.Security,
20 # Derive a Nim CPU identifier
23 else if isAarch64 then
29 else if isMips && is32bit then
31 else if isMips && is64bit then
35 else if isPower && is32bit then
37 else if isPower && is64bit then
39 else if isRiscV && is64bit then
48 throw "no Nim CPU support known for ${config}";
53 # Derive a Nim OS identifier
58 else if isFreeBSD then
68 else if isOpenBSD then
70 else if isWindows then
75 throw "no Nim OS support known for ${config}";
82 nimHost = parsePlatform stdenv.hostPlatform;
83 nimTarget = parsePlatform stdenv.targetPlatform;
86 stdenv.mkDerivation (finalAttrs: {
87 pname = "nim-unwrapped";
92 url = "https://nim-lang.org/download/nim-${finalAttrs.version}.tar.xz";
93 hash = "sha256-zphChJyXYOSH7N0c2t98DyhEyvrmBUAcfHKuJXZEiTw=";
102 ] ++ lib.optional stdenv.hostPlatform.isDarwin Security;
105 ./NIM_CONFIG_DIR.patch
106 # Override compiler configuration via an environmental variable
109 # Load libraries at runtime by absolute path
111 ./extra-mangling-2.patch
112 # Mangle store paths of modules to prevent runtime dependence.
115 # dlopen is widely used by Python, Ruby, Perl, ... what you're really telling me here is that your OS is fundamentally broken. That might be news for you, but it isn't for me.
120 bootstrapCompiler = stdenv.mkDerivation {
121 pname = "nim-bootstrap";
122 inherit (finalAttrs) version src preBuild;
123 enableParallelBuilding = true;
126 install -Dt $out/bin bin/nim
133 cp ${bootstrapCompiler}/bin/nim bin/
134 echo 'define:nixbuild' >> config/nim.cfg
135 runHook postConfigure
140 "--cpu:${nimHost.cpu}"
145 ++ lib.optional (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isLinux) "-d:nativeStacktrace";
147 preBuild = lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) ''
148 substituteInPlace makefile \
149 --replace "aarch64" "arm64"
155 ./bin/nim c --parallelBuild:$NIX_BUILD_CORES koch
156 ./koch boot $kochArgs --parallelBuild:$NIX_BUILD_CORES
157 ./koch toolsNoExternal $kochArgs --parallelBuild:$NIX_BUILD_CORES
158 ./bin/nim js -d:release tools/dochack/dochack.nim
164 install -Dt $out/bin bin/*
165 ln -sf $out/nim/bin/nim $out/bin/nim
166 ln -sf $out/nim/lib $out/lib
168 cp -a tools dist $out/nim/
173 inherit nimHost nimTarget;
177 description = "Statically typed, imperative programming language";
178 homepage = "https://nim-lang.org/";
179 license = licenses.mit;
181 maintainers = with maintainers; [