summary refs log tree commit diff
path: root/pkgs/build-support/writers
diff options
context:
space:
mode:
authorDominik Xaver Hörl <hoe.dom@gmx.de>2021-01-11 22:14:33 +0100
committerDominik Xaver Hörl <hoe.dom@gmx.de>2021-01-12 09:20:31 +0100
commitc6ff4f7143fc3b45c523ec6b77c0420aad4c8873 (patch)
tree6f30d78abe9e535f0fe6ca4b18d3be28c101f65e /pkgs/build-support/writers
parente4dae65515fa70434359723d72d2da61de4872f8 (diff)
downloadnixpkgs-c6ff4f7143fc3b45c523ec6b77c0420aad4c8873.tar
nixpkgs-c6ff4f7143fc3b45c523ec6b77c0420aad4c8873.tar.gz
nixpkgs-c6ff4f7143fc3b45c523ec6b77c0420aad4c8873.tar.bz2
nixpkgs-c6ff4f7143fc3b45c523ec6b77c0420aad4c8873.tar.lz
nixpkgs-c6ff4f7143fc3b45c523ec6b77c0420aad4c8873.tar.xz
nixpkgs-c6ff4f7143fc3b45c523ec6b77c0420aad4c8873.tar.zst
nixpkgs-c6ff4f7143fc3b45c523ec6b77c0420aad4c8873.zip
writers: add rust
Diffstat (limited to 'pkgs/build-support/writers')
-rw-r--r--pkgs/build-support/writers/default.nix30
1 files changed, 26 insertions, 4 deletions
diff --git a/pkgs/build-support/writers/default.nix b/pkgs/build-support/writers/default.nix
index 5945dc42c20..89edbd513d5 100644
--- a/pkgs/build-support/writers/default.nix
+++ b/pkgs/build-support/writers/default.nix
@@ -76,8 +76,8 @@ rec {
       contentPath = content;
     }) ''
       ${compileScript}
-      ${ lib.optionalString strip
-         "${pkgs.binutils-unwrapped}/bin/strip --strip-unneeded $out" }
+      ${lib.optionalString strip
+         "${pkgs.binutils-unwrapped}/bin/strip --strip-unneeded $out"}
       ${optionalString (types.path.check nameOrPath) ''
         mv $out tmp
         mkdir -p $out/$(dirname "${nameOrPath}")
@@ -111,7 +111,10 @@ rec {
   #        return 0;
   #      }
   #    ''
-  writeC = name: { libraries ? [] }:
+  writeC = name: {
+    libraries ? [],
+    strip ? true
+  }:
     makeBinWriter {
       compileScript = ''
         PATH=${makeBinPath [
@@ -134,6 +137,7 @@ rec {
             -x c \
             "$contentPath"
       '';
+      inherit strip;
     } name;
 
   # writeCBin takes the same arguments as writeC but outputs a directory (like writeScriptBin)
@@ -166,7 +170,8 @@ rec {
   writeHaskell = name: {
     libraries ? [],
     ghc ? pkgs.ghc,
-    ghcArgs ? []
+    ghcArgs ? [],
+    strip ? true
   }:
     makeBinWriter {
       compileScript = ''
@@ -174,12 +179,29 @@ rec {
         ${ghc.withPackages (_: libraries )}/bin/ghc ${lib.escapeShellArgs ghcArgs} tmp.hs
         mv tmp $out
       '';
+      inherit strip;
     } name;
 
   # writeHaskellBin takes the same arguments as writeHaskell but outputs a directory (like writeScriptBin)
   writeHaskellBin = name:
     writeHaskell "/bin/${name}";
 
+  writeRust = name: {
+      rustc ? pkgs.rustc,
+      rustcArgs ? [],
+      strip ? true
+  }:
+    makeBinWriter {
+      compileScript = ''
+        cp "$contentPath" tmp.rs
+        PATH=${makeBinPath [pkgs.gcc]} ${lib.getBin rustc}/bin/rustc ${lib.escapeShellArgs rustcArgs} -o "$out" tmp.rs
+      '';
+      inherit strip;
+    } name;
+
+  writeRustBin = name:
+    writeRust "/bin/${name}";
+
   # writeJS takes a name an attributeset with libraries and some JavaScript sourcecode and
   # returns an executable
   #