Nix: Noob: how to use on other Linux distros (services/system software)

How would I go about using Nix as an additional package manager on say a Debian/Ubuntu system for services or system software?

As I understand it, I cannot just have a configuration.nix that I would use to manage nixos. Installing software, as I would using nix profile doesn’t do configuration especially not configuring systemd units.

Does nix (the pkgmgr) integrate into the native init system by default or are there predefined integrations for distros such as debian or fedora?

Is what I’m looking for a viable approach or is the limit of nix on something like debian installing applications to be run manually?

I know that I can always install software and integrate it manually writing my own units, but this seems to be rather awkward and I would forego all the benefits of configuration management in nix.

I don’t find tutorials or documentation for this use case.

As I understand it, I cannot just have a configuration.nix that I would use to manage nixos. Installing software, as I would using nix profile doesn’t do configuration especially not configuring systemd units.

Correct. configuration.nix is exclusively a NixOS thing.

Does nix (the pkgmgr) integrate into the native init system by default or are there predefined integrations for distros such as debian or fedora?

No, Nix doesn’t deal with services, it just manages the files in /nix/store and creates symlinks in your profile. Packages sometimes provide systemd unit files, so you could use those (if using nix profile look under $XDG_DATA_HOME/nix/profile/lib/systemd).

Is what I’m looking for a viable approach or is the limit of nix on something like debian installing applications to be run manually?

No, that’s pretty much the end of the story. Nix is just a package manager and it looks like you want to configure software with it, which is NixOS’ job.

Depending on what kind of software you want to manage, you may try home-manager, which I don’t think depends on NixOS. This is a project re-using the NixOS module system but for configuring user programs and services (not the whole OS and system-wide services).

I would forego all the benefits of configuration management in nix.

Because configuration is just not a concept Nix has, it’s what NixOS provides, by building on top of Nix and systemd.

Thanks!

K900 on nix’ matrix server pointed me to GitHub - numtide/system-manager: Manage system config using nix on any distro

It’s probably a bad compromise (between not using nixos and trying to eat it anyway), but that’s what I’m looking for the moment, so I will look into this for now.

1 Like

I think winning with nix starts from the bottom up, and installing it on some rando distro and learning how to write small nix expressions to achieve what you want while not blocking your day-to-day is the least frustrating way to go about learning it, and you don’t need nix service configuration for that. i.e. if I wanted to try running haproxy or something from nix, I’d just write a nix expression to install it somewhere i.e. using nix-build, and then reference that path from my systemd unit (edited and installed the usual way for my distro under i.e. under /usr/local/lib), same for any associated config etc (you can get this all done in a single expression usually pretty easily). If you can do this and it doesn’t drive you crazy, then probably jumping into nixos is for you, and when you finally come to editing your configuration.nix on your newly minted system instead of being infuriating it will be liberating because you’ll already have a good theory of how it all fits together that you will have been exercising already for some time.

Of course feel free to ignore the unsolicited advice :slight_smile: