# GitHub - numtide/system-manager: Manage system config using nix on any distro

**URL:** https://discourse.nixos.org/t/github-numtide-system-manager-manage-system-config-using-nix-on-any-distro/27064
**Category:** Links
**Created:** [April 7, 2023, 8:56am UTC](https://discourse.nixos.org/t/github-numtide-system-manager-manage-system-config-using-nix-on-any-distro/27064 "2023-04-07T08:56:54Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Mic92](https://discourse.nixos.org/user_avatar/discourse.nixos.org/mic92/32/5265_2.png) [@Mic92](https://discourse.nixos.org/u/Mic92)
#### Post date: [April 7, 2023, 8:56am UTC](https://discourse.nixos.org/t/github-numtide-system-manager-manage-system-config-using-nix-on-any-distro/27064/1 "2023-04-07T08:56:54Z")

</div>

> **[GitHub - numtide/system-manager: Manage system config using nix on any distro](https://github.com/numtide/system-manager)**
>
> Manage system config using nix on any distro. Contribute to numtide/system-manager development by creating an account on GitHub.

---

<div class="post-metadata">

### Author: ![aanderse](https://discourse.nixos.org/user_avatar/discourse.nixos.org/aanderse/32/1420_2.png) [@aanderse](https://discourse.nixos.org/u/aanderse)
#### Post date: [April 7, 2023, 1:18pm UTC](https://discourse.nixos.org/t/github-numtide-system-manager-manage-system-config-using-nix-on-any-distro/27064/2 "2023-04-07T13:18:30Z")

</div>

Thanks to the authors for making this. The first steps toward something that has been a much requested feature.

❤

---

<div class="post-metadata">

### Author: ![doronbehar](https://discourse.nixos.org/user_avatar/discourse.nixos.org/doronbehar/32/1387_2.png) [@doronbehar](https://discourse.nixos.org/u/doronbehar)
#### Post date: [April 7, 2023, 2:01pm UTC](https://discourse.nixos.org/t/github-numtide-system-manager-manage-system-config-using-nix-on-any-distro/27064/3 "2023-04-07T14:01:16Z")

</div>

Wow this looks amazing! I am specifically interested regarding the `--target-host` option:

> **systems-manager --help**
>
> ```auto
> System Manager -- Manage system configuration with Nix on any distro
> 
> Usage: system-manager [OPTIONS] <COMMAND>
> 
> Commands:
> activate
> Activate a given system-manager profile
> build
> Build a new system-manager profile without registering it as a nix profile
> deactivate
> Deactivate the active system-manager profile, removing all managed configuration
> generate
> Generate a new system-manager profile and register is as the active system-manager profile
> switch
> Generate a new system-manager profile and activate it
> help
> Print this message or the help of the given subcommand(s)
> 
> Options:
> --target-host <TARGET_HOST>
> The host to deploy the system-manager profile to
> 
> --use-remote-sudo
> Invoke the remote command with sudo. Only useful in combination with --target-host
> 
> -h, --help
> Print help (see a summary with '-h')
> 
> -V, --version
> Print version
> 
> ```

How does this work exactly? Does it rely upon a Nix daemon running on the target host? Or does it just ssh to it and replaces the `/etc/` directory there with the one generated by `system-manager`? Does it take care of garbage collection as well? I’m asking because I wonder if it’s possible to use this tool to replace my imperative Arch Linux VPS installation with a declarative one of Nix, when the VPS has very low disk space and thus can’t use Nix natively.

P.S It would be nice to put the `--help` text in the repo’s README :).

---

<div class="post-metadata">

### Author: ![pxc](https://discourse.nixos.org/user_avatar/discourse.nixos.org/pxc/32/17601_2.png) [@pxc](https://discourse.nixos.org/u/pxc)
#### Post date: [April 7, 2023, 2:13pm UTC](https://discourse.nixos.org/t/github-numtide-system-manager-manage-system-config-using-nix-on-any-distro/27064/4 "2023-04-07T14:13:50Z")

</div>

The Nix-Darwin of foreign Linux! And just maybe, an early ancestor of the future GRUMS. Love to see it. Thanks for posting it here!!

---

<div class="post-metadata">

### Author: ![zimbatm](https://discourse.nixos.org/user_avatar/discourse.nixos.org/zimbatm/32/4_2.png) [@zimbatm](https://discourse.nixos.org/u/zimbatm)
#### Post date: [April 7, 2023, 4:23pm UTC](https://discourse.nixos.org/t/github-numtide-system-manager-manage-system-config-using-nix-on-any-distro/27064/5 "2023-04-07T16:23:31Z")

</div>

We started writing this because some of our customers want to benefit from the NixOS experience, but switching entirely to NixOS is too much to ask. This is a big project, so we have to pace ourselves.

We currently have a working POC that manages systemd units and /etc/files using the Nix module system, tested on Ubuntu. The main logic is all written in Rust and introduces a local state file, making it possible to remove everything cleanly. Note that things are very early so there is no documentation, and things might break.

In the near future, we want to:

- add support for tmpfiles.d
- handle service users
- support the most common NixOS services
- support more Linux distributions
- write documentation and user guides.

If you want to help out, feel free to try it and report issues. If your company could benefit from such work, we are also interested in getting in contact to specifically support your use cases.

---

<div class="post-metadata">

### Author: ![Lillecarl](https://discourse.nixos.org/user_avatar/discourse.nixos.org/lillecarl/32/34279_2.png) [@Lillecarl](https://discourse.nixos.org/u/Lillecarl)
#### Post date: [April 7, 2023, 5:15pm UTC](https://discourse.nixos.org/t/github-numtide-system-manager-manage-system-config-using-nix-on-any-distro/27064/6 "2023-04-07T17:15:52Z")

</div>

We’ve been doing really dirty things to mimic something like this. We’ve built nixos on the systems and had Saltstack link things from the result into the normal system.

I’ve been waiting for this since forever, great job! 🙂

---

<div class="post-metadata">

### Author: ![bobvanderlinden](https://discourse.nixos.org/user_avatar/discourse.nixos.org/bobvanderlinden/32/59_2.png) [@bobvanderlinden](https://discourse.nixos.org/u/bobvanderlinden)
#### Post date: [April 7, 2023, 5:21pm UTC](https://discourse.nixos.org/t/github-numtide-system-manager-manage-system-config-using-nix-on-any-distro/27064/7 "2023-04-07T17:21:24Z")

</div>

Nice! This looks really useful 👍

Hard to predict the future, but is there an incentive to combine with NixOS modules so that modules can be used by both system-manager as well as NixOS.

---

<div class="post-metadata">

### Author: ![zimbatm](https://discourse.nixos.org/user_avatar/discourse.nixos.org/zimbatm/32/4_2.png) [@zimbatm](https://discourse.nixos.org/u/zimbatm)
#### Post date: [April 8, 2023, 4:35pm UTC](https://discourse.nixos.org/t/github-numtide-system-manager-manage-system-config-using-nix-on-any-distro/27064/8 "2023-04-08T16:35:37Z")

</div>

> [@doronbehar](#):
>
> How does this work exactly? Does it rely upon a Nix daemon running on the target host? Or does it just ssh to it and replaces the `/etc/` directory there with the one generated by `system-manager` ? Does it take care of garbage collection as well? I’m asking because I wonder if it’s possible to use this tool to replace my imperative Arch Linux VPS installation with a declarative one of Nix, when the VPS has very low disk space and thus can’t use Nix natively.

For now we assume that the target machine already has Nix installed. We could include a bootstrap method in the future. Just like NixOS, the system closure can be built locally, then copied using `nix copy`, and bound to a profile in `/nix/var/nix/profiles/`. Except that it’s named `system-manager` instead of `system`. The biggest difference is that unlike NixOS where you can have a single `/run/current-system` symlink, we have to carefully weave the symlinks into the `/etc` folder to not disrupt the current distribution. That’s where the diffing engine and state file come in play. The exact implementation details of that diffing engine will probably change as we extend the scope of the project.

> [@bobvanderlinden](#):
>
> Hard to predict the future, but is there an incentive to combine with NixOS modules so that modules can be used by both system-manager as well as NixOS.

One of the goals that we have is that modules written in system-manager should be compatible with NixOS. That way, system-manager can become an on-ramp to NixOS whenever they are ready to do the full switch.

The reverse is more difficult because the namespace of NixOS is very wide. Any module might set values to any other modules. What I envision is that the list of NixOS modules that work out of the box will grow, depending on the customers or contributions that we get. Probably the most interesting ones are networked services such as nginx and postgres.

---

<div class="post-metadata">

### Author: ![Lillecarl](https://discourse.nixos.org/user_avatar/discourse.nixos.org/lillecarl/32/34279_2.png) [@Lillecarl](https://discourse.nixos.org/u/Lillecarl)
#### Post date: [April 10, 2023, 11:59pm UTC](https://discourse.nixos.org/t/github-numtide-system-manager-manage-system-config-using-nix-on-any-distro/27064/9 "2023-04-10T23:59:11Z")

</div>

A module like [this one (salt-master)](https://github.com/NixOS/nixpkgs/blob/528dd7fa250980b6450eecea6f1d9910dcc58b5b/nixos/modules/services/admin/salt/master.nix) looks like it’d be compatible with system-manager.

If the idea isn’t to be compatible with NixOS modules, would you accept modules that are just straight up ports from NixOS modules?

My thought when implementing my shabby version of this was to build the entirety of NixOS, then have some custom module that’d link from /run/current-system/etc/$name to /etc/$name, essentially a way to write nix to “include” files that should be linked, and keep state of the difference.

This looks more robust, but re-implementing NixOS modules is a lot of work.

---

<div class="post-metadata">

### Author: ![zimbatm](https://discourse.nixos.org/user_avatar/discourse.nixos.org/zimbatm/32/4_2.png) [@zimbatm](https://discourse.nixos.org/u/zimbatm)
#### Post date: [April 12, 2023, 12:46pm UTC](https://discourse.nixos.org/t/github-numtide-system-manager-manage-system-config-using-nix-on-any-distro/27064/10 "2023-04-12T12:46:16Z")

</div>

The idea is that system-manager itself only ships with the core modules like `systemd.services`, `environment.etc`, … Those are re-implemented in Rust, with a diffing engine; a bit like Terraform but for local system changes.

Then as a user, you would use `imports = ["${modulesPath}/path/to/my/service.nix"];` to load whatever service from the NixOS distribution, and if you are lucky, it’s compatible 🙂 Of course, a lot of modules will break initially, but we can expand the surface area over time. Common services such as Nginx would also be part of our test suite to avoid regressions.

Anyways, that’s the idea for now. This is still pretty early so some of those ideas might change as we learn more about the domain.

---

<div class="post-metadata">

### Author: ![Animeshz](https://discourse.nixos.org/user_avatar/discourse.nixos.org/animeshz/32/9551_2.png) [@Animeshz](https://discourse.nixos.org/u/Animeshz)
#### Post date: [June 7, 2023, 6:08pm UTC](https://discourse.nixos.org/t/github-numtide-system-manager-manage-system-config-using-nix-on-any-distro/27064/11 "2023-06-07T18:08:51Z")

</div>

While I generally liked the idea, rewriting everything from scratch in rust seems a never ending process to keep & maintain compatibility with nixos modules.

Instead what I’d recommend is that you can generate and apply generic resources from well-known generic configuration reinfocement tools like puppet & chef. Puppet allows cli access to its resources:

```bash
# Running on void-linux (runit), same cmd also works in systemd, or any other

$ sudo puppet resource service adb ensure=running
Notice: /Service[adb]/ensure: ensure changed 'stopped' to 'running'
service { 'adb':
  ensure => 'running',
  provider => 'runit',
}

```

And good thing is that it can be used across systemd, runit, s6, sysv, and various other defined in [https://github.com/puppetlabs/puppet/tree/main/lib/puppet/provider/service](https://github.com/puppetlabs/puppet/tree/main/lib/puppet/provider/service), also one-level up you can see there are more providers available for different purposes that packages, name-services, user/group, file, etc. that can be reused instead of reinventing the wheel (which will get unmaintainable in future).

Let me know what do you think about this, it’ll be quite beneficial imho.

---

<div class="post-metadata">

### Author: ![Mic92](https://discourse.nixos.org/user_avatar/discourse.nixos.org/mic92/32/5265_2.png) [@Mic92](https://discourse.nixos.org/u/Mic92)
#### Post date: [June 15, 2023, 2:03pm UTC](https://discourse.nixos.org/t/github-numtide-system-manager-manage-system-config-using-nix-on-any-distro/27064/12 "2023-06-15T14:03:09Z")

</div>

Does puppet stop a service that is no longer defined automatically i.e. does it perform correct state transitions? This is the most complex part of service management in my experience. a simple systemctl start/stop is easy to maintain.

---

<div class="post-metadata">

### Author: ![NobbZ](https://discourse.nixos.org/user_avatar/discourse.nixos.org/nobbz/32/7022_2.png) [@NobbZ](https://discourse.nixos.org/u/NobbZ)
#### Post date: [June 15, 2023, 2:49pm UTC](https://discourse.nixos.org/t/github-numtide-system-manager-manage-system-config-using-nix-on-any-distro/27064/13 "2023-06-15T14:49:32Z")

</div>

No.

If you change a puppet config to not include some “thing” anymore, puppet will just ignore it. So whatever state it was in, it will remain in.

Therefore it is a common idiom to do 2 deployments…

One to disable/remove the thing explicitely, and then one that doesn’t have the thing mentioned in the config anymore.

Similar is true for chef, salt, ansible, and whatnot.

An alternate approach is the “kettle” approach, which will just create a new machine from scratch for each deployment and destroy the old one(s).

---

<div class="post-metadata">

### Author: ![Anjali](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@Anjali](https://discourse.nixos.org/u/Anjali)
#### Post date: [February 23, 2024, 1:12pm UTC](https://discourse.nixos.org/t/github-numtide-system-manager-manage-system-config-using-nix-on-any-distro/27064/14 "2024-02-23T13:12:57Z")

</div>

I am using system-manager project with nix package manager on my debian system ,  
Tell me when you create your default.nix and add few lines for enabling service for my case suppose that I am taking openssh service .  
I have installed it this service package and then add few lines like

systemd.services = {  
sshd = {  
enable = true;

```
	 wantedBy = ["multi-user.target" "system-manager.target"];
	 wants = ["network.target"];
	 after = ["network.target" "systemd-user-sessions.service"];
	 description = "SSH Daemon";
	 serviceConfig = {
	 Type = "simple";
	 ExecStart = "${lib.getBin pkgs.openssh}/bin/sshd -D -e";
ExecReload = "${lib.getBin pkgs.openssh}/bin/true";
	 Restart = "always";
	 KillMode = "process";
	 };
	
		 };
	 };

```

I got an error

Started sshd.service - SSH Daemon.  
Feb 23 10:39:09 debian sshd[635]: Privilege separation user sshd does not exist  
Feb 23 10:39:09 debian systemd[1]: sshd.service: Main process exited, code=exit\>  
Feb 23 10:39:09 debian systemd[1]: sshd.service: Failed with result ‘exit-code’.  
Feb 23 10:39:09 debian systemd[1]: sshd.service: Scheduled restart job, restart\>  
Feb 23 10:39:09 debian systemd[1]: Started sshd.service - SSH Daemon.  
Feb 23 10:39:09 debian sshd[658]: Privilege separation user sshd does not exist  
Feb 23 10:39:09 debian systemd[1]: sshd.service: Main process exited, code=exit\>  
Feb 23 10:39:09 debian systemd[1]: sshd.service: Failed with result ‘exit-code’.

why it is please clear this and tell me the solution for this .

---

<div class="post-metadata">

### Author: ![R-VdP](https://discourse.nixos.org/user_avatar/discourse.nixos.org/r-vdp/32/2079_2.png) [@R-VdP](https://discourse.nixos.org/u/R-VdP)
#### Post date: [February 23, 2024, 1:27pm UTC](https://discourse.nixos.org/t/github-numtide-system-manager-manage-system-config-using-nix-on-any-distro/27064/15 "2024-02-23T13:27:12Z")

</div>

Currently, `system-manager` does not manage user accounts, it is up to the host distro to provide all user accounts.

SSH requires a user account called `sshd` that it uses for privilege separation (forked sshd processes will run as this user instead of root).

So you will need to create this user using your distros tools in order for ssh to work.

---

<div class="post-metadata">

### Author: ![ShalokShalom](https://discourse.nixos.org/user_avatar/discourse.nixos.org/shalokshalom/32/4108_2.png) [@ShalokShalom](https://discourse.nixos.org/u/ShalokShalom)
#### Post date: [March 28, 2024, 7:45pm UTC](https://discourse.nixos.org/t/github-numtide-system-manager-manage-system-config-using-nix-on-any-distro/27064/17 "2024-03-28T19:45:32Z")

</div>

Wonderful

This looks like something that can come in handy. I wonder about the feature parity with home manager: How do the two services compare?

Can system manager be described as a superset?

At least from the position of using it on another Linux distro.

---

<div class="post-metadata">

### Author: ![cognivore](https://discourse.nixos.org/user_avatar/discourse.nixos.org/cognivore/32/7641_2.png) [@cognivore](https://discourse.nixos.org/u/cognivore)
#### Post date: [October 31, 2024, 12:19am UTC](https://discourse.nixos.org/t/github-numtide-system-manager-manage-system-config-using-nix-on-any-distro/27064/18 "2024-10-31T00:19:38Z")

</div>

I wonder how do you use system-manager on a standalone install?

What I do is:

```auto
sudo $(which system-manager) switch --flake .

```

If I run it without sudo, rust tells me it needs [root permission](https://github.com/numtide/system-manager/blob/2272979512e9fd29325b6553fd038b4fb8b339ca/src/main.rs#L436).

But when I run it with `sudo`, it bricks my nix storage!

---

<div class="post-metadata">

### Author: ![waffle8946](https://discourse.nixos.org/user_avatar/discourse.nixos.org/waffle8946/32/27221_2.png) [@waffle8946](https://discourse.nixos.org/u/waffle8946)
#### Post date: [October 31, 2024, 1:06am UTC](https://discourse.nixos.org/t/github-numtide-system-manager-manage-system-config-using-nix-on-any-distro/27064/19 "2024-10-31T01:06:25Z")

</div>

I’d suggest a new topic, with more details of what your code looks like and what happened.

---

<div class="post-metadata">

### Author: ![R-VdP](https://discourse.nixos.org/user_avatar/discourse.nixos.org/r-vdp/32/2079_2.png) [@R-VdP](https://discourse.nixos.org/u/R-VdP)
#### Post date: [October 31, 2024, 10:18am UTC](https://discourse.nixos.org/t/github-numtide-system-manager-manage-system-config-using-nix-on-any-distro/27064/20 "2024-10-31T10:18:27Z")

</div>

What do you mean by “it bricks my nix storage”?

---

<div class="post-metadata">

### Author: ![cognivore](https://discourse.nixos.org/user_avatar/discourse.nixos.org/cognivore/32/7641_2.png) [@cognivore](https://discourse.nixos.org/u/cognivore)
#### Post date: [October 31, 2024, 3:04pm UTC](https://discourse.nixos.org/t/github-numtide-system-manager-manage-system-config-using-nix-on-any-distro/27064/21 "2024-10-31T15:04:32Z")

</div>

What I meant is that it rewrites permissions!

But upon closer inspection, I realised that the host I was working on indeed had a single-user install!

I have reinstalled Nix in multi-user mode, nix daemon started working and now system-manager just works!

Sorry for causing commotion.
