1

Is it possible to grow a Nix (the package manager, not nixos the distro) based linux system from scratch? More specifically:

  1. AFAIK Nix provides infrastructural packages like glibc, gcc, linux kernel, etc. Does that mean one won't need to build these manually, like in LFS?

  2. Nixos itself uses systemd, but I am aware of not-os, which is based on runit. How much do nixpkg packages depend on systemd?

  3. Nixos seems to support grub as bootloader only. Can one use EFI-stub boot, together with dracut or hand-rolled initcpio, with Nix?

If you are curious, this is why:

  1. I like gentoo's USE flags, but get somewhat tired of gentoo's frequent dependency hell and world re-compiling (especially in terms of python versioning, though that's not gentoo's fault essentially lol). So I am seeking a package manager that has decent support for both source-based and binary packages, and with simpler dependency handling. I have wandered between Arch (Artix) and Void, but in both case one have to manage source packages manually. At last I found Nix a perfect fit.

  2. Purely for fun and aesthetic reasons, I would like to try a non-systemd distro.

  3. I prefer EFI-stub.

  4. I use ZFS as the root filesystem, which needs special initcpio.

3

The short answer is, yes, you can roll your own Linux distro using Nix and Nixpkgs as a foundation.

AFAIK Nix provides infrastructural packages like glibc, gcc, linux kernel, etc. Does that mean one won't need to build these manually, like in LFS? Correct. You should be able to use the existing packages.

Nixos itself uses systemd, but I am aware of not-os, which is based on runit. How much do nixpkg packages depend on systemd? It's hard to say, given that Nixpkgs and NixOS live in the same Git repo. Nixpkgs should not depend on systemd (outside of providing the systemd packages), but there may be some dependencies on it.

Nixos seems to support grub as bootloader only. Can one use EFI-stub boot, together with dracut or hand-rolled initcpio, with Nix? NixOS supports systemd-boot and GRUB. I can't think of a reason why it would be impossible to support other bootloaders.

5
  • Good to hear (1). For (2), I mean service files of the packages. I am not hopeful that packages with services will have other init support... For (3), what about maintenance? i.e. does using bootloaders not supported by Nixos mean that I must maintain these bootloaders (and initcpio) myself?
    – Guest0x0
    Jun 6 '20 at 3:46
  • NixOS doesn't use any service files which may come with packages. NixOS modules are used to generate systemd services. You'd have to maintain Nix expressions, scripts, and something akin to nixos-rebuild in order to build an OS with Nix/Nixpkgs. There's an academic paper about the early design of NixOS, which may give you valuable insight. Jun 6 '20 at 13:55
  • 2
    Sometimes a NixOS service uses systemd units provided by the package itself; see git grep '\<systemd\.packages\>' (perhaps coming from upstream). The systemd override mechanism helps such usage. Jun 6 '20 at 16:55
  • @EmmanuelRosa The paper is a good read, I see the basic idea of services in NixOS now. So without NixOS, one would not get any service scripts/systemd unit files, and NixOS seem to only provide the latter. But I wonder how Nix users on Mac get services?
    – Guest0x0
    Jun 7 '20 at 7:16
  • I'm not sure that Mac users, nor just Nix users on other distros, get services. Nix on its own doesn't handle that, so to get services outside of Nix you'd have to do a custom integration. Jun 7 '20 at 23:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.