* [PATCH] Add wrapper scripts to run make in a Nix shell
@ 2025-08-07 18:50 Demi Marie Obenour
2025-08-08 15:00 ` Alyssa Ross
0 siblings, 1 reply; 6+ messages in thread
From: Demi Marie Obenour @ 2025-08-07 18:50 UTC (permalink / raw)
To: Spectrum OS Development; +Cc: Alyssa Ross, Demi Marie Obenour
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
--
Sincerely,
Demi Marie Obenour (she/her/hers)
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Add wrapper scripts to run make in a Nix shell
2025-08-07 18:50 [PATCH] Add wrapper scripts to run make in a Nix shell Demi Marie Obenour
@ 2025-08-08 15:00 ` Alyssa Ross
2025-08-08 17:32 ` Demi Marie Obenour
0 siblings, 1 reply; 6+ messages in thread
From: Alyssa Ross @ 2025-08-08 15:00 UTC (permalink / raw)
To: Demi Marie Obenour, Spectrum OS Development
[-- Attachment #1: Type: text/plain, Size: 630 bytes --]
Demi Marie Obenour <demiobenour@gmail.com> writes:
> 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.
I think you'd probably be better setting up nix-direnv or something. It
makes it so that you can't forget to be in the shell, but also means you
can just run make, rather than having to remember to run some other
script. It also comes with caching I think, so if that works you'll
probably save quite a bit of time over doing a Nix evaluation for every
make invocation.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Add wrapper scripts to run make in a Nix shell
2025-08-08 15:00 ` Alyssa Ross
@ 2025-08-08 17:32 ` Demi Marie Obenour
2025-08-08 18:02 ` Alyssa Ross
0 siblings, 1 reply; 6+ messages in thread
From: Demi Marie Obenour @ 2025-08-08 17:32 UTC (permalink / raw)
To: Alyssa Ross, Spectrum OS Development
[-- Attachment #1.1.1: Type: text/plain, Size: 1072 bytes --]
On 8/8/25 11:00, Alyssa Ross wrote:
> Demi Marie Obenour <demiobenour@gmail.com> writes:
>
>> 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.
>
> I think you'd probably be better setting up nix-direnv or something. It
> makes it so that you can't forget to be in the shell, but also means you
> can just run make, rather than having to remember to run some other
> script. It also comes with caching I think, so if that works you'll
> probably save quite a bit of time over doing a Nix evaluation for every
> make invocation.
For general development I agree, but unless nix-direnv always rebuilds
when needed I think wrappers like this might be better for scripted use.
The big advantage is that they guarantee the environment variables
passed to 'make' will always be up-to-date, and I'm not sure how to
achieve that in a script otherwise.
--
Sincerely,
Demi Marie Obenour (she/her/hers)
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 7253 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Add wrapper scripts to run make in a Nix shell
2025-08-08 17:32 ` Demi Marie Obenour
@ 2025-08-08 18:02 ` Alyssa Ross
2025-08-08 18:30 ` Demi Marie Obenour
0 siblings, 1 reply; 6+ messages in thread
From: Alyssa Ross @ 2025-08-08 18:02 UTC (permalink / raw)
To: Demi Marie Obenour, Spectrum OS Development
[-- Attachment #1: Type: text/plain, Size: 1173 bytes --]
Demi Marie Obenour <demiobenour@gmail.com> writes:
> On 8/8/25 11:00, Alyssa Ross wrote:
>> Demi Marie Obenour <demiobenour@gmail.com> writes:
>>
>>> 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.
>>
>> I think you'd probably be better setting up nix-direnv or something. It
>> makes it so that you can't forget to be in the shell, but also means you
>> can just run make, rather than having to remember to run some other
>> script. It also comes with caching I think, so if that works you'll
>> probably save quite a bit of time over doing a Nix evaluation for every
>> make invocation.
>
> For general development I agree, but unless nix-direnv always rebuilds
> when needed I think wrappers like this might be better for scripted use.
> The big advantage is that they guarantee the environment variables
> passed to 'make' will always be up-to-date, and I'm not sure how to
> achieve that in a script otherwise.
I think that's exactly what it does, but do correct me if I'm wrong.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Add wrapper scripts to run make in a Nix shell
2025-08-08 18:02 ` Alyssa Ross
@ 2025-08-08 18:30 ` Demi Marie Obenour
2025-08-08 18:36 ` Alyssa Ross
0 siblings, 1 reply; 6+ messages in thread
From: Demi Marie Obenour @ 2025-08-08 18:30 UTC (permalink / raw)
To: Alyssa Ross, Spectrum OS Development
[-- Attachment #1.1.1: Type: text/plain, Size: 1336 bytes --]
On 8/8/25 14:02, Alyssa Ross wrote:
> Demi Marie Obenour <demiobenour@gmail.com> writes:
>
>> On 8/8/25 11:00, Alyssa Ross wrote:
>>> Demi Marie Obenour <demiobenour@gmail.com> writes:
>>>
>>>> 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.
>>>
>>> I think you'd probably be better setting up nix-direnv or something. It
>>> makes it so that you can't forget to be in the shell, but also means you
>>> can just run make, rather than having to remember to run some other
>>> script. It also comes with caching I think, so if that works you'll
>>> probably save quite a bit of time over doing a Nix evaluation for every
>>> make invocation.
>>
>> For general development I agree, but unless nix-direnv always rebuilds
>> when needed I think wrappers like this might be better for scripted use.
>> The big advantage is that they guarantee the environment variables
>> passed to 'make' will always be up-to-date, and I'm not sure how to
>> achieve that in a script otherwise.
>
> I think that's exactly what it does, but do correct me if I'm wrong.
Is there a way to use nix-direnv from a script?
--
Sincerely,
Demi Marie Obenour (she/her/hers)
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 7253 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Add wrapper scripts to run make in a Nix shell
2025-08-08 18:30 ` Demi Marie Obenour
@ 2025-08-08 18:36 ` Alyssa Ross
0 siblings, 0 replies; 6+ messages in thread
From: Alyssa Ross @ 2025-08-08 18:36 UTC (permalink / raw)
To: Demi Marie Obenour, Spectrum OS Development
[-- Attachment #1: Type: text/plain, Size: 1506 bytes --]
Demi Marie Obenour <demiobenour@gmail.com> writes:
> On 8/8/25 14:02, Alyssa Ross wrote:
>> Demi Marie Obenour <demiobenour@gmail.com> writes:
>>
>>> On 8/8/25 11:00, Alyssa Ross wrote:
>>>> Demi Marie Obenour <demiobenour@gmail.com> writes:
>>>>
>>>>> 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.
>>>>
>>>> I think you'd probably be better setting up nix-direnv or something. It
>>>> makes it so that you can't forget to be in the shell, but also means you
>>>> can just run make, rather than having to remember to run some other
>>>> script. It also comes with caching I think, so if that works you'll
>>>> probably save quite a bit of time over doing a Nix evaluation for every
>>>> make invocation.
>>>
>>> For general development I agree, but unless nix-direnv always rebuilds
>>> when needed I think wrappers like this might be better for scripted use.
>>> The big advantage is that they guarantee the environment variables
>>> passed to 'make' will always be up-to-date, and I'm not sure how to
>>> achieve that in a script otherwise.
>>
>> I think that's exactly what it does, but do correct me if I'm wrong.
>
> Is there a way to use nix-direnv from a script?
direnv exec? But it's a relatively obscure thing to want to do, because
generally it makes it so you don't need to think about it…
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-08-08 18:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-07 18:50 [PATCH] Add wrapper scripts to run make in a Nix shell Demi Marie Obenour
2025-08-08 15:00 ` Alyssa Ross
2025-08-08 17:32 ` Demi Marie Obenour
2025-08-08 18:02 ` Alyssa Ross
2025-08-08 18:30 ` Demi Marie Obenour
2025-08-08 18:36 ` Alyssa Ross
Code repositories for project(s) associated with this public inbox
https://spectrum-os.org/git/crosvm
https://spectrum-os.org/git/doc
https://spectrum-os.org/git/mktuntap
https://spectrum-os.org/git/nixpkgs
https://spectrum-os.org/git/spectrum
https://spectrum-os.org/git/ucspi-vsock
https://spectrum-os.org/git/www
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).