Autowiring

An optional autowiring module is provided that will scan the directory structure and wire up the appropriate flake outputs automatically without you having to do it manually.

A ready demonstration is available in nixos-unified-template as well as srid/nixos-config. In the latter, you will notice the following directory structure:

❮ lsd --tree --depth 1 configurations modules overlays packages
📁 configurations
├── 📁 darwin
├── 📁 home
└── 📁 nixos
📁 modules
├── 📁 darwin
├── 📁 flake-parts
├── 📁 home
└── 📁 nixos
📁 overlays
└── ❄️ default.nix
📁 packages
├── ❄️ git-squash.nix
├── ❄️ sshuttle-via.nix
└── 📁 twitter-convert

Each of these are wired to the corresponding flake output, as indicated in the below table:

DirectoryFlake Output
configurations/nixos/foo.nix1nixosConfigurations.foo
configurations/darwin/foo.nix1darwinConfigurations.foo
configurations/home/foo.nix1legacyPackages.${system}.homeConfigurations.foo2
modules/nixos/foo.nixnixosModules.foo
modules/darwin/foo.nixdarwinModules.foo
modules/flake-parts/foo.nixflakeModules.foo
overlays/foo.nixoverlays.foo
1

This path could as well be configurations/nixos/foo/default.nix. Likewise for other output types.

2

Why legacyPackages? Because, creating a home-manager configuration requires pkgs. See https://github.com/nix-community/home-manager/issues/3075