diff options
author | rnhmjoj <rnhmjoj@inventati.org> | 2021-02-18 18:03:00 +0100 |
---|---|---|
committer | rnhmjoj <rnhmjoj@inventati.org> | 2021-02-18 22:07:00 +0100 |
commit | 65325292da4b653fa5cae1dd8a0547015cfc0205 (patch) | |
tree | 17833aff3bf2ae510f65d060cfff24bdc5f7db1f /nixos/modules/system/boot/stage-1.nix | |
parent | 15d6eacb1564c7c6467f9a50a91426000593dc33 (diff) | |
download | nixpkgs-65325292da4b653fa5cae1dd8a0547015cfc0205.tar nixpkgs-65325292da4b653fa5cae1dd8a0547015cfc0205.tar.gz nixpkgs-65325292da4b653fa5cae1dd8a0547015cfc0205.tar.bz2 nixpkgs-65325292da4b653fa5cae1dd8a0547015cfc0205.tar.lz nixpkgs-65325292da4b653fa5cae1dd8a0547015cfc0205.tar.xz nixpkgs-65325292da4b653fa5cae1dd8a0547015cfc0205.tar.zst nixpkgs-65325292da4b653fa5cae1dd8a0547015cfc0205.zip |
nixos/stage-1: install networkd link files
Renaming an interface must be done in stage-1: otherwise udev will report the interface as ready and network daemons (networkd, dhcpcd, etc.) will bring it up. Once up the interface can't be changed and the renaming will fail. Note: link files are read directly by udev, so they can be used even without networkd enabled.
Diffstat (limited to 'nixos/modules/system/boot/stage-1.nix')
-rw-r--r-- | nixos/modules/system/boot/stage-1.nix | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/nixos/modules/system/boot/stage-1.nix b/nixos/modules/system/boot/stage-1.nix index 44287f3cf09..4074f2e0235 100644 --- a/nixos/modules/system/boot/stage-1.nix +++ b/nixos/modules/system/boot/stage-1.nix @@ -205,13 +205,22 @@ let ''; # */ + # Networkd link files are used early by udev to set up interfaces early. + # This must be done in stage 1 to avoid race conditions between udev and + # network daemons. 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 + )); udevRules = pkgs.runCommand "udev-rules" { allowedReferences = [ extraUtils ]; |