62 lines
1.4 KiB
Nix
62 lines
1.4 KiB
Nix
{
|
|
pkgs,
|
|
lib,
|
|
config,
|
|
...
|
|
}:
|
|
|
|
let
|
|
compat = pkgs.runCommand "runit-compat" { } ''
|
|
mkdir -p $out/bin/
|
|
cat << EOF > $out/bin/poweroff
|
|
#!/bin/sh
|
|
exec runit-init 0
|
|
EOF
|
|
cat << EOF > $out/bin/reboot
|
|
#!/bin/sh
|
|
exec runit-init 6
|
|
EOF
|
|
chmod +x $out/bin/{poweroff,reboot}
|
|
'';
|
|
in
|
|
{
|
|
environment.systemPackages = [ compat ];
|
|
environment.etc = lib.mkMerge [
|
|
{
|
|
"runit/1".source = pkgs.writeScript "1" ''
|
|
#!${pkgs.runtimeShell}
|
|
mkdir /bin/
|
|
ln -s ${pkgs.runtimeShell} /bin/sh
|
|
|
|
${lib.optionalString (config.networking.timeServers != [ ]) ''
|
|
${pkgs.ntp}/bin/ntpdate ${toString config.networking.timeServers}
|
|
''}
|
|
|
|
# disable DPMS on tty's
|
|
echo -ne "\033[9;0]" > /dev/tty0
|
|
|
|
touch /etc/runit/stopit
|
|
chmod 0 /etc/runit/stopit
|
|
'';
|
|
"runit/2".source = pkgs.writeScript "2" ''
|
|
#!${pkgs.runtimeShell}
|
|
exec runsvdir -P /etc/service
|
|
'';
|
|
"runit/3".source = pkgs.writeScript "3" ''
|
|
#!${pkgs.runtimeShell}
|
|
echo and down we go
|
|
'';
|
|
"service/nix-daemon/run".source = pkgs.writeScript "nix-daemon" ''
|
|
#!${pkgs.runtimeShell}
|
|
nix-daemon
|
|
'';
|
|
}
|
|
(lib.mkIf config.not-os.rngd {
|
|
"service/rngd/run".source = pkgs.writeScript "rngd" ''
|
|
#!${pkgs.runtimeShell}
|
|
export PATH=$PATH:${pkgs.rng-tools}/bin
|
|
exec rngd -r /dev/hwrng
|
|
'';
|
|
})
|
|
];
|
|
}
|