summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.rst7
-rw-r--r--nix/overlay/development.nix2
-rw-r--r--nix/package/dev-shell.nix2
-rw-r--r--nix/package/mark-darcs-weak-hash.nix26
-rw-r--r--script/mk-darcs-weak-hash4
5 files changed, 33 insertions, 8 deletions
diff --git a/README.rst b/README.rst
index b8c2062..334e138 100644
--- a/README.rst
+++ b/README.rst
@@ -206,14 +206,13 @@ Darcs hooks (can skip)
.. code:: console
- $ chmod +x script/mk-darcs-weak-hash
$ $EDITOR _darcs/prefs/defaults
.. code::
- apply posthook script/mk-darcs-weak-hash && nix-build --no-out-link release.nix
- obliterate posthook script/mk-darcs-weak-hash
- record posthook script/mk-darcs-weak-hash
+ apply posthook nix-shell --run mk-darcs-weak-hash && nix-build --no-out-link release.nix
+ obliterate posthook nix-shell --run mk-darcs-weak-hash
+ record posthook nix-shell --run mk-darcs-weak-hash
Hooks here can:
• Build the entire project before applying patches to make sure it works.
diff --git a/nix/overlay/development.nix b/nix/overlay/development.nix
index b414597..c956556 100644
--- a/nix/overlay/development.nix
+++ b/nix/overlay/development.nix
@@ -7,6 +7,8 @@ final: prev: {
final': prev': {
dev-shell = final'.callPackage ../package/dev-shell.nix { };
+ mark-darcs-weak-hash = final'.callPackage ../package/mark-darcs-weak-hash.nix { };
+
nixfmt-3-space = final'.callPackage ../package/nixfmt-3-space.nix { };
ocamlformat-rpc-bin = final'.callPackage ../package/ocamlformat-rpc-bin.nix { };
diff --git a/nix/package/dev-shell.nix b/nix/package/dev-shell.nix
index 77a9ac1..3cfec5c 100644
--- a/nix/package/dev-shell.nix
+++ b/nix/package/dev-shell.nix
@@ -7,6 +7,7 @@
kdlfmt,
topiary,
ocamlPackages,
+ mark-darcs-weak-hash,
nixtamal,
nixfmt-3-space,
ocamlformat-rpc-bin,
@@ -19,6 +20,7 @@ mkShell {
];
packages = [
kdlfmt
+ mark-darcs-weak-hash
nixfmt-3-space
topiary
diff --git a/nix/package/mark-darcs-weak-hash.nix b/nix/package/mark-darcs-weak-hash.nix
new file mode 100644
index 0000000..7f644e1
--- /dev/null
+++ b/nix/package/mark-darcs-weak-hash.nix
@@ -0,0 +1,26 @@
+#──────────────────────────────────────────────────────────────────────────────┐
+# SPDX-FileCopyrightText: 2025 toastal <https://toast.al/contact/> │
+# SPDX-License-Identifier: LGPL-2.1-or-later │
+#──────────────────────────────────────────────────────────────────────────────┘
+{
+ lib,
+ writeDashBinScript,
+ darcs,
+ gawk,
+}:
+
+let
+ path = lib.makeBinPath [
+ darcs
+ gawk
+ ];
+in
+writeDashBinScript {
+ name = "mark-darcs-weak-hash";
+ text = /* sh */ ''
+ export PATH="${path}:$PATH"
+
+ darcs show repo \
+ | awk '/^[[:space:]]*Weak Hash:/ { sub(/^[[:space:]]*Weak Hash:[[:space:]]*/, "", $0); printf $0 }' > "$PWD/_darcs/weak_hash"
+ '';
+}
diff --git a/script/mk-darcs-weak-hash b/script/mk-darcs-weak-hash
deleted file mode 100644
index 0836354..0000000
--- a/script/mk-darcs-weak-hash
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/usr/bin/env dash
-base_dir=$(cd -- "$(dirname -- "$0")/.." && pwd)
-darcs show repo \
- | awk '/^[[:space:]]*Weak Hash:/ { sub(/^[[:space:]]*Weak Hash:[[:space:]]*/, "", $0); printf $0 }' > "$base_dir/_darcs/weak_hash"