i want to fix a NixOS module. What is the best workflow to test your changes without messing up your system? I’m on NixOS stable and fear, that switching it to master will break programs, that rely on state, like Chromium session.
It would also be great to document it, to make contributing easier.
I think fixing the NixOS module by developing a NixOS test (and iterating on that) is a good idea. Doing it like that doesn’t affect your (stable) system at all.
With a NixOS test in place you can also bring up the VMs defined in the test interactively and experiment a bit, until the test is fully developed.
You can also use
nixos-rebuild build-vm -I nixpkgs=path/to/nixpkgs/checkout -I nixos-config=path/to/configuration.nix to build a virtual machine.
I don’t know if you’ve already considered it but you can very well add or replace a single module in your “stable” nixos configuration. Steps here:
[Question] How to enable a service from a different channel · Issue #41212 · NixOS/nixpkgs · GitHub
It’s a slightly complex module because of two services, but you might want to peruse #77734 PR on github to see how easy a module is (it’s just another nix file where you define the interface’s options by just defining some nix attributes)
Its the cheapest way in terms of effort. @bjornfor’s approach is probably better in most other ways.
If you don’t need to deal with kernel stuff you can also use containers, I like to use extra-container, but I haven’t tried any other platforms. The NixOS tests option also sounds good because you can merge things upstream, but I’ve never used that myself either. The VM option is also certainly interesting - I’ve used it to test a disk I was migrating while in a live system, so I didn’t need to reboot constantly.
It’s probably good to get experience with all three.