1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-08 19:46:02 +01:00

add rc.d script for the nix-daemon

This commit is contained in:
Jörg Thalheim 2025-08-08 08:02:37 +02:00
parent 241420a788
commit 73d09e67a7
3 changed files with 63 additions and 0 deletions

10
misc/freebsd/meson.build Normal file
View file

@ -0,0 +1,10 @@
configure_file(
input : 'nix-daemon.in',
output : 'nix-daemon',
install : true,
install_dir : get_option('prefix') / 'etc/rc.d',
install_mode : 'rwxr-xr-x',
configuration : {
'bindir' : bindir,
},
)

View file

@ -0,0 +1,49 @@
#!/bin/sh
#
# PROVIDE: nix_daemon
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable nix-daemon:
#
# nix_daemon_enable="YES"
#
# shellcheck source=/dev/null
. /etc/rc.subr
name="nix_daemon"
# shellcheck disable=SC2034
rcvar="nix_daemon_enable"
load_rc_config $name
: "${nix_daemon_enable:=NO}"
command="@bindir@/nix-daemon"
command_args=""
pidfile="/var/run/nix-daemon.pid"
# shellcheck disable=SC2034
start_cmd="${name}_start"
# shellcheck disable=SC2034
stop_cmd="${name}_stop"
nix_daemon_start() {
echo "Starting ${name}."
# command_args is intentionally unquoted to allow multiple arguments
# shellcheck disable=SC2086
/usr/sbin/daemon -c -f -p "${pidfile}" "${command}" ${command_args}
}
nix_daemon_stop() {
if [ -f "${pidfile}" ]; then
echo "Stopping ${name}."
kill -TERM "$(cat "${pidfile}")"
rm -f "${pidfile}"
else
echo "${name} is not running."
fi
}
run_rc_command "$1"

View file

@ -9,3 +9,7 @@ endif
if host_machine.system() == 'darwin'
subdir('launchd')
endif
if host_machine.system() == 'freebsd'
subdir('freebsd')
endif