-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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: add new implementation #308801
Conversation
211f98e
to
36f7214
Compare
6e2c9bb
to
deee302
Compare
@ofborg test switchTestNg |
deee302
to
8e920d6
Compare
@ofborg test switchTestNg |
Stellar work, thank you! I haven't looked at the Rust code in detail yet but scrolling over it quickly looked great. (Edit: The lack of One thing to keep in mind is the existence of #307562. Also, pretty much the last thing I wanted to do with Perl STC (apart from getting the sockets to work) was to port the fstab handling to the same logic the .mount unit uses. |
I did see that issue. I haven't tested against #307562 (comment) yet, but I'll do so shortly and paste the results. I started this PR as a 1-to-1 port of the perl code, so I'm "hoping" that this issue is also present in this PR, then they can be addressed together.
That sounds great, I believe the logic was if any of the mount options change (and nothing else changed), reload the unit, otherwise restart it?
Definitely no rush |
nixos/modules/system/activation/switch-to-configuration-ng/Cargo.toml
Outdated
Show resolved
Hide resolved
nixos/modules/system/activation/switch-to-configuration-ng/default.nix
Outdated
Show resolved
Hide resolved
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.
We should definitely split this file into multiple smaller ones.
8e920d6
to
6c333a3
Compare
@ofborg test switchTestNg |
6c333a3
to
1391794
Compare
We need to be very careful about rewriting fundamental parts of NixOS in Rust, because we're going to break NixOS on platforms that Rust doesn't support, but do have some committed NixOS users, like MIPS, which had a lot of work put into it over the last couple of years. (Most scripting languages don't have this problem, so something like Python might be a better fit, but compiled languages, especially those using LLVM, will.) |
This adds an implementation of switch-to-configuration that allows for closer interaction with the lifecycle of systemd units by using DBus APIs directly instead of using systemctl. It is disabled by default, but can be enabled by specifying `{ system.switch = { enable = false; enableNg = true; }; }`.
1391794
to
32bf051
Compare
@alyssais totally agree, though I would assume LLVM would give us great platform support? After fixing the derivation (using dbus interface definitions from |
Rust supports cross-compilation to more platforms than it supports running the compiler on, but the latter is what would be important for switch-to-configuration. Otherwise, we'd be completely removing the ability to switch configurations on those systems, since that system wouldn't be cross-compiled. So systems supported by Nixpkgs that would potentially lose out on being able to self-host NixOS from this change would be:
Some of these, like microblaze and s390, likely can't even build all of NixOS anyway. MIPS definitely has actual users (one use case I think is NixOS on a router, but I don't really know) and I'm pretty sure armv7 does too, although that might be armv7l and it wouldn't surprise me if most of those systems were cross-compiled. |
I run nixos on my armv7 router :) though I will admit I cross compile to it, as just doing an eval on it is too expensive. I guess it's important to narrow down the focus to the list of users that run on the platforms listed above that don't cross compile their systems, since users that do cross-compile would be fine. While I would personally be surprised if users were doing native builds on many of those platforms listed above, I don't have much knowledge outside of the arm and x86 space and I definitely don't want to make any arbitrary limits on the platforms nixos can be built from. |
I think MIPS64 is the main one to worry about. |
Is this even something to worry about? Afaik, NixOS has no official MIPS64 support and for these platforms I honestly think it would be okay to require cross-compilation. Also, while the new implementation is there now, it's still opt-in and I don't see why we wouldn't keep the old variant around for a bit after it has be come the default. This would also give the LLVM people more time (years probably) to fix the MIPS targets if they even intend doing so. |
It depends whether this would break anything for anybody in practice. I've drawn attention to this PR in places where users using those platforms are likely to be reachable (#exotic:nixos.org, #networking:nixos.org), and nobody has come forward, so it seems like that's a no, and so that's fine. It's just important to make sure of that when making this kind of decision. |
As written a bunch of times above, it's probably fine to introduce this additionally, even flip the default at some point. rustc platform support is gonna catch up at some point, and we can still keep the perl script around for these usecases - if people for these architectures really need it, they at some point need to step up with maintainership of the perl flavour. Having the activation script in something not-perl is such a long-term quality of life improvement, and empowers more people to fix it, so I'm heavily in favor of this. Thanks ❤️ |
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.
Less Perl in NixOS is definitely the way to go forward — following the footsteps of #270727 — and I'm excited to see how this will turn out!
Let's get this in - this is behind an explicit feature flag, so a no-op for anyone not explicitly enabling it. |
Fewer interpreters to reduce closure size, I hope you mean? :) Anyway, good effort on the rewrite @jmbaur! |
Using
|
I think the perl implementation also hangs if it has to wait for I include the following in my config to make the service log which interface it's waiting on:
|
Not for me, I tested it on both and the switch happened on the Perl implementation but hangs on this implementation. |
Made an issue here |
First: Great. I think the Perl-written key parts of NixOS are some of the weakest parts of it: Very difficult to read/understand, very easy to footgun. Now just Next: I recommend to make the following improvements to make this whole thing more likely to succeed:
|
Well, I just made a WIP port of |
Description of changes
This adds an implementation of switch-to-configuration that allows for closer interaction with the lifecycle of systemd units by using DBus APIs directly instead of using systemctl. It is disabled by default, but can be enabled by specifying
{ system.switch = { enable = false; enableNg = true; }; }
.The goal of this change is to provide an implementation of switch-to-configuration that is compatible (bug-for-bug, feature-for-feature) with the current perl script. This means that it is expected that all current NixOS VM tests under
./nixos/tests
will pass without any of the test scripts being modified. Assuming the changes here land, hopefully this implementation is found to be easier to maintain and more testable, allowing for easier modification of it in the future and eventually deprecation of the perl script.Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.