alternative for iproute module (#41801)

This commit is contained in:
volth 2018-09-01 18:28:23 +00:00 committed by xeji
parent 2d6179d1e8
commit 0fa04d646d
3 changed files with 25 additions and 19 deletions

View File

@ -91,7 +91,7 @@ $ nix-instantiate -E '(import <nixpkgsunstable> {}).gitFull'
<para> <para>
When enabled the <literal>iproute2</literal> will copy the files expected When enabled the <literal>iproute2</literal> will copy the files expected
by ip route (e.g., <filename>rt_tables</filename>) in by ip route (e.g., <filename>rt_tables</filename>) in
<filename>/run/iproute2</filename>. This allows to write aliases for <filename>/etc/iproute2</filename>. This allows to write aliases for
routing tables for instance. routing tables for instance.
</para> </para>
</listitem> </listitem>

View File

@ -4,20 +4,29 @@ with lib;
let let
cfg = config.networking.iproute2; cfg = config.networking.iproute2;
confDir = "/run/iproute2";
in in
{ {
options.networking.iproute2.enable = mkEnableOption "copy IP route configuration files"; options.networking.iproute2 = {
enable = mkEnableOption "copy IP route configuration files";
config = mkMerge [ rttablesExtraConfig = mkOption {
({ nixpkgs.config.iproute2.confDir = confDir; }) type = types.lines;
default = "";
(mkIf cfg.enable { description = ''
system.activationScripts.iproute2 = '' Verbatim lines to add to /etc/iproute2/rt_tables
cp -R ${pkgs.iproute}/etc/iproute2 ${confDir}
chmod -R 664 ${confDir}
chmod +x ${confDir}
''; '';
}) };
]; };
config = mkIf cfg.enable {
environment.etc."iproute2/bpf_pinning" = { mode = "0644"; text = fileContents "${pkgs.iproute}/etc/iproute2/bpf_pinning"; };
environment.etc."iproute2/ematch_map" = { mode = "0644"; text = fileContents "${pkgs.iproute}/etc/iproute2/ematch_map"; };
environment.etc."iproute2/group" = { mode = "0644"; text = fileContents "${pkgs.iproute}/etc/iproute2/group"; };
environment.etc."iproute2/nl_protos" = { mode = "0644"; text = fileContents "${pkgs.iproute}/etc/iproute2/nl_protos"; };
environment.etc."iproute2/rt_dsfield" = { mode = "0644"; text = fileContents "${pkgs.iproute}/etc/iproute2/rt_dsfield"; };
environment.etc."iproute2/rt_protos" = { mode = "0644"; text = fileContents "${pkgs.iproute}/etc/iproute2/rt_protos"; };
environment.etc."iproute2/rt_realms" = { mode = "0644"; text = fileContents "${pkgs.iproute}/etc/iproute2/rt_realms"; };
environment.etc."iproute2/rt_scopes" = { mode = "0644"; text = fileContents "${pkgs.iproute}/etc/iproute2/rt_scopes"; };
environment.etc."iproute2/rt_tables" = { mode = "0644"; text = (fileContents "${pkgs.iproute}/etc/iproute2/rt_tables")
+ (optionalString (cfg.rttablesExtraConfig != "") "\n\n${cfg.rttablesExtraConfig}"); };
};
} }

View File

@ -1,6 +1,4 @@
{ fetchurl, stdenv, config, flex, bash, bison, db, iptables, pkgconfig { fetchurl, stdenv, flex, bash, bison, db, iptables, pkgconfig, libelf }:
, libelf
}:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "iproute2-${version}"; name = "iproute2-${version}";
@ -28,9 +26,8 @@ stdenv.mkDerivation rec {
"HDRDIR=$(TMPDIR)/include/iproute2" # Don't install headers "HDRDIR=$(TMPDIR)/include/iproute2" # Don't install headers
]; ];
# enable iproute2 module if you want this folder to be created
buildFlags = [ buildFlags = [
"CONFDIR=${config.iproute2.confDir or "/run/iproute2"}" "CONFDIR=/etc/iproute2"
]; ];
installFlags = [ installFlags = [