Nix: structuring Flakes with Blueprint

Probably not as-is, but I can see blueprint becoming a source of inspiration (among other projects) when designing the next iteration of flakes, once the current implementation has been marked as stable. Ideally flakes would be low overhead out of the box.

4 Likes

once the current implementation has been marked as stable

I’ll see you in 2060!

Hi. I’m new to NixOS, and right now I’m deciding on what to use as my starter config, since I’m using just default configuration.nix right now, with some added options.
I’ve stumbled upon Misterio77’s starter-configs at first, but after reading some posts and issues, I’ve found out about this nixpkgs problem. I’m still looking for a template that would implement the best practices of NixOS, and Blueprint seems promising, but, as I understand, it has the same problem @waffle8946 has wrote about.
As I am a new user, it’s hard for me to wrap my head around. Could someone explain it to me?

  • Does this mean I shouldn’t use this project?
  • What are the practical consequences? Does it mean that the packages are stored multiple times on disk, or downloaded multiple times?
  • Is there a better alternative?

I can give one example:

I have a blueprint with a host that has is cross compiled (its a resource constrained pi):

# ./hosts/pi-homeautomator.nix
{ pkgs,... }: {
  nixpkgs.hostPlaform = "aarch64-linux";
  nixpkgs.buildPlatform = "x86_64-linux";
}

Now i want to consume a package from the flake. If it’s an overlay this just works. In another scenario I’m now stuck.

3 Likes

I wonder if we would make packages defined using nixpkgs fixpoint lib, as opposed to the built in fixpoint in flakes; then at least the result can be spliced and you can call extend on the set or convert the set to a pkgsCross version. The problem is that flakes builtin fixpoint (the inputs param) makes all the nixpkgs cross compiling infra useless as you can’t splice your package even if you neatly define it with mkDerivation. You need the callPackageWith stuff

1 Like

I think I would go deeper and look at how to get access to the flake fixpoint to make them programatically overridable.

Blueprint could solve this by having its own interface. Have a compatibility layer that maps the blueprint outputs to flake outputs. And if any other input is a blueprint, detect that and bypass the flake schema entirely. That’s something I have been experimenting with, but it also introduces more complexity and questions to solve.

The 1000 instances of nixpkgs problem is only an issue for producers. Aka flakes that are going to be consumed by other flakes. In your case, this is the root flake, so you don’t have to worry about this.

Generally speaking my recommendation is not to worry too much. You’re going to mess things up, and it’s going to be fine. Pick a started template where you feel you can get things done, it’s always possible to move things around later.

If you pick blueprint, don’t hesitate to create issues whenever you get stuck, so I can improve the documentation. I love getting the fresh user’s perspective on things.

4 Likes

I think I accidentally stubled onto some nice design, because I keep getting feedbacks like this (I asked Oli if I could share):

image

5 Likes