about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/compilers/nim
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-09-27 16:00:58 +0000
committerAlyssa Ross <hi@alyssa.is>2021-09-27 16:00:58 +0000
commitc504e5d19d940926b3ddcf62c983d66f49f3cbb2 (patch)
treeec955e58bcac2cb93b9f8c10786b23f61d40cd7e /nixpkgs/pkgs/development/compilers/nim
parent72789cefce7b17419815f600fbd18238d89afcc9 (diff)
parent1737f98af6667560e3e4f930312f9b5002649d04 (diff)
downloadnixlib-c504e5d19d940926b3ddcf62c983d66f49f3cbb2.tar
nixlib-c504e5d19d940926b3ddcf62c983d66f49f3cbb2.tar.gz
nixlib-c504e5d19d940926b3ddcf62c983d66f49f3cbb2.tar.bz2
nixlib-c504e5d19d940926b3ddcf62c983d66f49f3cbb2.tar.lz
nixlib-c504e5d19d940926b3ddcf62c983d66f49f3cbb2.tar.xz
nixlib-c504e5d19d940926b3ddcf62c983d66f49f3cbb2.tar.zst
nixlib-c504e5d19d940926b3ddcf62c983d66f49f3cbb2.zip
Merge commit '1737f98af6667560e3e4f930312f9b5002649d04'
Conflicts:
	nixpkgs/nixos/modules/services/networking/ssh/sshd.nix
	nixpkgs/pkgs/applications/networking/irc/weechat/scripts/default.nix
	nixpkgs/pkgs/development/node-packages/default.nix
	nixpkgs/pkgs/development/python-modules/priority/deadline.patch
Diffstat (limited to 'nixpkgs/pkgs/development/compilers/nim')
-rw-r--r--nixpkgs/pkgs/development/compilers/nim/default.nix256
1 files changed, 130 insertions, 126 deletions
diff --git a/nixpkgs/pkgs/development/compilers/nim/default.nix b/nixpkgs/pkgs/development/compilers/nim/default.nix
index 25b1c4873572..7434347f2a28 100644
--- a/nixpkgs/pkgs/development/compilers/nim/default.nix
+++ b/nixpkgs/pkgs/development/compilers/nim/default.nix
@@ -1,8 +1,9 @@
 # https://nim-lang.github.io/Nim/packaging.html
 # https://nim-lang.org/docs/nimc.html
 
-{ lib, buildPackages, stdenv, fetchurl, fetchgit, fetchFromGitHub, makeWrapper
-, openssl, pcre, readline, boehmgc, sqlite, nim-unwrapped }:
+{ lib, callPackage, buildPackages, stdenv, fetchurl, fetchgit, fetchFromGitHub
+, makeWrapper, openssl, pcre, readline, boehmgc, sqlite, nim-unwrapped
+, nimble-unwrapped }:
 
 let
   parseCpu = platform:
@@ -22,9 +23,9 @@ let
       "mips64"
     else if isMsp430 then
       "msp430"
-    else if isPowerPC && is32bit then
+    else if isPower && is32bit then
       "powerpc"
-    else if isPowerPC && is64bit then
+    else if isPower && is64bit then
       "powerpc64"
     else if isRiscV && is64bit then
       "riscv64"
@@ -186,138 +187,141 @@ in {
     nim' = buildPackages.nim-unwrapped;
     nimble' = buildPackages.nimble-unwrapped;
     inherit (stdenv) targetPlatform;
-  in stdenv.mkDerivation {
-    name = "${targetPlatform.config}-nim-wrapper-${nim'.version}";
-    inherit (nim') version;
-    preferLocalBuild = true;
-    strictDeps = true;
-
-    nativeBuildInputs = [ makeWrapper ];
-
-    patches = [
-      ./nim.cfg.patch
-      # Remove configurations that clash with ours
-    ];
-
-    unpackPhase = ''
-      runHook preUnpack
-      tar xf ${nim'.src} nim-$version/config
-      cd nim-$version
-      runHook postUnpack
-    '';
-
-    dontConfigure = true;
-
-    buildPhase =
-      # Configure the Nim compiler to use $CC and $CXX as backends
-      # The compiler is configured by two configuration files, each with
-      # a different DSL. The order of evaluation matters and that order
-      # is not documented, so duplicate the configuration across both files.
-      ''
-        runHook preBuild
-        cat >> config/config.nims << WTF
-
-        switch("os", "${nimTarget.os}")
-        switch("cpu", "${nimTarget.cpu}")
-        switch("define", "nixbuild")
-
-        # Configure the compiler using the $CC set by Nix at build time
-        import strutils
-        let cc = getEnv"CC"
-        if cc.contains("gcc"):
-          switch("cc", "gcc")
-        elif cc.contains("clang"):
-          switch("cc", "clang")
-        WTF
-
-        mv config/nim.cfg config/nim.cfg.old
-        cat > config/nim.cfg << WTF
-        os = "${nimTarget.os}"
-        cpu =  "${nimTarget.cpu}"
-        define:"nixbuild"
-        WTF
-
-        cat >> config/nim.cfg < config/nim.cfg.old
-        rm config/nim.cfg.old
-
-        cat >> config/nim.cfg << WTF
-
-        clang.cpp.exe %= "\$CXX"
-        clang.cpp.linkerexe %= "\$CXX"
-        clang.exe %= "\$CC"
-        clang.linkerexe %= "\$CC"
-        gcc.cpp.exe %= "\$CXX"
-        gcc.cpp.linkerexe %= "\$CXX"
-        gcc.exe %= "\$CC"
-        gcc.linkerexe %= "\$CC"
-        WTF
-
-        runHook postBuild
+    self = stdenv.mkDerivation {
+      name = "${targetPlatform.config}-nim-wrapper-${nim'.version}";
+      inherit (nim') version;
+      preferLocalBuild = true;
+      strictDeps = true;
+
+      nativeBuildInputs = [ makeWrapper ];
+
+      patches = [
+        ./nim.cfg.patch
+        # Remove configurations that clash with ours
+      ];
+
+      unpackPhase = ''
+        runHook preUnpack
+        tar xf ${nim'.src} nim-$version/config
+        cd nim-$version
+        runHook postUnpack
       '';
 
-    wrapperArgs = [
-      "--prefix PATH : ${lib.makeBinPath [ buildPackages.gdb ]}:${
-        placeholder "out"
-      }/bin"
-      # Used by nim-gdb
-
-      "--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ openssl pcre ]}"
-      # These libraries may be referred to by the standard library.
-      # This is broken for cross-compilation because the package
-      # set will be shifted back by nativeBuildInputs.
-
-      "--set NIM_CONFIG_PATH ${placeholder "out"}/etc/nim"
-      # Use the custom configuration
-
-      ''--set NIX_HARDENING_ENABLE "''${NIX_HARDENING_ENABLE/fortify}"''
-      # Fortify hardening appends -O2 to gcc flags which is unwanted for unoptimized nim builds.
-    ];
-
-    installPhase = ''
-      runHook preInstall
-
-      mkdir -p $out/bin $out/etc
+      dontConfigure = true;
+
+      buildPhase =
+        # Configure the Nim compiler to use $CC and $CXX as backends
+        # The compiler is configured by two configuration files, each with
+        # a different DSL. The order of evaluation matters and that order
+        # is not documented, so duplicate the configuration across both files.
+        ''
+          runHook preBuild
+          cat >> config/config.nims << WTF
+
+          switch("os", "${nimTarget.os}")
+          switch("cpu", "${nimTarget.cpu}")
+          switch("define", "nixbuild")
+
+          # Configure the compiler using the $CC set by Nix at build time
+          import strutils
+          let cc = getEnv"CC"
+          if cc.contains("gcc"):
+            switch("cc", "gcc")
+          elif cc.contains("clang"):
+            switch("cc", "clang")
+          WTF
+
+          mv config/nim.cfg config/nim.cfg.old
+          cat > config/nim.cfg << WTF
+          os = "${nimTarget.os}"
+          cpu =  "${nimTarget.cpu}"
+          define:"nixbuild"
+          WTF
+
+          cat >> config/nim.cfg < config/nim.cfg.old
+          rm config/nim.cfg.old
+
+          cat >> config/nim.cfg << WTF
+
+          clang.cpp.exe %= "\$CXX"
+          clang.cpp.linkerexe %= "\$CXX"
+          clang.exe %= "\$CC"
+          clang.linkerexe %= "\$CC"
+          gcc.cpp.exe %= "\$CXX"
+          gcc.cpp.linkerexe %= "\$CXX"
+          gcc.exe %= "\$CC"
+          gcc.linkerexe %= "\$CC"
+          WTF
+
+          runHook postBuild
+        '';
+
+      wrapperArgs = [
+        "--prefix PATH : ${lib.makeBinPath [ buildPackages.gdb ]}:${
+          placeholder "out"
+        }/bin"
+        # Used by nim-gdb
+
+        "--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ openssl pcre ]}"
+        # These libraries may be referred to by the standard library.
+        # This is broken for cross-compilation because the package
+        # set will be shifted back by nativeBuildInputs.
+
+        "--set NIM_CONFIG_PATH ${placeholder "out"}/etc/nim"
+        # Use the custom configuration
+
+        ''--set NIX_HARDENING_ENABLE "''${NIX_HARDENING_ENABLE/fortify}"''
+        # Fortify hardening appends -O2 to gcc flags which is unwanted for unoptimized nim builds.
+      ];
+
+      installPhase = ''
+        runHook preInstall
+
+        mkdir -p $out/bin $out/etc
+
+        cp -r config $out/etc/nim
+
+        for binpath in ${nim'}/bin/nim?*; do
+          local binname=`basename $binpath`
+          makeWrapper \
+            $binpath $out/bin/${targetPlatform.config}-$binname \
+            $wrapperArgs
+          ln -s $out/bin/${targetPlatform.config}-$binname $out/bin/$binname
+        done
 
-      cp -r config $out/etc/nim
+        makeWrapper \
+          ${nim'}/nim/bin/nim $out/bin/${targetPlatform.config}-nim \
+          --set-default CC $(command -v $CC) \
+          --set-default CXX $(command -v $CXX) \
+          $wrapperArgs
+        ln -s $out/bin/${targetPlatform.config}-nim $out/bin/nim
 
-      for binpath in ${nim'}/bin/nim?*; do
-        local binname=`basename $binpath`
         makeWrapper \
-          $binpath $out/bin/${targetPlatform.config}-$binname \
+          ${nim'}/bin/testament $out/bin/${targetPlatform.config}-testament \
           $wrapperArgs
-        ln -s $out/bin/${targetPlatform.config}-$binname $out/bin/$binname
-      done
-
-      makeWrapper \
-        ${nim'}/nim/bin/nim $out/bin/${targetPlatform.config}-nim \
-        --set-default CC $(command -v $CC) \
-        --set-default CXX $(command -v $CXX) \
-        $wrapperArgs
-      ln -s $out/bin/${targetPlatform.config}-nim $out/bin/nim
-
-      makeWrapper \
-        ${nim'}/bin/testament $out/bin/${targetPlatform.config}-testament \
-        $wrapperArgs
-      ln -s $out/bin/${targetPlatform.config}-testament $out/bin/testament
-
-      makeWrapper \
-        ${nimble'}/bin/nimble $out/bin/${targetPlatform.config}-nimble \
-        --suffix PATH : $out/bin
-      ln -s $out/bin/${targetPlatform.config}-nimble $out/bin/nimble
+        ln -s $out/bin/${targetPlatform.config}-testament $out/bin/testament
 
-      runHook postInstall
-    '';
+        makeWrapper \
+          ${nimble'}/bin/nimble $out/bin/${targetPlatform.config}-nimble \
+          --suffix PATH : $out/bin
+        ln -s $out/bin/${targetPlatform.config}-nimble $out/bin/nimble
 
-    passthru = {
-      nim = nim';
-      nimble = nimble';
-    };
+        runHook postInstall
+      '';
+
+      passthru = {
+        nim = nim';
+        nimble = nimble';
+      };
 
-    meta = nim'.meta // {
-      description = nim'.meta.description
-        + " (${targetPlatform.config} wrapper)";
-      platforms = with lib.platforms; unix ++ genode;
+      meta = nim'.meta // {
+        description = nim'.meta.description
+          + " (${targetPlatform.config} wrapper)";
+        platforms = with lib.platforms; unix ++ genode;
+      };
     };
+  in self // {
+    pkgs = callPackage ../../../top-level/nim-packages.nix { nim = self; };
   };
 
 }