How to have a minimal NixOS?

I really dig nixos’ design, and would like to use it for my linux servers too.

I wonder if it’s possible to ask nix to skip installing things that are usually not very useful in a server context, like man pages or i18n files?

I also wonder, does the the concept of suggested and recommended packages in the Debian world exist in nix, where you can limit the optional dependencies to install with?

I searched around, but couldn’t find anything useful.

1 Like

You can disabled man pages with and for 22.11 only C and us.utf8 locales are build by default.

Not really. Some packages have optional flags to disable some features but then you often need to compile them yourself. NixOS modules on the other hand have often options to disable certain parts.

You can disabled man pages with

Didn’t know it’s that easy. Thanks

Some packages have optional flags to disable some features but then you often need to compile them yourself.

I don’t mind compiling things myself and I’d prefer compiling things not on the servers themselves. I guess nixos must have a way of installing from custom repo where precompiled packages live. Does there exist some doc that explain how to set up such a repo and how to make nixos use it?

1 Like

You can get rid of most fluff with something like this:

  imports = [

  # only add strictly necessary modules
  boot.initrd.includeDefaultModules = false;
  boot.initrd.kernelModules = [ "ext4" ... ];
  disabledModules =
    [ <nixpkgs/nixos/modules/profiles/all-hardware.nix>

  # disable useless software
  environment.defaultPackages = [];
  xdg.icons.enable  = false;
  xdg.mime.enable   = false;
  xdg.sounds.enable = false;

There is this chapter in the nix manual: Sharing Packages Between Machines

Also this wiki entry: Binary Cache - NixOS Wiki

Depending on your use case, you can also build your system locally and then scp the built binaries to the remote and “activate” them. nixos-rebuild has some built-in features for that: nixpkgs/ at c5432c121ecf2b91fec7e8520f9f75fd6f507333 · NixOS/nixpkgs · GitHub

If there’s documentation for those flags outside of nixos-rebuild --help I’ve yet to see it. But this is a very useful feature for small deployments where setting up a third server just to act as a build cache is overkill.

There are also some useful deploy tools that reimplement this as flake attributes, instead of CLI flags you need to remember: GitHub - serokell/deploy-rs: A simple multi-profile Nix-flake deploy tool. and GitHub - zhaofengli/colmena: A simple, stateless NixOS deployment tool


@rnhmjoj @TLATER

These are tremendously helpful! Thanks a lot.