liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

default.nix (1925B)


      1 {
      2   lualinux,
      3   writeFennel,
      4   anoia,
      5   fennel,
      6   stdenv,
      7   fennelrepl,
      8 }:
      9 stdenv.mkDerivation {
     10   name = "s6-rc-up-tree";
     11   src = ./.;
     12   nativeBuildInputs = [ fennelrepl ];
     13   # propagatedBuildInputs = [ s6-rc-up-tree ];
     14   installPhase = ''
     15     mkdir -p $out/bin
     16     cp -p ${
     17       writeFennel "s6-rc-up-tree" {
     18         packages = [
     19           lualinux
     20         ];
     21         mainFunction = "run";
     22       } ./s6-rc-up-tree.fnl
     23     } $out/bin/s6-rc-up-tree
     24   '';
     25   postBuild = ''
     26     export PATH=./scripts:$PATH
     27     patchShebangs ./scripts
     28     export TEST_LOG=./log
     29     fail(){ cat $TEST_LOG | od -c; exit 1; }
     30     expect(){
     31       test "$(echo $(cat $TEST_LOG))" = "$@" || fail;
     32     }
     33     # given a service with no rdepends, starts only that service
     34     fennelrepl ./test.fnl ${./test-services} turmeric
     35     expect "turmeric"
     36 
     37     # given a controlled service with no rdepends, starts only that service
     38     fennelrepl ./test.fnl ${./test-services} wombat
     39     expect "wombat"
     40 
     41     # uncontrolled rdepends start
     42     fennelrepl ./test.fnl ${./test-services} thyme
     43     expect "thyme rosemary"
     44 
     45     # stopped controlled rdepends don't start
     46     fennelrepl ./test.fnl ${./test-services} enables-wan
     47     expect "enables-wan" # not wattle, even though it depends
     48 
     49     # started controlled rdepends are running, so starting them is harmless
     50 
     51     # descendants which depend on a _different_ controlled service,
     52     # which is down, don't start:
     53     # Given:
     54     #  - modeswitch is controlled
     55     #  - atz is controlled
     56     #  - atz => modeswitch
     57     #  - ifconfig => atz
     58     # Then: if atz is down, ifconfig should not start when modeswitch is started
     59     fennelrepl ./test.fnl ${./test-services} modeswitch
     60     expect "modeswitch"
     61 
     62     # descendants which depend on a _different_ controlled service, which is up, do start
     63     ATZ=up fennelrepl ./test.fnl ${./test-services} modeswitch
     64     set -x
     65     expect "modeswitch atz ifconfig"
     66   '';
     67 }