FOLLOW UP: (Probably) Don’t do this. After using this pattern more extensively, I realized that recursively updating locks, or creating giant lists of follows
declarations was incredibly tedious.
Instead I recommend that you import flakes where you actually use them - OR USE A REGISTRY. In retrospect I see that what I was doing here, was literally what registries were for, so I was using the wrong tool for the job.
Hey so I have been learning to use flakes a bit more, and started working on converting several of my existing package overlays to be individual flakes.
I am hoping to get feedback critique on my understanding and my approach so far. For context I use several NixOS machines at home with flakes enabled and home-manager
setup through NixOS, and at work I run a RHEL box with nix
/nixpkgs
without flakes or home-manager.
My approach so far was to create individual git
repos for each of my packages with a flake.nix
, overlay.nix
, and default.nix
in each of them. Then I made a single git
repo that aims to “collect” all of my flakes/overlays into a package set. The goal being that on my NixOS boxes I could add just add the collection to my /etc/nixos/flake.nix
and on my RHEL box I could add the overlays. So far I have only really been testing things on my NixOS boxes and am hoping to iron out any quirks there, I imagine I’ll have to get creative with the overlay collection on the RHEL box. Some flake documentation make it seem like the nix flake init -t templates#compat;
may be less painful than the old way of managing channels to merge collections so hopefully things won’t be too nasty for the RHEL stuff.
I will just post the snippet from my “collection” flake.nix
file, which I am calling ak-nix
. So far the collection contains only two packages set_wm_class
and ak-core
. I “merge” the sub-flakes’ modules and overlays in the ak-nix
flake which is really the part of my approach that I am least confident about. Let me know if this seems reasonable :
{
description = "A collection of aakropotkin's nix flakes";
inputs.nixpkgs.follows = "nix/nixpkgs";
inputs.set_wm_class.url = "github:aakropotkin/set_wm_class";
inputs.ak-core.url = "github:aakropotkin/ak-core";
outputs = { self, nixpkgs, set_wm_class, ak-core, nix, ... }: {
packages.x86_64-linux =
set_wm_class.packages.x86_64-linux //
ak-core.packages.x86_64-linux;
overlays.set_wm_class = set_wm_class.overlay;
overlays.ak-core = ak-core.overlay;
overlays.ak-nix = final: prev:
( set_wm_class.overlay final prev ) //
( ak-core.overlay final prev );
overlay = self.overlays.ak-nix;
nixosModules.set_wm_class = set_wm_class.nixosModule;
nixosModules.ak-core = ak-core.nixosModule;
nixosModules.ak-nix = { pkgs, ... }@args:
( set_wm_class.nixosModule args ) //
( ak-core.nixosModule args );
nixosModule = self.nixosModules.ak-nix;
};
}
Follow up: this did actually work for my NixOS setups. I’m not sure it’s the intended pattern, but my packages definitely install as expected.