diff --git a/default.nix b/default.nix index b156e15a..bdff2b94 100644 --- a/default.nix +++ b/default.nix @@ -1,4 +1,4 @@ -{ pkgs ? import { } }: +{ pkgs ? import { }, gitSha ? "unknown" }: pkgs.rustPlatform.buildRustPackage { pname = "amp"; version = "0.7.0"; @@ -13,6 +13,13 @@ # Packages needed during the build nativeBuildInputs = with pkgs; [ git ]; + # Make the build command explicit so we can + # provide the commit SHA for the splash screen + buildPhase = '' + export BUILD_REVISION=${gitSha} + cargo build --release + ''; + # 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. diff --git a/flake.nix b/flake.nix index 7d9df7a4..76c78c16 100644 --- a/flake.nix +++ b/flake.nix @@ -5,14 +5,16 @@ nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; }; - outputs = { self, nixpkgs }: + outputs = { self, nixpkgs, ampSha ? "unknown" }: let supportedSystems = [ "x86_64-linux" ]; forAllSystems = nixpkgs.lib.genAttrs supportedSystems; pkgsFor = nixpkgs.legacyPackages; in { packages = forAllSystems (system: { - default = pkgsFor.${system}.callPackage ./. { }; + default = pkgsFor.${system}.callPackage ./. { + gitSha = ampSha; + }; }); }; }