From 83d576fb58c8b1807952523918aa3be35a8bebf4 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Tue, 20 Sep 2022 15:46:03 +0100 Subject: [PATCH] remove unused lets, add test case --- make-image.nix | 2 +- tests/smoke/configuration.nix | 16 ++++++++-------- tests/smoke/run.sh | 1 + 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/make-image.nix b/make-image.nix index 003dcea..8bc6dfd 100644 --- a/make-image.nix +++ b/make-image.nix @@ -1,6 +1,6 @@ pkgs: config: 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 # config.services and calling s6-rc-compile on them diff --git a/tests/smoke/configuration.nix b/tests/smoke/configuration.nix index 9eedc29..3a78b2f 100644 --- a/tests/smoke/configuration.nix +++ b/tests/smoke/configuration.nix @@ -24,9 +24,9 @@ in rec { # the simplest approach at the consumer end is to require the # producer to create a file per output variable. name = "ntp"; - run = let s = services; - r = "${pkgs.ntp}/bin/ntp $(cat ${output s.dhcpv4 "ntp_servers"}) $(cat ${output s.dhcpv6 "NTP_IP"})"; - in (builtins.trace r r); + run = let inherit (services) dhcpv4 dhcpv6; + in "${pkgs.ntp}/bin/ntp $(cat ${output dhcpv4 "ntp_servers"}) $(cat ${output dhcpv6 "NTP_IP"})"; + # I don't think it's possible to standardise the file names # generally, as different services have different outputs, but it # would be cool if services that provide an interface could use @@ -41,16 +41,16 @@ in rec { }; services.defaultroute4 = - let s = services; + let inherit (services) dhcpv4; in oneshot { name = "defaultroute4"; up = '' - ip route add default gw $(cat ${output s.dhcpv4 "address"}) - echo "1" > /sys/net/ipv4/$(cat ${output s.dhcpv4 "ifname"}) + ip route add default gw $(cat ${output dhcpv4 "address"}) + echo "1" > /sys/net/ipv4/$(cat ${output dhcpv4 "ifname"}) ''; down = '' - ip route del default gw $(cat ${output s.dhcpv4 "address"}) - echo "0" > /sys/net/ipv4/$(cat ${output s.dhcpv4 "ifname"}) + ip route del default gw $(cat ${output dhcpv4 "address"}) + echo "0" > /sys/net/ipv4/$(cat ${output dhcpv4 "ifname"}) ''; }; systemPackages = [ pkgs.hello ] ; diff --git a/tests/smoke/run.sh b/tests/smoke/run.sh index 01114d2..0316302 100755 --- a/tests/smoke/run.sh +++ b/tests/smoke/run.sh @@ -14,6 +14,7 @@ chmod -R +w $db # check we have closure of config.services (lo.link.service exists only # as a dependency) test "$(s6-rc-db -c $db type lo.link.service)" = "oneshot" +test "$(s6-rc-db -c $db type ntp.service)" = "longrun" echo OK EOF )