Skip to content

Instantly share code, notes, and snippets.

@Tayrannosaur
Last active December 3, 2022 12:48
Show Gist options
  • Save Tayrannosaur/cc4415e9cfec1190ac5c2efcd84e556d to your computer and use it in GitHub Desktop.
Save Tayrannosaur/cc4415e9cfec1190ac5c2efcd84e556d to your computer and use it in GitHub Desktop.
nix-daemon service script for OpenRC
#!/sbin/openrc-run
name="nix-daemon"
description="Nix Daemon"
supervisor="supervise-daemon"
command="/nix/var/nix/profiles/default/bin/nix-daemon"
pidfile="/run/${RC_SVCNAME}.pid"
command_background=true
@Tayrannosaur
Copy link
Author

Ran into an issue trying to install Nix on an OpenRC based system. I searched online to see if someone else had already made a service script for it but I could not find any search-engine visible solutions. Decided I should share my script for others who might run into the same stumbling block in the future. Hope this helps 💖

Just drop it into your /etc/init.d/ and use rc-update add nix-daemon to add it to the default runlevel.

I ended up digging into packages for Nix from some non-systemd operating systems to see how they handled it but their solutions seemed outdated. I don't know if the solution I ended up coming up with is actually the most correct one, as I am not well versed in the ways of OpenRC, but after going over its documentation a few times, transcribing functionality from the nix-daemon.service template file as best I could, and perusing the Nix daemon source code to make sure I wasn't missing some important behaviour, I feel confident enough to put it out into the wild.

If you have any suggestions to improve it please share!

@Piecuuu
Copy link

Piecuuu commented Dec 3, 2022

Just make sure to change it to an executable with chmod +x /etc/init.d/nix-daemon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment