which as expected tries to build the whole NixOS system.
Is there a way for me to trim this down? I.e. tell it not to install any packages except those I explicitly told it to install in the configuration (and perhaps some that are absolutely necessary). I assume there’s some default list of packages somewhere that I should turn off or something.
Keep in mind many derivations are not packages in the traditional sense. That number is going to need to be fairly high just to have a nixos system at all. Every config file, random glue script that holds bits of things together, etc, is going to get its own derivation, generally.
Many such derivations are trivial to build and store, so the number of them is not really indicative of the amount of work involved.
@tejing My problem is that when I do the above without --dry-run it starts downloading packages and says it will download ~2G and install more than 2x that - here’s a snapshot:
An OS is an OS… they take up space. Pretty much any linux distro is going to take up multiple gigabytes on disk these days. I don’t think you can get around that.
It does only download packages installed/mentioned/configured.
Apparently it is downloading way more than I explicitly configured, because I configured none So either I’m not doing this right or there must be a default somewhere. If there’s a way to explicitly tell it to not install anything and start building from there, I’d like to explore that.
If you don’t want that stick to stable.
I don’t see this as a stable / unstable issue. I’m on a non-NixOS OS and just running nix to test the configuration. I’m trying to get it to build the smallest subset possible basically.
I.e. I want to build the smallest possible NixOS system + whatever select packages I’m currently interested in while doing the building itself outside of NixOS, if that makes sense.
So, depending on what you need, there’s almost an order of magnitude difference in size.
I understand why NixOS by default wants to build a lot of packages, that’s a sensible default. I’m looking to trim that down as much as possible basically. To take Ubuntu example, I’d like to go from the 2G desktop to 240M core (and even further if possible!), as for this particular testing I don’t care about most of the packages.
Minimal iso will still be huge for their purposes. But yeah, they will need to disable more of the defaults since this is not really a goal of NixOS.
Minimal profile might help a bit:
Though environment.noXlibs option also overrides Nixpkgs packages so you will not be able to use binary cache for majority of those and most stuff will be broken.
Another thing you can try is to look at what derivations are in your build closure and then guess what module installs them:
nix-store --query --tree $(nix-instantiate -A outputs.nixosConfigurations.joke.config.system.build.toplevel)