Skip to content
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/switch-to-configuration: Rework activation script restarts #150859

Conversation

dasJ
Copy link
Member

@dasJ dasJ commented Dec 15, 2021

Motivation for this change

This was the actual reason I started touching stc.
Instead of expecting the activation scripts to differentiate between restarting and reloading, do this in stc now.
This shouldn't be a too disruptive change since the only user of that interface I know of is sops-nix and that is already using the new interface.

Should also streamline things to make #49528 easier to fix in the future.

Also test the new behaviour.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.05 Release Notes (or backporting 21.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` labels Dec 15, 2021
@dasJ dasJ requested review from ajs124 and stigtsp December 15, 2021 15:21
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Dec 15, 2021
@dasJ dasJ force-pushed the feat/redo-restart-by-activation-script branch from eeba8b0 to 5cdbf6e Compare December 15, 2021 17:44
@wamserma wamserma removed their request for review December 16, 2021 06:37
Copy link
Member

@primeos primeos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The concept/idea sounds good to me (although I should note that I'm not familiar with that interface) and the diff seems to be fine. I really like that this makes that interface less "dangerous" and transfers the decision logic back to the normal NixOS logic handleModifiedUnit. So +1 for this change :) (Release notes entry and tests already included <3)

That said I must admit that I find the commit message really lacking, even for our low(?) Nixpkgs standards (normally that'd be a hard NAK for me). Would you mind explaining the reasoning in a few sentences? It doesn't have to be perfect but otherwise someone looking at the Git history in the future will have no idea why this change was made (or what it even does - without looking at the diff), etc. See also https://cbea.ms/git-commit/#seven-rules.

@dasJ dasJ force-pushed the feat/redo-restart-by-activation-script branch from 5cdbf6e to 2277f82 Compare January 5, 2022 12:05
@dasJ
Copy link
Member Author

dasJ commented Jan 5, 2022

Done and rebased due to merge conflicts

@dasJ
Copy link
Member Author

dasJ commented Jan 5, 2022

@GrahamcOfBorg test switchTest

@dasJ
Copy link
Member Author

dasJ commented Jan 14, 2022

Any more comments? If not I think this is ready to merge

Copy link
Member

@lovesegfault lovesegfault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good :)

}

my $baseName = $baseUnit;
$baseName =~ s/\.[a-z]*$//;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe File::Basename::basename would be safer. (It's in core)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying this but this isn't really the basename we both were thinking ;) It's doing /a/b/c.service/a/b/c and not the classic basename

This removes `/run/nixos/activation-reload-list` (which we will need in
the future when reworking the reload logic) and makes
`/run/nixos/activation-restart-list` honor `restartIfChanged` and
`reloadIfChanged`. This way activation scripts don't have to bother with
choosing between reloading and restarting.
@dasJ dasJ force-pushed the feat/redo-restart-by-activation-script branch from 2277f82 to 2cf157c Compare January 17, 2022 17:00
@lovesegfault lovesegfault merged commit eaf7be0 into NixOS:master Jan 17, 2022
@ajs124 ajs124 deleted the feat/redo-restart-by-activation-script branch January 17, 2022 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants