diff --git a/default.nix b/default.nix index b156e15a..04d4da6c 100644 --- a/default.nix +++ b/default.nix @@ -1,4 +1,4 @@ -{ pkgs ? import { } }: +{ pkgs ? import {}, gitSha }: pkgs.rustPlatform.buildRustPackage { pname = "amp"; version = "0.7.0"; @@ -13,8 +13,26 @@ # Packages needed during the build nativeBuildInputs = with pkgs; [ git ]; + # Make the build/check/install commands explicit so we can + # provide the commit SHA for the splash screen + buildPhase = '' + export BUILD_REVISION=${builtins.substring 0 7 gitSha} + echo "BUILD_REVISION=$BUILD_REVISION" + + cargo build --release + ''; + + checkPhase = '' + cargo test + ''; + + installPhase = '' + mkdir -p $out/bin + cp target/release/amp $out/bin/ + ''; + # Amp creates files and directories in $HOME/.config/amp when run. # Since the checkPhase of the build process runs the test suite, we # need a writable location to avoid permission error test failures. - HOME="$out"; + HOME="$src"; } diff --git a/flake.nix b/flake.nix index 7d9df7a4..c8c659f6 100644 --- a/flake.nix +++ b/flake.nix @@ -12,7 +12,7 @@ pkgsFor = nixpkgs.legacyPackages; in { packages = forAllSystems (system: { - default = pkgsFor.${system}.callPackage ./. { }; + default = pkgsFor.${system}.callPackage ./. { gitSha = self.rev; }; }); }; }