liminix

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

default.nix (1942B)


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