summary refs log tree commit diff
path: root/pkgs/os-specific/linux/spectrum/rootfs/services.nix
blob: b2b09faa06e0077eaab04544c605617b90bd6b8f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{ runCommandNoCC, writeScript, lib, execline }:

{ services ? [] }:

let
  services' = {
    ".s6-svscan" = {
      finish = writeScript "init-stage3" ''
        #! ${execline}/bin/execlineb -P
        foreground { s6-nuke -th }
        s6-sleep -m -- 2000
        foreground { s6-nuke -k }
        wait { }
        s6-linux-init-hpr -fr
      '';
    } // services.".s6-svscan" or {};
  } // services;
in

runCommandNoCC "services" {} ''
  mkdir $out
  ${lib.concatStrings (lib.mapAttrsToList (name: attrs: ''
    mkdir $out/${name}
    ${lib.concatStrings (lib.mapAttrsToList (key: value: ''
      cp ${value} $out/${name}/${key}
    '') attrs)}
  '') services')}
''