NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.21k stars 14.21k forks source link

nixos: systemd user services #1689

Closed offlinehacker closed 10 years ago

offlinehacker commented 10 years ago

So systemd supports user services, and some/most of nixos modules would not need a lot of changing to work in user environemnts(ex. changing the state dir). @zefhemel used supervisor for that(https://github.com/zefhemel/nix-docker), but that's not necessary and i would like to implement this, but first i would also like to get comments from others and especially @edolstra how to properly implement this.

shlevy commented 10 years ago

I have some ideas for how to do this properly (and they would even work on non-nixos systems that use systemd), but they will need to wait until #1021 is fixed as systemd has changed how user services work since our systemd version.

shlevy commented 10 years ago

Essentially we'd use the module system to define units and use that config to ultimately create a symlink tree that contains a bunch of unit files, plus an activation script to update relevant symlinks in the user's HOME and reload any needed targets, then have a simple tool like nixos-rebuild (that nixos-rebuild can hook into) to rebuild the tree + activation script and run the script.

offlinehacker commented 10 years ago

+1

edolstra commented 10 years ago

In the interim, you can use service-runner.nix, see 2b0aea17934fda4aca24d4b6b99f0b9c24486ff7.

offlinehacker commented 10 years ago

@edolstra thanks, exactly what i needed for now :)

offlinehacker commented 10 years ago

We should have someting like system.defaultStateDir option(by default pointing to /var), which would be reused where needed. Then you could use it like dataDir = "${config.system.defaultStateDir}/db/postgresql". Do you see any problems with that and where should i put this option?

offlinehacker commented 10 years ago

I am now working on something similar now (https://github.com/offlinehacker/nix-services). I use supervisor for managing processes(basically expression from @zefhemel for nix-docker), because systemd does not work on darwin.

shlevy commented 10 years ago

Note also that @proger is working on an abstraction around services that might be useful here. Seems like a lot of people are converging on this problem :)

offlinehacker commented 10 years ago

I already have working implementation, which uses supervisord for running services, i'm also using in production: https://github.com/kiberpipa/nix-rehash/tree/master/nix-services On Apr 5, 2014 7:23 PM, "Shea Levy" notifications@github.com wrote:

Note also that @proger https://github.com/proger is working on an abstraction around services that might be useful here. Seems like a lot of people are converging on this problem :)

Reply to this email directly or view it on GitHubhttps://github.com/NixOS/nixpkgs/issues/1689#issuecomment-39644844 .

shlevy commented 10 years ago

Ah cool, I just asked for that in another PR :) I think after 14.04 we should start coordinating and seeing if we can't converge on a solution.

shlevy commented 10 years ago

I no longer expect to have the bandwidth to take this on.

domenkozar commented 10 years ago

duplicate of #1689

cstrahan commented 10 years ago

@iElectric you closed this on the basis of it being a duplicate of #1689, but this is #1689. Did you have another issue in mind, or should this be reopened?

wmertens commented 10 years ago

@iElectric did you mean #4493 or #4594 or something else?

domenkozar commented 10 years ago

@wmertens correct, sorry for wrong info.