remove unused lets, add test case

module-based-network
Daniel Barlow 2022-09-20 15:46:03 +01:00
parent b38b0bd932
commit 83d576fb58
3 changed files with 10 additions and 9 deletions

View File

@ -1,6 +1,6 @@
pkgs: config: pkgs: config:
let let
inherit (pkgs) buildPlatform callPackage stdenvNoCC closureInfo stdenv writeText s6-rc; inherit (pkgs) callPackage stdenvNoCC closureInfo stdenv writeText s6-rc;
# we need to generate s6 db, by generating closure of all # we need to generate s6 db, by generating closure of all
# config.services and calling s6-rc-compile on them # config.services and calling s6-rc-compile on them

View File

@ -24,9 +24,9 @@ in rec {
# the simplest approach at the consumer end is to require the # the simplest approach at the consumer end is to require the
# producer to create a file per output variable. # producer to create a file per output variable.
name = "ntp"; name = "ntp";
run = let s = services; run = let inherit (services) dhcpv4 dhcpv6;
r = "${pkgs.ntp}/bin/ntp $(cat ${output s.dhcpv4 "ntp_servers"}) $(cat ${output s.dhcpv6 "NTP_IP"})"; in "${pkgs.ntp}/bin/ntp $(cat ${output dhcpv4 "ntp_servers"}) $(cat ${output dhcpv6 "NTP_IP"})";
in (builtins.trace r r);
# I don't think it's possible to standardise the file names # I don't think it's possible to standardise the file names
# generally, as different services have different outputs, but it # generally, as different services have different outputs, but it
# would be cool if services that provide an interface could use # would be cool if services that provide an interface could use
@ -41,16 +41,16 @@ in rec {
}; };
services.defaultroute4 = services.defaultroute4 =
let s = services; let inherit (services) dhcpv4;
in oneshot { in oneshot {
name = "defaultroute4"; name = "defaultroute4";
up = '' up = ''
ip route add default gw $(cat ${output s.dhcpv4 "address"}) ip route add default gw $(cat ${output dhcpv4 "address"})
echo "1" > /sys/net/ipv4/$(cat ${output s.dhcpv4 "ifname"}) echo "1" > /sys/net/ipv4/$(cat ${output dhcpv4 "ifname"})
''; '';
down = '' down = ''
ip route del default gw $(cat ${output s.dhcpv4 "address"}) ip route del default gw $(cat ${output dhcpv4 "address"})
echo "0" > /sys/net/ipv4/$(cat ${output s.dhcpv4 "ifname"}) echo "0" > /sys/net/ipv4/$(cat ${output dhcpv4 "ifname"})
''; '';
}; };
systemPackages = [ pkgs.hello ] ; systemPackages = [ pkgs.hello ] ;

View File

@ -14,6 +14,7 @@ chmod -R +w $db
# check we have closure of config.services (lo.link.service exists only # check we have closure of config.services (lo.link.service exists only
# as a dependency) # as a dependency)
test "$(s6-rc-db -c $db type lo.link.service)" = "oneshot" test "$(s6-rc-db -c $db type lo.link.service)" = "oneshot"
test "$(s6-rc-db -c $db type ntp.service)" = "longrun"
echo OK echo OK
EOF EOF
) )