about summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2023-07-17 18:01:56 +0000
committerGitHub <noreply@github.com>2023-07-17 18:01:56 +0000
commit8717af0ce1d26210b62e2641549e0f6e1089c530 (patch)
treef125e45ebde3f83082e1418dd4d7805e80a0c461 /pkgs/build-support
parent14016f3852cda9ed7dd23ef5c8f5a49bd3a4db8b (diff)
parent342b5f4f7b2a7175bf7857cf8e048e8cbdc90a94 (diff)
Merge staging-next into staging
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/fetchpijul/default.nix56
1 files changed, 56 insertions, 0 deletions
diff --git a/pkgs/build-support/fetchpijul/default.nix b/pkgs/build-support/fetchpijul/default.nix
new file mode 100644
index 0000000000000..ca7e1a7926e80
--- /dev/null
+++ b/pkgs/build-support/fetchpijul/default.nix
@@ -0,0 +1,56 @@
+{ lib, stdenvNoCC, pijul }:
+
+lib.makeOverridable (
+{ url
+, hash ? ""
+, change ? null
+, state ? null
+, channel ? "main"
+, name ? "fetchpijul"
+, # TODO: Changes in pijul are unordered so there's many ways to end up with the same repository state.
+  # This makes leaveDotPijul unfeasible to implement until pijul CLI implements
+  # a way of reordering changes to sort them in a consistent and deterministic manner.
+  # leaveDotPijul ? false
+}:
+if change != null && state != null then
+  throw "Only one of 'change' or 'state' can be set"
+else
+  stdenvNoCC.mkDerivation {
+    inherit name;
+    nativeBuildInputs = [ pijul ];
+
+    dontUnpack = true;
+    dontConfigure = true;
+    dontBuild = true;
+
+    installPhase = ''
+      runHook preInstall
+
+      pijul clone \
+        ''${change:+--change "$change"} \
+        ''${state:+--state "$state"} \
+        --channel "$channel" \
+        "$url" \
+        "$out"
+
+      runHook postInstall
+    '';
+
+    fixupPhase = ''
+      runHook preFixup
+
+      rm -rf "$out/.pijul"
+
+      runHook postFixup
+    '';
+
+    outputHashAlgo = if hash != "" then null else "sha256";
+    outputHashMode = "recursive";
+    outputHash = if hash != "" then
+      hash
+    else
+      lib.fakeSha256;
+
+    inherit url change state channel;
+  }
+)