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/system: make switch-to-configuration script pure #31805

Merged
merged 2 commits into from Nov 19, 2017

Conversation

gleber
Copy link
Contributor

@gleber gleber commented Nov 18, 2017

Fixes #28443

Fixed few invocations to systemctl to have an absolute path. Additionally add
LOCALE_ARCHIVE so that perl stops spewing warning messages.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@gleber
Copy link
Contributor Author

gleber commented Nov 18, 2017

@FRidh, please take a look. Especially if the added test is the right way to test it.

@gleber
Copy link
Contributor Author

gleber commented Nov 18, 2017

@phile314 FYI

@@ -83,6 +82,7 @@ let
done

mkdir $out/bin
export localeArchive=${lib.optionalString (pkgs.stdenv.isLinux or false) "${pkgs.glibcLocales}/lib/locale/locale-archive"}
Copy link
Contributor

Choose a reason for hiding this comment

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

This should use "${config.i18n.glibcLocales}/lib/locale/locale-archive" so the NixOS locale configuration options are respected.

And no need to make conditional for Linux.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -65,7 +69,7 @@
sub getActiveUnits {
# FIXME: use D-Bus or whatever to query this, since parsing the
# output of list-units is likely to break.
my $lines = `LANG= systemctl list-units --full --no-legend`;
my $lines = `LANG= @systemd@/bin/systemctl list-units --full --no-legend`;
Copy link
Contributor

Choose a reason for hiding this comment

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

It worries me a bit what will happen if the systemd version used here doesn't match the running systemd.

Perhaps use /run/current-system/sw/bin/systemctl here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps use /run/current-system/sw/bin/systemctl here.

If doing that, please add a comment above that command line saying why.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are many spots in this file which use @systemd@/bin/systemctl already. Do you think I should switch all of them?

Copy link
Contributor

Choose a reason for hiding this comment

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

AFAICT all of them (except one systemd-escape call, which presumably doesn't need to contact the daemon anyway) are run for the purposes of talking to the upgraded systemd, so those ones should be correct.

Although, at that point the activation script has been run and changed /run/current-system to point to the new system (incl. the new systemd), so theoretically it would still work. But sounds somewhat magical to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In such a case, probably the best solution is to use result of sudo readlink /proc/1/exe to get absolute path to previous systemctl and use it before the daemon-reexec command, and after the call use @systemd@/bin/systemctl path. I'll make it so.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nah, this is too complex for very little benefit. I will just use /run/current-system/sw/bin/systemctl before the daemon-rexec call

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@gleber
Copy link
Contributor Author

gleber commented Nov 19, 2017

Please take another look.

@gleber gleber force-pushed the make-switch-to-configuration-pure branch from ac383ce to e72bf2d Compare November 19, 2017 14:33
# Mutable users tests.

import ./make-test.nix ({ pkgs, ...} : {
name = "mutable-users";
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably not the name you intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch.

A more important question: do you think a separate test like this is useful?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure to be honest.

Fixes NixOS#28443

Fixed few invocations to `systemctl` to have an absolute path. Additionally add
LOCALE_ARCHIVE so that perl stops spewing warning messages.
@gleber gleber force-pushed the make-switch-to-configuration-pure branch from e72bf2d to 2f6148c Compare November 19, 2017 18:43
@obadz
Copy link
Contributor

obadz commented Nov 19, 2017

I don't have a complete grip of this change, but it looks overall good to me.

@gleber
Copy link
Contributor Author

gleber commented Nov 19, 2017

@fpletz Added the test to release.nix and release-combined.nix.

@obadz obadz merged commit edcf51a into NixOS:master Nov 19, 2017
@gleber gleber deleted the make-switch-to-configuration-pure branch November 19, 2017 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants