nix icon indicating copy to clipboard operation
nix copied to clipboard

support activation/migration workflows for profile upgrades/installs

Open RonnyPfannschmidt opened this issue 3 years ago • 2 comments

Is your feature request related to a problem? Please describe.

both nixos-rebuild and home-manager use profiles that need to be activates on upgrade to ensure the imperative world they are embedded converges to the reality the profile wants that to be like,

currently installation/activation seem foreign as they manage state in a "non-pure world"

it would be a great help for state management if activation/upgrades could be integrated with applications/services in a way that allows profile upgrades to contain updates/backups/migrations that can be rolled back safely.

This would also help for details like upgrading/installing applications/services that need user state

Describe the solution you'd like

nix profile install/upgrade myflake#someapp/someprofile being able to run upgrades/activation scripts nixos-rebuild-switch/test/boot` as well as home-manager being able to build on a higher level primitive instead of nix profile set + running scripts

part of this may require creating a formal convention to manage the difference between "activation packages" and installed environments that are currently active so that nixos-rebuild and home-manager converge

Describe alternatives you've considered own shell scripts, unfortunately that makes things brittle as nix is no longer aware of migrations/updates that way

Additional context related #6349 - home manager needing to replicate nix-env --set on top of nix profile install

RonnyPfannschmidt avatar Sep 17 '22 10:09 RonnyPfannschmidt

How should this operate? What to do when the script fails? Does the profile switch before or after activation? Should nix even have an answer for these questions?

nixos-rebuild is quite an elaborate script and I am not convinced that its behavior can fit into the nix profile command nicely. Doing so makes it harder for NixOS to improve when it comes to such things as rollback behavior.

Perhaps nix profile activate should behave like no more than nix run <installable>.config.activate.command? That way the expression remains in control of the particular way activation happens and when the change is persisted.

roberth avatar Sep 21 '22 00:09 roberth

Indeed, a better definition of activation, delayed activation, testing without persistence is needed

It would be very nice if applications /backups, database migration could be integrated in a set of common workflows for profiles

RonnyPfannschmidt avatar Sep 21 '22 07:09 RonnyPfannschmidt