NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.7k stars 13.15k forks source link

`profiles/minimal.nix` module forces big rebuilds of packages #319102

Open qaristote opened 1 month ago

qaristote commented 1 month ago

Describe the bug

Importing the profiles/minimal.nix module forces some packages to be built locally because their derivations change. For some of these packages the build process is very resource consuming, hence not feasible for small machines, which are one of the targets of the profiles/minimal.nix module.

Additional context

Here's an example: I have a router with low resources (4GB of RAM and a 2GB swap file) running NixOS under nixpkgs release-24.05, on which I enabled the Kea DHCP server. I have the profiles/minimal.nix module imported, and building my configuration locally results in the machine crashing as it runs out of memory. This happens because NixOS tries to build Kea locally, as it needs a version that is not cached:

❯ nixos-rebuild dry-build --flake . --impure 2>&1 >/dev/null | grep kea
  /nix/store/6klgj1gdd6y2i94ijkd4q8h8qhraxga3-kea-2.4.1.drv
  ...

When I disable the profiles/minimal.nix module, NixOS correctly fetches Kea from the cachix instance:

❯ nixos-rebuild dry-build --flake . --impure 2>&1 >/dev/null | grep kea
  ...
  /nix/store/jb5s4ifjiw4ajgjirylxg7v18j5zshk8-kea-2.4.1
  ...

This version is indeed the one that's cached:

❯ nix build github:NixOS/nixpkgs/release-24.05#kea
❯ ls -l result
result -> /nix/store/jb5s4ifjiw4ajgjirylxg7v18j5zshk8-kea-2.4.1

Here's the result of comparing the two derivations with nix-diff: I don't understand all the differences but for instance one of them is the flag --without-x which is enabled because the minimal profile disables X.

Steps To Reproduce

Build a NixOS configuration with Kea enabled and the profiles/minimal.nix module imported.

Expected behavior

While it is expected that the derivations differ, small machines shouldn't have to build these kinds of big packages locally, so I would expect that packages built with the minimal profile imported be cached as well. Unless I'm mistaken and the point of this minimal profile isn't to be used on small machines ? In that case I feel like this should be documented here for instance.

Notify maintainers

Not sure who to notify here, @SuperSandro2000 perhaps ? Sorry for the noise.


Add a :+1: reaction to issues you find important.

SuperSandro2000 commented 1 month ago

You can use the minimal profile on small machines, you just should build the configuration on a more powerful machine.

Can you do a PR to update the documentation?