Nix development environment? #766
Labels
No Label
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: borgmatic-collective/borgmatic#766
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I recently learned Nix (https://nixos.org/) and to work on the project, I created a Nix development environment which worked great for me. Perhaps it might be worth adding support for it, or just putting it in documentation? I uploaded the code on this branch: https://projects.torsion.org/pizzapim/borgmatic/src/branch/nix-dev-env
The idea is as follows: direnv (https://direnv.net/) automatically activates some environment which is specified in the
.envrc
file. This file in turn says to activate a Nix shell specified in theflake.nix
file. This Nix shell makes some programs available (Python 3.11, borgbackup) and Python libraries (apprise, pipx, tox, etc.) in an ephemeral shell. If you move out of this directory, the shell is unloaded are not longer available.Pull requests welcome! 😄 I don't know much about NixOS, but the only issue I see is that a particular NixOS version and a particular Python version are encoded in that flake.nix file. So that would just need to be kept up-to-date or somehow parameterized.
A question though: In this ephemeral shell, are state files like
.tox
left behind.. or deleted after use? Because if those are ephemeral too, then you'll have to recreate your Tox environment every time you work on borgmatic. Honestly, not the worst thing in the world, and it might actually be kind of useful so you don't have to know when to runtox -r
manually...If this were to get merged into borgmatic, I think there should be at least a mention on the borgmatic dev documentation page: https://torsion.org/borgmatic/docs/how-to/develop-on-borgmatic/
Yeah, I don't think there is a ready way to automate synchronization between
setup.py
and the Nix flake. So if any dependencies are updated, they would need to be updated in the flake configuration as well by hand. It's probably not worth the effort to support two different dev environments. I was maybe thinking of a small sidenote in the dev documentation page with an (unsupported) example setup instead?About your question: only the things specificed in flake.nix are ephemeral in the shell. Any side-effects like the
.tox
directory would remain after exiting the shell.Sorry for the delay here. Yes, an unsupported example or a link to a separate repository from the dev docs would be fine IMO. PRs welcome!
Closing this for now due to inactivity, but I'd be happy to revisit this if you'd still like to discuss!