# Restructuring NixOS to work without systemd? e.g., with SysVinit

**URL:** https://discourse.nixos.org/t/restructuring-nixos-to-work-without-systemd-e-g-with-sysvinit/21298
**Category:** Development
**Created:** [August 27, 2022, 7:54pm UTC](https://discourse.nixos.org/t/restructuring-nixos-to-work-without-systemd-e-g-with-sysvinit/21298 "2022-08-27T19:54:27Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![menuhin](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/m/c5a1d2/32.png) [@menuhin](https://discourse.nixos.org/u/menuhin)
#### Post date: [August 27, 2022, 7:54pm UTC](https://discourse.nixos.org/t/restructuring-nixos-to-work-without-systemd-e-g-with-sysvinit/21298/1 "2022-08-27T19:54:28Z")

</div>

How possible (or how non-trivial) is it to restructure NixOS (or a branch) so that it can work without the systemd package?

---

<div class="post-metadata">

### Author: ![fricklerhandwerk](https://discourse.nixos.org/user_avatar/discourse.nixos.org/fricklerhandwerk/32/2029_2.png) [@fricklerhandwerk](https://discourse.nixos.org/u/fricklerhandwerk)
#### Post date: [August 27, 2022, 9:23pm UTC](https://discourse.nixos.org/t/restructuring-nixos-to-work-without-systemd-e-g-with-sysvinit/21298/2 "2022-08-27T21:23:43Z")

</div>

Hi and welcome to the forum!

@pxc summarized the history and state of affairs as follows:

> [@On another topic](https://discourse.nixos.org/t/21205/2):
>
> it’s a feature Nixpkgs has almost gotten a few times now via ambitious PRs that never quite made it:
> 
> - 2014: @offlinehacker’s [service abstraction layer](https://github.com/NixOS/nixpkgs/pull/5246)
> - 2015: @nbp’s [nix user profiles (nixup)](https://github.com/NixOS/nixpkgs/pull/4594), a proto-Home Manager
> - 2016: @ts468’s [declarative user profiles](https://github.com/NixOS/nixpkgs/pull/9250), continuation of nixup
> - 2019: @svanderburg’s [nix-processmgmt](https://github.com/svanderburg/nix-processmgmt), whose author has not made any real moves to upstream into Nixpkgs despite [writing that he hoped to do so](http://sandervanderburg.blogspot.com/2021/04/a-test-framework-for-nix-process.html) over a year ago, I suspect because he has seen the difficulties faced by the endeavors that preceded him!

Note that the complexity lies both naturally in the problem of what service management at an abstract level really is and has to do, as well as the specifics of how NixOS is tied to systemd.

---

<div class="post-metadata">

### Author: ![TLATER](https://discourse.nixos.org/user_avatar/discourse.nixos.org/tlater/32/4257_2.png) [@TLATER](https://discourse.nixos.org/u/TLATER)
#### Post date: [August 27, 2022, 9:31pm UTC](https://discourse.nixos.org/t/restructuring-nixos-to-work-without-systemd-e-g-with-sysvinit/21298/3 "2022-08-27T21:31:52Z")

</div>

It’s probably just going to get harder, too. The initrd is slowly being migrated to systemd as well.

---

<div class="post-metadata">

### Author: ![ElvishJerricco](https://discourse.nixos.org/user_avatar/discourse.nixos.org/elvishjerricco/32/984_2.png) [@ElvishJerricco](https://discourse.nixos.org/u/ElvishJerricco)
#### Post date: [August 27, 2022, 9:43pm UTC](https://discourse.nixos.org/t/restructuring-nixos-to-work-without-systemd-e-g-with-sysvinit/21298/4 "2022-08-27T21:43:22Z")

</div>

I think the ship has sailed for NixOS to use anything other than systemd. I’m not just saying that because I quite like systemd; NixOS is just actually quite heavily dependent on it at this point. I think it’d be really cool to see alternative distros built with Nix that use other systems and provide NixOS-compatible modules for non-systemd-related options. But I _do_ think those would effectively have to be one or more “new distros” (there’d be a ton in common with NixOS so it’s weird to say “new distro”).

---

<div class="post-metadata">

### Author: ![blaggacao](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@blaggacao](https://discourse.nixos.org/u/blaggacao)
#### Post date: [August 28, 2022, 3:33am UTC](https://discourse.nixos.org/t/restructuring-nixos-to-work-without-systemd-e-g-with-sysvinit/21298/5 "2022-08-28T03:33:26Z")

</div>

In the tone and spirit of what @fricklerhandwerk said, I want to add that service management / scheduling has probably seen unprecedented expansion of it’s domain ranging from cluster/data-center schedulers (mesos, k8s, nomad) to development environment service managers (docker-compose, foreman, hivemind, etc).

NixOS, in and of itself, is a superset of a service library.

Service Managers probably always have some common (and in principle abstractable) interfaces. If clarity is produced, that might not even be too hard. Such generic interfaces are probably:

- Capabilites-based Scheduling (including resources)
- Liveness & Readiness
- Dependency Management
- Environment Preparation
- Capabilities Management (in isolating schedulers)
- Upgrade/Migration paths (sometimes)

Finding an interface that could sufficiently satisfy the subset of the common denominator between the various implementations, might actually not even be too hard. It would be a subset that would forgo some scheduler-specific features.

It would make the above mentioned service library potentially extremely more useful. And would probably also help tear down some current ecosystem boundaries: e.g. have a service library for X thousand services across k8s, nomad, sytemd would immitate the enormous business value that the Nix Package Collection already provides, just for services.

Migrating `nixpkgs/nixos` is another beast, of course, as may it be finding an interface that provides scheduler specific escape hatches…

---

<div class="post-metadata">

### Author: ![peterhoeg](https://discourse.nixos.org/user_avatar/discourse.nixos.org/peterhoeg/32/137_2.png) [@peterhoeg](https://discourse.nixos.org/u/peterhoeg)
#### Post date: [August 28, 2022, 4:17am UTC](https://discourse.nixos.org/t/restructuring-nixos-to-work-without-systemd-e-g-with-sysvinit/21298/6 "2022-08-28T04:17:46Z")

</div>

> How possible (or how non-trivial) is it to restructure NixOS (or a branch) so that it can work without the systemd package?

systemd, as in “systemd-as-pid-1” or “systemd-the-project”?

Because SysVinit is really only a substitute for the former. And replacing systemd with sysvinit would of course be entirely doable. It would be a lot of work and it would take features away but sure, you could do it. Some of the questions are “what problem are you trying to solve by changing” and “will this fragmentation do us any good (as a project) or harm us in the long run” so I’m guessing the chances of it happening are very slim.

As time goes by and we start depending more and more on the features provided by the systemd project, the harder it will be to change of course.

I’d be super curious to hear the justification for such a change though.

---

<div class="post-metadata">

### Author: ![JosW](https://discourse.nixos.org/user_avatar/discourse.nixos.org/josw/32/100_2.png) [@JosW](https://discourse.nixos.org/u/JosW)
#### Post date: [August 28, 2022, 9:42am UTC](https://discourse.nixos.org/t/restructuring-nixos-to-work-without-systemd-e-g-with-sysvinit/21298/7 "2022-08-28T09:42:44Z")

</div>

> [@On another topic](https://discourse.nixos.org/t/21205/2):
>
> 2019: @svanderburg’s [nix-processmgmt](https://github.com/svanderburg/nix-processmgmt), whose author has not made any real moves to upstream into Nixpkgs despite [writing that he hoped to do so](http://sandervanderburg.blogspot.com/2021/04/a-test-framework-for-nix-process.html) over a year ago, I suspect because he has seen the difficulties faced by the endeavors that preceded him!

Then again, to follow the trail on it, this gives a nice overview:

[https://sandervanderburg.blogspot.com/2019/11/a-nix-based-functional-organization-for.html](https://sandervanderburg.blogspot.com/2019/11/a-nix-based-functional-organization-for.html)

> **[A declarative process manager-agnostic deployment framework based on Nix tooling](https://sandervanderburg.blogspot.com/2020/02/a-declarative-process-manager-agnostic.html)**
>
> In a previous blog post written two months ago, I have introduced a new experimental Nix-based process framework , that provides the followi...

> **[A test framework for the Nix process management framework](https://sandervanderburg.blogspot.com/2021/04/a-test-framework-for-nix-process.html)**
>
> As already explained in many previous blog posts, the Nix process management framework adds new ideas to earlier service management concept...

[https://www.youtube.com/watch?v=6a2NOvod\_MY](https://www.youtube.com/watch?v=6a2NOvod_MY) Disnix NixCon 2015

[https://www.youtube.com/watch?v=7xDVTflSrdU](https://www.youtube.com/watch?v=7xDVTflSrdU) Dysnomia NixCon 2018

[https://www.youtube.com/watch?v=N9Dygq4Lz0c](https://www.youtube.com/watch?v=N9Dygq4Lz0c) - Nix processmgmt NixCon2020

---

<div class="post-metadata">

### Author: ![JosW](https://discourse.nixos.org/user_avatar/discourse.nixos.org/josw/32/100_2.png) [@JosW](https://discourse.nixos.org/u/JosW)
#### Post date: [August 28, 2022, 9:46am UTC](https://discourse.nixos.org/t/restructuring-nixos-to-work-without-systemd-e-g-with-sysvinit/21298/8 "2022-08-28T09:46:43Z")

</div>

And there is DisnixOS 😉

> **[GitHub - svanderburg/disnixos: DisnixOS: A Disnix extension providing...](https://github.com/svanderburg/disnixos)**
>
> DisnixOS: A Disnix extension providing complementary infrastructure deployment using NixOS - GitHub - svanderburg/disnixos: DisnixOS: A Disnix extension providing complementary infrastructure deplo...

---

<div class="post-metadata">

### Author: ![rnhmjoj](https://discourse.nixos.org/user_avatar/discourse.nixos.org/rnhmjoj/32/1792_2.png) [@rnhmjoj](https://discourse.nixos.org/u/rnhmjoj)
#### Post date: [August 28, 2022, 12:42pm UTC](https://discourse.nixos.org/t/restructuring-nixos-to-work-without-systemd-e-g-with-sysvinit/21298/9 "2022-08-28T12:42:58Z")

</div>

Realistically, I don’t think it will ever happen. Most of the NixOS options provides only a very slim layer of abstraction above systemd and many are 1:1 mapped to systemd options.

We also rely on much more than just the init and journal: containers, boot loader, file systems, logins, device dependencies, udev, and more. Some modules do have two alternative implementations, like `networking-interfaces.nix`, so it’s doable but it’s such a massive effort and most people don’t care about alternative inits.

---

<div class="post-metadata">

### Author: ![anon52471967](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/a/dc4da7/32.png) [@anon52471967](https://discourse.nixos.org/u/anon52471967)
#### Post date: [August 28, 2022, 1:17pm UTC](https://discourse.nixos.org/t/restructuring-nixos-to-work-without-systemd-e-g-with-sysvinit/21298/10 "2022-08-28T13:17:57Z")

</div>

The NixOS init system has been replaced before and it will certainly be replaced again.

---

<div class="post-metadata">

### Author: ![rnhmjoj](https://discourse.nixos.org/user_avatar/discourse.nixos.org/rnhmjoj/32/1792_2.png) [@rnhmjoj](https://discourse.nixos.org/u/rnhmjoj)
#### Post date: [August 28, 2022, 1:53pm UTC](https://discourse.nixos.org/t/restructuring-nixos-to-work-without-systemd-e-g-with-sysvinit/21298/11 "2022-08-28T13:53:35Z")

</div>

Yeah, around 2011, right? NixOS was pratically an experiment back then.  
Today it’s necessarily going to be much more difficult: there are probably 10x the modules and most services are tied to systemd hardening mechanisms like `DynamicUser`, `ProtectSystem` and `PrivateTmp` which we would have to drop (lowering the security) or reimplement.

As much as I don’t like the leadership and many design decisions of systemd, it’s extremely useful for NixOS and replacing it doesn’t make much sense. It would be interesting to make the init configurable, particularly for embedded devices with few resources, but it would probably mean losing most of the services we have now.

---

<div class="post-metadata">

### Author: ![TLATER](https://discourse.nixos.org/user_avatar/discourse.nixos.org/tlater/32/4257_2.png) [@TLATER](https://discourse.nixos.org/u/TLATER)
#### Post date: [August 28, 2022, 1:54pm UTC](https://discourse.nixos.org/t/restructuring-nixos-to-work-without-systemd-e-g-with-sysvinit/21298/12 "2022-08-28T13:54:11Z")

</div>

Could be. If there is a distro that can do so it’s NixOS, given the levels of abstraction involved. It’s still very hard to see this happening anytime soon, if at all, given the effort it would be and the limited drive behind such a thing at the moment.

---

<div class="post-metadata">

### Author: ![blaggacao](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@blaggacao](https://discourse.nixos.org/u/blaggacao)
#### Post date: [August 28, 2022, 1:59pm UTC](https://discourse.nixos.org/t/restructuring-nixos-to-work-without-systemd-e-g-with-sysvinit/21298/13 "2022-08-28T13:59:39Z")

</div>

Is it not too short-sighted or semantically skewed to look at NixOS (i.e. systemd) as _the only_ legitimate target of that massive Nix Module Service Library (i.e. `nixpkgs/nixos/*`)?

Of course, it depends on the presumed priorities. So let’s presume the goal is to make this library as generally useful and interoperable as the Nix Package Collection already is.

It probably won’t happen based on mere “scratching of itches”, given the current user base is cought in a local maximum of NixOS users, but a good vision and understanding of where we _could_ be instead, might help drive some more thought.

DisNix is a nice “path-dependent” _evolution_, but it isn’t and won’t be capable of substituting interoperability with other _very rich_ scheduler ecosystems.

---

<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: [August 28, 2022, 4:17pm UTC](https://discourse.nixos.org/t/restructuring-nixos-to-work-without-systemd-e-g-with-sysvinit/21298/14 "2022-08-28T16:17:19Z")

</div>

> [@rnhmjoj](#):
>
> Realistically, I don’t think it will ever happen. Most of the NixOS options provides only a very slim layer of abstraction above systemd and many are 1:1 mapped to systemd options.

> [@blaggacao](#):
>
> Is it not too short-sighted or semantically skewed to look at NixOS (i.e. systemd) as _the only_ legitimate target of that massive Nix Module Service Library (i.e. `nixpkgs/nixos/*` )?

This is the thing— ‘it’ (the NixOS module system being used in other ways and with other services managers) has _already_ happened— that’s what Nix-Darwin and Home Manager are. (In one case it’s a different service manager, and the other it’s systemd but not a systemd instance managed wholly by Nix.)

The actual question is whether/where/when such efforts will be integrated so that they can share code and a uniform user interface, not whether they’ll ever exist or have users and contributors. `¯\_(ツ)_/¯`

---

<div class="post-metadata">

### Author: ![Atemu](https://discourse.nixos.org/user_avatar/discourse.nixos.org/atemu/32/10383_2.png) [@Atemu](https://discourse.nixos.org/u/Atemu)
#### Post date: [August 28, 2022, 5:48pm UTC](https://discourse.nixos.org/t/restructuring-nixos-to-work-without-systemd-e-g-with-sysvinit/21298/15 "2022-08-28T17:48:15Z")

</div>

> [@rnhmjoj](#):
>
> Today it’s necessarily going to be much more difficult: there are probably 10x the modules and most services are tied to systemd hardening mechanisms like `DynamicUser` , `ProtectSystem` and `PrivateTmp` which we would have to drop (lowering the security) or reimplement.

A systemd replacement doesn’t need to implement all of systemd, nor would it have to be compatible with every module from the beginning.

In NixOS, we are empowered to have experimental things hidden behind an option without disturbing non-experimental users. See for example how easy Pipewire is to integrate.

A microcosm of this is the initrd for which we currently have a custom micro init system. Experimentally, there is also systemd for the initrd, behind an option. The two can coexist and be developed further without interfering with another.

OTOH though, there isn’t that much of a need for a non-systemd init anymore as the only other platform we could see a port of NixOS for in the near-ish future is FreeBSD for which a [systemd port](https://github.com/InitWare/InitWare) in the works.

---

<div class="post-metadata">

### Author: ![blaggacao](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@blaggacao](https://discourse.nixos.org/u/blaggacao)
#### Post date: [August 28, 2022, 6:02pm UTC](https://discourse.nixos.org/t/restructuring-nixos-to-work-without-systemd-e-g-with-sysvinit/21298/16 "2022-08-28T18:02:26Z")

</div>

> [@pxc](#):
>
> This is the thing— ‘it’ (the NixOS module system being used in other ways and with other services managers) has _already_ happened

Right, the necessity for a uniform interface is absolutly evident.

Still, it is important to take a conscientious look beyond the boundaries of the Nix Ecosystem and envision the potential value that — in casu — a “Nix [Unified] Service Library” could offer to the world.

Provided that _interoperability_ was to become a deliberate _priority_, rather than a side effect of “scratching itches”.

---

<div class="post-metadata">

### Author: ![peterhoeg](https://discourse.nixos.org/user_avatar/discourse.nixos.org/peterhoeg/32/137_2.png) [@peterhoeg](https://discourse.nixos.org/u/peterhoeg)
#### Post date: [August 29, 2022, 8:07am UTC](https://discourse.nixos.org/t/restructuring-nixos-to-work-without-systemd-e-g-with-sysvinit/21298/17 "2022-08-29T08:07:26Z")

</div>

I would still very much like to hear what problems @menuhin thinks would be solved by adding support for multiple init systems/ripping systemd out in favour of something else.

Probably easier to address **those** than adding support for something else. And then testing that. And making sure that things don’t break. And keeping up the development/release velocity.

---

<div class="post-metadata">

### Author: ![Sandro](https://discourse.nixos.org/user_avatar/discourse.nixos.org/sandro/32/2865_2.png) [@Sandro](https://discourse.nixos.org/u/Sandro)
#### Post date: [August 29, 2022, 11:35am UTC](https://discourse.nixos.org/t/restructuring-nixos-to-work-without-systemd-e-g-with-sysvinit/21298/18 "2022-08-29T11:35:04Z")

</div>

I fail to see the improvement by replacing systemd with fiddly pile of shell scripts.

Removing only the systemd package is quite possible if you are on another distro or operating system like MacOS.

---

<div class="post-metadata">

### Author: ![Sandro](https://discourse.nixos.org/user_avatar/discourse.nixos.org/sandro/32/2865_2.png) [@Sandro](https://discourse.nixos.org/u/Sandro)
#### Post date: [August 29, 2022, 11:57am UTC](https://discourse.nixos.org/t/restructuring-nixos-to-work-without-systemd-e-g-with-sysvinit/21298/20 "2022-08-29T11:57:00Z")

</div>

> A lighter and simpler design, due to the omission of systemd

Those claims only hold true if you need parts of systemd like in a container. If you are going to replace every function of systemd with its own project then you have a more complicated, harder to maintain and less integrated software stack.

---

<div class="post-metadata">

### Author: ![menuhin](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/m/c5a1d2/32.png) [@menuhin](https://discourse.nixos.org/u/menuhin)
#### Post date: [September 10, 2022, 7:34pm UTC](https://discourse.nixos.org/t/restructuring-nixos-to-work-without-systemd-e-g-with-sysvinit/21298/21 "2022-09-10T19:34:16Z")

</div>

The way systemd takes up the “responsibility of further providing features” make the life of developers and system admins perhaps easily.  
But as the complexity of systemd builds up, it’s becoming alarming. And while we are all depending on it because of convenience, similar projects such as launchd of MacOS while handling jobs in similar ways, has only around 30K lines of code while systemd has well over 1M lines of code, and it is still continuing to engulf other functions. Further information: UNIX Version 7 was a complete, production-quality operating system written in about ten thousand lines of code.

There are endless number of patches to fix errors during the development of systemd (e.g. [widespread outage caused by systemd](https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1988119)), and as the vulnerability both in failing and in being attacked of a system correlates to its complexity, this one single pillar that everyone relies will inevitably fail one day. But then the problem is the way to “building a way out” of this MS-registry like style will probably be even more difficult.

[Next page](https://discourse.nixos.org/t/restructuring-nixos-to-work-without-systemd-e-g-with-sysvinit/21298.md?page=2)
