From 7e59ce132303837b05aaa5f173ea2050ac0203f6 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Thu, 14 Jul 2022 01:45:28 -0400 Subject: 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". --- Biz/Bild.nix | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'Biz/Bild.nix') 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; } -- cgit v1.2.3