-
-
Notifications
You must be signed in to change notification settings - Fork 15k
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/udev: systemd initrd improvements #171021
nixos/udev: systemd initrd improvements #171021
Conversation
First, add the builtin udev rules to /etc/udev/rules.d so they are used. Then, add all networkd .link units to the initrd. This is done in the old stage 1 as well so I assume this is needed even when networkd is not used. I assume this is for things like changing the MAC address. Also limit the number of udev/lib binaries that is put into the initrd because the old initrd doesn't use all units either.
Correct .link units are part of udev. Not networkd. This is also pointed
out in the manpage systemd.link
…On Sat, 30 Apr 2022, 14:20 Janne Heß, ***@***.***> wrote:
@dasJ <https://github.com/dasJ> requested your review on: #171021
<#171021> nixos/udev: systemd initrd
improvements.
—
Reply to this email directly, view it on GitHub
<#171021 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEZNI422ANJCAQ3ERV2KSDVHUQQPANCNFSM5UYJD4LQ>
.
You are receiving this because your review was requested.Message ID:
***@***.***>
|
We'd probably have to move these to the network module if it exists because |
# This must be done in stage 1 to avoid race conditions between udev and | ||
# network daemons. | ||
# TODO move this into the initrd-network module when it exists | ||
initrdLinkUnits = pkgs.runCommand "initrd-link-units" {} '' |
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.
I don't understand this. We don't have to do this in the old initrd, why should we have to with this one?
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.
I just don't think we did link files in the old initrd. i.e. predictible interface names were not used.
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.
But can't we use the initrd.systemd.units
logic for this?
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.
@arianvp That would place units in /etc/systemd/system
, not in /etc/systemd/network
.
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.
ah yes; but we have similar logic in the networkd
module in stage-2. Perhaps we want to copy that to stage-1
under initrd.systemd.network.links
? (https://search.nixos.org/options?channel=21.11&show=systemd.network.links&from=0&size=50&sort=relevance&type=packages&query=systemd.network.links)
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.
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.
So. we can keep this workaround for now; and then clean it up later once that PR is ready? Must just make sure to not forget.
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.
@ElvishJerricco we do this because the code was actually in the old stage 1 as well ;) It's not a new invention.
Old code:
nixpkgs/nixos/modules/system/boot/stage-1.nix
Lines 223 to 235 in b991bbd
linkUnits = pkgs.runCommand "link-units" { | |
allowedReferences = [ extraUtils ]; | |
preferLocalBuild = true; | |
} ('' | |
mkdir -p $out | |
cp -v ${udev}/lib/systemd/network/*.link $out/ | |
'' + ( | |
let | |
links = filterAttrs (n: v: hasSuffix ".link" n) config.systemd.network.units; | |
files = mapAttrsToList (n: v: "${v.unit}/${n}") links; | |
in | |
concatMapStringsSep "\n" (file: "cp -v ${file} $out/") files | |
)); |
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.
Oh, heh cool. So yea, keep this, and revisit whenever we actually want to take that networkd patch seriously.
First, add the builtin udev rules to /etc/udev/rules.d so they are used.
Then, add all networkd .link units to the initrd. This is done in the
old stage 1 as well so I assume this is needed even when networkd is not
used. I assume this is for things like changing the MAC address.
Also limit the number of udev/lib binaries that is put into the initrd
because the old initrd doesn't use all units either.
Description of changes
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)nixos/doc/manual/md-to-db.sh
to update generated release notes