summaryrefslogtreecommitdiff
path: root/Biz/Bild.nix
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2022-07-14 01:45:28 -0400
committerBen Sima <ben@bsima.me>2022-07-17 19:21:12 -0400
commit7e59ce132303837b05aaa5f173ea2050ac0203f6 (patch)
treec815a868136e8d725e3d429f504e91fc05c34dd4 /Biz/Bild.nix
parent973e67f109f634ce347a1894628a8d551f0ccfbd (diff)
Add basic Rust support
Support for packages and third-party imports will need to come later once I figure out how to lookup rust packages by their import statements. Until then, this works to compile "hello world".
Diffstat (limited to 'Biz/Bild.nix')
-rw-r--r--Biz/Bild.nix21
1 files changed, 21 insertions, 0 deletions
diff --git a/Biz/Bild.nix b/Biz/Bild.nix
index b640a05..fdaba0e 100644
--- a/Biz/Bild.nix
+++ b/Biz/Bild.nix
@@ -153,6 +153,7 @@ in rec {
ormolu
python38Packages.black
python38Packages.pylint
+ rustc
shellcheck
wemux
] ++ lib.optional nixpkgs.stdenv.isLinux [
@@ -168,5 +169,25 @@ in rec {
pkgs = { inherit (nixpkgs) git; };
+ rust = main:
+ let
+ data = analyze main;
+ rustc = nixpkgs.pkgs.rustc;
+ in stdenv.mkDerivation {
+ name = lib.string.concatStringsSep "::" data.namespace.path;
+ src = ../.;
+ nativeBuildInputs = [ rustc ];
+ strictDeps = true;
+ buildPhase = ''
+ set -eux
+ mkdir -p $out/bin
+ : compiling with rustc
+ ${rustc}/bin/rustc \
+ ${main} \
+ -o $out/bin/${data.out}
+ '';
+ installPhase = "exit 0";
+ };
+
image = nixpkgs.pkgs.dockerTools.buildImage;
}