NixOS (module) development workflow

Hello,

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.

1 Like

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.

1 Like

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:

https://github.com/NixOS/nixpkgs/issues/41212

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.

1 Like