iproute2: module to create rt_table file & co

When doing source routing/multihoming, it's practical to give names to routing
tables. The absence of the rt_table file in /etc make this impossible.
This patch recreates these files on rebuild so that they can be modified
by the user see NixOS#38638.

iproute2 is modified to look into config.networking.iproute2.confDir instead of
/etc/iproute2.

Changed files
+27 -2
nixos
modules
pkgs
os-specific
linux
iproute
+23
nixos/modules/config/iproute2.nix
···
···
+
{ config, lib, pkgs, ... }:
+
+
with lib;
+
+
let
+
cfg = config.networking.iproute2;
+
confDir = "/run/iproute2";
+
in
+
{
+
options.networking.iproute2.enable = mkEnableOption "copy IP route configuration files";
+
+
config = mkMerge [
+
({ nixpkgs.config.iproute2.confDir = confDir; })
+
+
(mkIf cfg.enable {
+
system.activationScripts.iproute2 = ''
+
cp -R ${pkgs.iproute}/etc/iproute2 ${confDir}
+
chmod -R 664 ${confDir}
+
chmod +x ${confDir}
+
'';
+
})
+
];
+
}
+1
nixos/modules/module-list.nix
···
./config/fonts/ghostscript.nix
./config/gnu.nix
./config/i18n.nix
./config/krb5/default.nix
./config/ldap.nix
./config/networking.nix
···
./config/fonts/ghostscript.nix
./config/gnu.nix
./config/i18n.nix
+
./config/iproute2.nix
./config/krb5/default.nix
./config/ldap.nix
./config/networking.nix
+3 -2
pkgs/os-specific/linux/iproute/default.nix
···
-
{ fetchurl, stdenv, lib, flex, bash, bison, db, iptables, pkgconfig }:
stdenv.mkDerivation rec {
name = "iproute2-${version}";
···
"HDRDIR=$(TMPDIR)/include/iproute2" # Don't install headers
];
buildFlags = [
-
"CONFDIR=/etc/iproute2"
];
installFlags = [
···
+
{ fetchurl, stdenv, config, lib, flex, bash, bison, db, iptables, pkgconfig }:
stdenv.mkDerivation rec {
name = "iproute2-${version}";
···
"HDRDIR=$(TMPDIR)/include/iproute2" # Don't install headers
];
+
# enable iproute2 module if you want this folder to be created
buildFlags = [
+
"CONFDIR=${config.iproute2.confDir or "/run/iproute2"}"
];
installFlags = [