summary refs log blame commit diff
path: root/pkgs/os-specific/linux/spectrum/rootfs/rc-services.nix
blob: 4c942189c5e9f57e7301248a47d93a0a2ae932f0 (plain) (tree)

























                                                                            
{ runCommandNoCC, lib, s6-rc }:

{ services ? [] }:

let
  inherit (lib) concatStrings escapeShellArg mapAttrsToList optionalString;

  source = runCommandNoCC "s6-services-source" {} ''
    mkdir $out
    ${concatStrings (mapAttrsToList (name: attrs: ''
      mkdir $out/${name}
      ${concatStrings (mapAttrsToList (key: value: ''
        cp ${value} $out/${name}/${key}
      '') attrs)}
    '') services)}
  '';

  s6RcCompile = { fdhuser ? null }: source:
    runCommandNoCC "s6-rc-compile" {} ''
      ${s6-rc}/bin/s6-rc-compile \
        ${optionalString (fdhuser != null) "-h ${escapeShellArg fdhuser}"} \
        $out ${source}
    '';
in

s6RcCompile {} source