NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.44k stars 13.64k forks source link

Feature Request: redeploying to interactive nixos tests #281332

Open Radvendii opened 8 months ago

Radvendii commented 8 months ago

Issue description

When developing NixOS tests, it is usually slow and tedious to re-run the test every time one makes a change. For this reason, I usually use driverInteractive, which allows me to muck around on the machines and see what happens in real time, re-run parts of tests that have failed, etc.

However, it often happens that I want to modify the NixOS configuration for one or more machines and redeploy. In this case I am back to re-running the driver every time I make a change.

I would like a way to modify the configuration and re-deploy, as I would with nixos-rebuild switch normally.

proposed solution

I developed a solution that I've been using privately #281331. It adds a command to the output of driverInteractive that can be used to push that configuration to the actively running test.

alternate solutions

we can just continue re-running the driver and restarting the machines every time we make a change to the configuration.

  1. this is slow and annoying

getting the configuration somehow into /etc/nixos/configuration.nix. This way people could modify the configuration on the machine and run nixos-rebuild switch.

  1. you have to generate a configuration.nix, and it's not clear which options to include and which not. It will end up in a different form than people are editing it in their test.
  2. the changes are ephemeral until you also make them on the test itself. which is easy to forget to do.

iterating on your tests in a separate environment (e.g. nixos-shell)

  1. requires copying changes over to the test, which is error-prone
  2. requires you to be familiar with two frameworks for spinning up nixos vms
  3. other systems for spinning up vms (such as nixos-rebuild) are often less convenient for spinning up several vms that all have access to each other
  4. the two systems for spinning up vms might have differences that affect the running of the tests.
Radvendii commented 8 months ago

See also https://github.com/fornybar/redpanda.nix, where we've been using my proposed solution

Radvendii commented 1 month ago

I've updated the PR to reflect a new solution. In retrospect I'm not sure it was useful to have a separate issue but here we are.