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

Alyssa Ross
2025-08-08T18:36:53Z

[-- 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…