Another question is how to keep my packages up-to-date. I don’t do serious development work, thus I typically perfer my package and dev-tools to be on the latest version. I prefer to have a little management of this as possible. Ideally, every time I start up a nix shell, the package manager will grab the latest version of the package if possible without requiring additional interaction from me. Is this possible?
Definitely sounds like you should look into using https://direnv.net/. Once you direnv allow
the directory, as soon as you enter the directory it will create per-project isolated development environments.
The in the .envrc
file you could have something like:
nix flake update
use flake
If your using nix flakes which also imply you’re using git.
However, without flakes you could use a tool like:
And run their update command from the .envrc
Or if you don’t want to use direnv, then perhaps run a update command from the nix shellHook.
shellHook =
''
echo "Hello shell"
export SOME_API_TOKEN="$(cat ~/.config/some-app/api-token)"
'';
Sorry, I’m not sure about your last question.
Edit:
If you’re using git
and a forge like GitHub, then you could use a GitHub
action to automate the update and create a
PR. Such as a GH action like
https://github.com/DeterminateSystems/update-flake-lock
Personally, for projects I use direnv
+ flakes and that github action above,
but I can understand if you don’t want to mess with learning git.
There’s a bunch of tools that solve this problem.
https://github.com/direnv/direnv/wiki/Nix
In the link above check out the table in the “Some factors to consider” section. However, note that it hasn’t be updated since May 30, 2022. Many of those tools don’t depend on
direnv
if you don’t need its functionality.Personally, I use
direnv
and enablenix-direnv
using these options:https://search.nixos.org/options?channel=23.11&from=0&size=50&sort=relevance&type=packages&query=direnv
Here’s an example of how I use
direnv
withnix-direnv
.Edit: damn over wrote what I wrote to the first question with a response to the second question. Thank goodness for automatic file backups I have setup in Emacs.