New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos system-activation: support activation scripts run in a user context #47842
Conversation
@GrahamcOfBorg test plasma5 |
Success on aarch64-linux (full log) Attempted: tests.plasma5 Partial log (click to expand)
|
Success on x86_64-linux (full log) Attempted: tests.plasma5 Partial log (click to expand)
|
Should we add a test for this? |
We definitely should - any good ideas? |
This might be useful for things like home-manager/nixup ! |
Can we maybe encrypt the home directory and enable auto login? |
Hmmm, it almost works, but it looks like the activation scripts are always "one build behind" here. Here's my test setup: On top of 7f70ebf, applied the user-activation commit (e0e8874a8d0a55588d509641cf01c3c3d86ada65). My configuration is as such: {
system.userActivationScripts.annoy = ''
${pkgs.libnotify}/bin/notify-send -a nixos -t 5000 -u critical "AAA"
'';
} Before doing I'm rebuilding without the patch, rebooting and checking what it takes so it works at the first Update:
I don't know what it takes to make it "Active: active (waiting)", as even after a Though, once it is active, it will solidly activate with the previous generation's script! |
After a reboot, the service doesn't need any kind of massaging, but still seems to lag behind one generation. |
Yeah, probably because |
d36909d
to
4dada63
Compare
I just pushed some untested commits (I'll try them out now) that uses |
Quick update, before more in-depth testing it doesn't lag behind one generation anymore! Now testing a fresh boot without the change, if the the first switch works. |
And confirming that the changes (1353ba2 and 8118d6e) on 18.09 does activate right on first activation. Seems fine as far as I can tell (and can now annoy myself with notifications on rebuilds!) That feature is 👍 imho. |
So this is good to go despite the lack of tests? We really should have some (although I think the encryptfs test isn't relevant in this case) but it's of course your call if it's more important to ship 18.09 assuming this is the last pending blocker. |
I would prefer having tests for the feature; though I don't know how the testing infrastructure can be used to make this work since it seems to need a user session to be active (though I'm sure there's already good material in there). Do you have any idea on how to proceed with a test and the time to implement it at short notice? (DO NOT feel pressured!) Otherwise I feel like I have tested it right, and with the latest changes seems solid. With another pair of eyes looking at it and testing it I would be okay to merge without tests, hoping to later see tests pop into existence. (Which I would gladly adopt into backporting.) |
One way to do it would be to have the plasma test see if the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving after successful manual testing.
Code is minimal and looks fine to me.
It's also working fine for me in the last iteration. I'll open a separate PR for 18.09. |
Tests popping into existence: #113241 |
Motivation for this change
Some
system.activationScripts
are user specific but are run by root usingsu
. That causes a number of problems:stage-2-init
will try to activate the volume (and fail) during boot causing a hang until the user hits escape which isn't obvious if plymouth and KDE is enabledThere is now
system.userActivationScripts
which will be run by a systemd user service when$XDG_RUNTIME_DIR/.nixos-activate
is changed.We could easily use a different activation mechanism but the file based option chosen here is very straight forward.
I have tried it out here and tested as follows:
stage-2-init
errorsktorrent
toenvironment.systemPackages
nixos-rebuild switch
nixos-active.service
ran and as a consequencekbuildsycoca5
as wellktorrent
is now available in the menuI haven't gone through all the various activation scripts but there are likely more that should be moved to
system.userActivationScripts
.Fixes #47577. Supersedes #45290
Cc: @vcunat @samueldr
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)