Packaging systemd services for non-NixOS distros without specifying any host\user info

I have several python scripts I need to be run as services and I want this configuration to be independent of the host and the user so I can install it on a new non-NixOS machine the same way normal packages are installed with “nix-env -iA”. I’ve packaged everything for home-manager and it works but I have to specify the user in home.nix which I don’t want to do. What’s the right way of doing what I’ve described?

Don’t use nix-env - https://stop-using-nix-env.privatevoid.net/

and you can use either home-manager for user services or GitHub - numtide/system-manager: Manage system config using nix on any distro for system services

1 Like

Thanks for the quick response!

I don’t use nix-env. What I meant was I want the same ease of installing a package (a set of packages) as with it. I’d like to be able to install and run all my services with just one command.

I am already using home-manager, the question is can I use it without changing the username in home.nix on every machine?

System-manager seems to be just what I need! I’ll give it a try. But it looks like it might not run well on distros other than Ubuntu. Maybe there’s some better way?

system-manager works on any systemd-based distro, I used it on Arch before. It manages systemd units and anything in /etc. I only stopped because I just use NixOS now.

1 Like

@waffle8946 thanks. I was about to dig into just trying to use straight “modules” to generate and manage systemd services on non-Nixos, but system-manager probably will be better.

Works perfectly! Thanks again :slight_smile: