-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
30 lines (24 loc) · 945 Bytes
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
let rust-overlay = builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz";
in { pkgs ? import <nixpkgs> { overlays = [ (import rust-overlay) ]; }}:
let
arch = builtins.elemAt (builtins.split "-" pkgs.system) 0;
target = "${arch}-unknown-linux-musl";
toolchain =
pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override { targets = [ target ]; });
rustPlatform = pkgs.makeRustPlatform { cargo = toolchain; rustc = toolchain; };
in rustPlatform.buildRustPackage rec {
pname = "fhsenv";
version = "0.1.0";
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
buildPhase = ''
export RUSTFLAGS='-C target-feature=+crt-static' # enable static linking
cargo build --release --target ${target}
'';
installPhase = ''
mkdir -p $out/bin
mv ./target/${target}/release/fhsenv $out/bin
'';
doCheck = false;
shellHook = ''PS1="\[\e[1;32m\]\u \W> \[\e[0m\]"'';
}