[PATCH] Add wrapper scripts to run make in a Nix shell

Demi Marie Obenour
2025-08-07T18:51:57Z

It is very easy to forget to do this, and the results are confusing at
best and wrong at worst. Add wrapper scripts that get it right and also
automatically change to the correct directory for you.

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
---
host/initramfs/run-make.sh | 1 +
host/rootfs/run-make.sh | 1 +
img/app/run-make.sh | 1 +
release/live/run-make.sh | 1 +
scripts/run-make.sh | 12 ++++++++++++
tools/lseek/run-make.sh | 1 +
vm/sys/net/run-make.sh | 1 +
7 files changed, 18 insertions(+)

diff --git a/host/initramfs/run-make.sh b/host/initramfs/run-make.sh
new file mode 120000
index 0000000000000000000000000000000000000000..2142d230828768016cf5a4a59a895448ae3b12d9
--- /dev/null
+++ b/host/initramfs/run-make.sh
@@ -0,0 +1 @@
+../../scripts/run-make.sh
\ No newline at end of file
diff --git a/host/rootfs/run-make.sh b/host/rootfs/run-make.sh
new file mode 120000
index 0000000000000000000000000000000000000000..2142d230828768016cf5a4a59a895448ae3b12d9
--- /dev/null
+++ b/host/rootfs/run-make.sh
@@ -0,0 +1 @@
+../../scripts/run-make.sh
\ No newline at end of file
diff --git a/img/app/run-make.sh b/img/app/run-make.sh
new file mode 120000
index 0000000000000000000000000000000000000000..2142d230828768016cf5a4a59a895448ae3b12d9
--- /dev/null
+++ b/img/app/run-make.sh
@@ -0,0 +1 @@
+../../scripts/run-make.sh
\ No newline at end of file
diff --git a/release/live/run-make.sh b/release/live/run-make.sh
new file mode 120000
index 0000000000000000000000000000000000000000..2142d230828768016cf5a4a59a895448ae3b12d9
--- /dev/null
+++ b/release/live/run-make.sh
@@ -0,0 +1 @@
+../../scripts/run-make.sh
\ No newline at end of file
diff --git a/scripts/run-make.sh b/scripts/run-make.sh
new file mode 100755
index 0000000000000000000000000000000000000000..b865bb3461b5d3f192598d273cee278a76d0a6b7
--- /dev/null
+++ b/scripts/run-make.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/env -S bash --
+# SPDX-License-Identifier: CC0-1.0
+# SPDX-FileCopyrightText: 2025 Demi Marie Obenour <demiobenour@gmail.com>
+set -eu
+case $0 in (/*) cd "${0%/*}/";; (*/*) cd "./${0%/*}";; esac
+if [ ! -f shell.nix ] || [ ! -f Makefile ]; then
+ echo "Must have a shell.nix and a Makefile" >&2
+ exit 1
+fi
+cmd='exec make'
+for i; do cmd+=" '"${i//\'/\'\\\'\'}\'; done
+exec nix-shell --pure --run "$cmd"
diff --git a/tools/lseek/run-make.sh b/tools/lseek/run-make.sh
new file mode 120000
index 0000000000000000000000000000000000000000..2142d230828768016cf5a4a59a895448ae3b12d9
--- /dev/null
+++ b/tools/lseek/run-make.sh
@@ -0,0 +1 @@
+../../scripts/run-make.sh
\ No newline at end of file
diff --git a/vm/sys/net/run-make.sh b/vm/sys/net/run-make.sh
new file mode 120000
index 0000000000000000000000000000000000000000..38a7b0cf91ebf669e9794d91c6962cbe882de20f
--- /dev/null
+++ b/vm/sys/net/run-make.sh
@@ -0,0 +1 @@
+../../../scripts/run-make.sh
\ No newline at end of file

---
base-commit: 39baa378367d95fac6ce4d0140b25203b2ee9b53
change-id: 20250807-make-wrapper-scripts-77231ac0c0a7