this post was submitted on 24 Jan 2025
13 points (100.0% liked)

Nix / NixOS

1932 readers
1 users here now

Main links

Videos

founded 2 years ago
MODERATORS
 

I'm working on small nix flake to standardize the developer environments at my job.

What I'm still missing, however, is a way to clean up after leaving the shell. Some hook to call a shell script, when the shell is closed.

Is there something like this? I thought about wrapping the actual nix develop call inside a bash script and waiting for nix to terminate, but that seems rather hacky.

you are viewing a single comment's thread
view the rest of the comments
[โ€“] [email protected] 5 points 2 weeks ago (1 children)

If I'm not mistaken, everything in nix uses bash. So you should be able to use trap to catch the EXIT signal and execute a cleanup script. Here's a guide

Anti Commercial-AI license

[โ€“] [email protected] 4 points 2 weeks ago

Id never heard of trap. This is awesome! Thank you for sharing