iana-etc module: allow adding new services
This fixes a bug which only allowed modifying existing services.
This commit is contained in:
parent
4a1ab9bf65
commit
b77df86da8
@ -23,32 +23,20 @@ with import <stockholm/lib>;
|
||||
};
|
||||
|
||||
config.environment.etc = mkIf (config.krebs.iana-etc.services != {}) {
|
||||
services.source = mkForce (pkgs.runCommand "krebs-iana-etc" {} ''
|
||||
exec < ${pkgs.iana_etc}/etc/services
|
||||
exec > $out
|
||||
awk -F '[ /]+' '
|
||||
BEGIN {
|
||||
port=0
|
||||
}
|
||||
${concatMapStringsSep "\n" (entry: ''
|
||||
$2 == ${entry.port} {
|
||||
port=$2
|
||||
next
|
||||
}
|
||||
port == ${entry.port} {
|
||||
services.source = mkForce (pkgs.runCommand "krebs-iana-etc" {} /* sh */ ''
|
||||
{
|
||||
${concatMapStringsSep "\n" (entry: /* sh */ ''
|
||||
${concatMapStringsSep "\n"
|
||||
(proto: let
|
||||
s = "${entry.${proto}.name} ${entry.port}/${proto}";
|
||||
in
|
||||
"print ${toJSON s}")
|
||||
line = "${entry.${proto}.name} ${entry.port}/${proto}";
|
||||
in /* sh */ ''
|
||||
echo ${shell.escape line}
|
||||
'')
|
||||
(filter (proto: entry.${proto} != null) ["tcp" "udp"])}
|
||||
port=0
|
||||
}
|
||||
'') (attrValues config.krebs.iana-etc.services)}
|
||||
{
|
||||
print $0
|
||||
}
|
||||
'
|
||||
cat ${pkgs.iana_etc}/etc/services
|
||||
} |
|
||||
sort -b -k 2,2 -u > $out
|
||||
'');
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user