Skip to content

feat: Replace flake-utils input with plain nixpkgs.lib.genAttrs - #4

Open
sestrella wants to merge 2 commits into
herdrdev:mainfrom
sestrella:remove-flake-utils
Open

feat: Replace flake-utils input with plain nixpkgs.lib.genAttrs#4
sestrella wants to merge 2 commits into
herdrdev:mainfrom
sestrella:remove-flake-utils

Conversation

@sestrella

@sestrella sestrella commented Sep 12, 2026

Copy link
Copy Markdown

The eachDefaultSystem function from flake-utils can be replaced with the following code snippet:

systems = [
  "aarch64-darwin"
  "aarch64-linux"
  "x86_64-darwin"
  "x86_64-linux"
];
forAllSystems = nixpkgs.lib.genAttrs systems;

This reduces the dependency footprint for the Nix flake, as it is explained in the following article:

nixpkgs.lib.genAttrs offers a more direct, built-in alternative. Using it with an explicit list of systems gives you clear control without an extra dependency.

Source: https://nixcademy.com/posts/1000-instances-of-flake-utils/

Additionally, nixpkgs.legacyPackages.${system} is used in favor of import nixpkgs { inherit system; } to avoid creating too many instances of nixpkgs as it is explained in the following article:

Instead of instantiating a new nixpkgs, access nixpkgs.legacyPackages.$ and then make sure that all dependencies use the same instance of nixpkgs.

Source: https://zimbatm.com/notes/1000-instances-of-nixpkgs/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant