summary refs log tree commit diff
path: root/pkgs/games
diff options
context:
space:
mode:
authorMorgan Jones <me@numin.it>2023-11-05 13:34:58 -0800
committergithub-actions[bot] <github-actions[bot]@users.noreply.github.com>2023-11-27 00:03:57 +0000
commitd383e4489d35cfd93584be9f49a45931bcedf21c (patch)
tree80c3f444b430ecb47db09d7ffc042fde70750be7 /pkgs/games
parent5326135a50a833e86c1ad6acd02e1f81e27841dd (diff)
armagetronad: reproducible build by setting version
(cherry picked from commit 6f41e0b9aff319adc25ada9d41a5d8effae5ed79)
Diffstat (limited to 'pkgs/games')
-rw-r--r--pkgs/games/armagetronad/default.nix28
1 files changed, 27 insertions, 1 deletions
diff --git a/pkgs/games/armagetronad/default.nix b/pkgs/games/armagetronad/default.nix
index 3b406c6a8b50c..275b878d26199 100644
--- a/pkgs/games/armagetronad/default.nix
+++ b/pkgs/games/armagetronad/default.nix
@@ -79,6 +79,20 @@ let
   };
 
   mkArmagetron = { version, src, dedicatedServer ? false, extraBuildInputs ? [ ], extraNativeBuildInputs ? [ ] }@params:
+  let
+    # Split the version into the major and minor parts
+    versionParts = lib.splitString "-" version;
+    splitVersion = lib.splitString "." (builtins.elemAt versionParts 0);
+    majorVersion = builtins.concatStringsSep "." (lib.lists.take 2 splitVersion);
+
+    minorVersionPart =  parts: sep: expectedSize:
+      if builtins.length parts > expectedSize then
+        sep + (builtins.concatStringsSep sep (lib.lists.drop expectedSize parts))
+      else
+        "";
+
+    minorVersion = (minorVersionPart splitVersion "." 2) + (minorVersionPart versionParts "-" 1) + "-nixpkgs";
+  in
     stdenv.mkDerivation rec {
       pname = if dedicatedServer then "armagetronad-dedicated" else "armagetronad";
       inherit version src;
@@ -90,6 +104,11 @@ let
       preConfigure = ''
         patchShebangs .
 
+        # Create the version.
+        echo "${majorVersion}" > major_version
+        echo "${minorVersion}" > minor_version
+
+        echo "Bootstrapping version: $(<major_version)$(<minor_version)" >&2
         ./bootstrap.sh
       '';
 
@@ -115,9 +134,16 @@ let
       installCheckPhase = ''
         export XDG_RUNTIME_DIR=/tmp
         bin="$out/bin/${pname}"
+        version="$("$bin" --version || true)"
         prefix="$("$bin" --prefix || true)"
         rubber="$("$bin" --doc | grep -m1 CYCLE_RUBBER)"
-        if [ "$prefix" != "$out" ] || \
+
+        echo "Version: $version" >&2
+        echo "Prefix: $prefix" >&2
+        echo "Docstring: $rubber" >&2
+
+        if [[ "$version" != *"${version}"* ]] || \
+           [ "$prefix" != "$out" ] || \
            [[ ! "$rubber" =~ ^CYCLE_RUBBER[[:space:]]+Niceness[[:space:]]factor ]]; then
           exit 1
         fi