Add given password for hosts/mermet/knot/sourcephile.fr/lebureau.conf to store.
[sourcephile-nix.git] / nixos / defaults / predictable-interface-names.nix
index ed1f366211887f6f63de9725b8dbb6166ffd321c..e81bca3999c70253ccc1142e173049825229d8be 100644 (file)
@@ -4,33 +4,29 @@
 # Tip: names that can be given using ID_NET_NAME_* envvars
 # can be checked before hand with:
 # udevadm test-builtin net_id /sys/class/net/*
+{ pkgs, ... }:
+let
+  udevNetSetupLinkRules = pkgs.writeTextDir "etc/udev/rules.d/79-net-setup-link.rules" ''
+    SUBSYSTEM!="net", GOTO="net_setup_link_end"
 
-{ pkgs, lib, config, ... }:
-let udevNetSetupLinkRules = pkgs.writeTextFile {
-    name = "80-net-setup-link.rules";
-    destination = "/etc/udev/rules.d/80-net-setup-link.rules";
-    text = ''
-      SUBSYSTEM!="net", GOTO="net_setup_link_end"
+    IMPORT{builtin}="path_id"
 
-      IMPORT{builtin}="path_id"
+    ACTION!="add", GOTO="net_setup_link_end"
 
-      ACTION!="add", GOTO="net_setup_link_end"
+    # Load net_setup_link to setup the ID_NET_NAME_* envvars
+    IMPORT{builtin}="net_setup_link"
 
-      # Load net_setup_link to setup the ID_NET_NAME_* envvars
-      IMPORT{builtin}="net_setup_link"
+    # Rename eth* using the "path" name policy (eg. enp1s0),
+    # Note that in stage-1 the envvar ID_NET_NAME is not set,
+    # hence not usable as in ''${pkgs.systemd}/lib/udev/rules.d/80-net-setup-link.rules
+    # Because in stage-1 there is no /etc/systemd/network/*.link
+    # nor **/systemd/network/99-default.link
+    # to set NamePolicy= which is responsible to set ID_NET_NAME.
+    # Not sure if ATTR{type}=="1" and KERNEL=="eth*" are equivalent or not.
+    ATTR{type}=="1", KERNEL=="eth*", NAME="$env{ID_NET_NAME_PATH}"
 
-      # Rename eth* using the "path" name policy (eg. enp1s0),
-      # Note that in stage-1 the envvar ID_NET_NAME is not set,
-      # hence not usable as in ''${pkgs.systemd}/lib/udev/rules.d/80-net-setup-link.rules
-      # Because in stage-1 there is no /etc/systemd/network/*.link
-      # nor **/systemd/network/99-default.link
-      # to set NamePolicy= which is responsible to set ID_NET_NAME.
-      # Not sure if ATTR{type}=="1" and KERNEL=="eth*" are equivalent or not.
-      ATTR{type}=="1", KERNEL=="eth*", NAME="$env{ID_NET_NAME_PATH}"
-
-      LABEL="net_setup_link_end"
-    '';
-  };
+    LABEL="net_setup_link_end"
+  '';
 in
 {
   networking = {
@@ -42,12 +38,9 @@ in
 
   boot.initrd = {
     extraUdevRulesCommands = ''
-      # Query hwdb to set some more ID_* in case someone need them for their rules.
-      cp -v ${pkgs.systemd}/lib/udev/rules.d/75-net-description.rules $out/
-
-      # The name set here in stage-1 by 80-net-setup-link.rules
+      # The name set here in stage-1 by 79-net-setup-link.rules
       # will stay in stage-2 (at least until the device is removed/added).
-      cp -v ${udevNetSetupLinkRules}/etc/udev/rules.d/80-net-setup-link.rules $out/
+      cp -v ${udevNetSetupLinkRules}/etc/udev/rules.d/79-net-setup-link.rules $out/
     '';
   };
 
@@ -62,11 +55,11 @@ in
 
   /* Useless block, only here for explanations.
 
-  # NixOS put this .link only in the root filesystem, not in the initrd
-  # hence it's only active in stage-2, not stage-1.
-  # And even in stage-2, the 80-net-setup-link.rules has priority.
-  # DOC: https://www.freedesktop.org/software/systemd/man/systemd.link.html
-  environment.etc."systemd/network/79-net-setup.link".text = ''
+    # NixOS put this .link only in the root filesystem, not in the initrd
+    # hence it's only active in stage-2, not stage-1.
+    # And even in stage-2, the 80-net-setup-link.rules has priority.
+    # DOC: https://www.freedesktop.org/software/systemd/man/systemd.link.html
+    environment.etc."systemd/network/79-net-setup.link".text = ''
     [Match]
     OriginalName=*
 
@@ -74,6 +67,6 @@ in
     #NamePolicy=keep kernel database onboard slot path
     NamePolicy=mac
     MACAddressPolicy=persistent
-  '';
+    '';
   */
 }