1.7 KiB
Discover Nix files
Rule
Use util.collectNixFiles to discover Nix files.
Do not use builtins.readDir with a .nix suffix filter for this purpose.
Pass util to Nix functions that need the helper.
Rationale
util.collectNixFiles centralizes recursive discovery of Nix files.
Repository Nix code uses one implementation.
Remove Nix file suffixes with the utility
Rule
Use util.removeNixSuffix to derive a Nix name from a path.
Do not call lib.removeSuffix ".nix" outside the utility definition.
Rationale
The utility centralizes Nix file-name normalization.
Use executable helpers for package commands
Rule
Use lib.getExe when invoking a package's main executable.
Use lib.getExe' when invoking a non-main executable from a package.
Do not build executable paths with "${pkg}/bin/name" when an executable helper can name the target.
Use lib.getExe' config.programs.<name>.package "tool" when a command must follow a configured package option.
Rationale
Executable helpers use the package output that contains binaries.
They also make package ownership explicit.
lib.getExe' avoids accidentally resolving a package's main executable when code needs a different tool.
Prefer NixOS package ownership for commands
Rule
Use pkgs.<name> for Home Manager tools.
Use config.programs.<name>.package when a NixOS module owns the selected package.
Do not read config.home-manager.users.<user>.programs.<name>.package for command paths.
Rationale
Home Manager uses the NixOS package set in this repository.
Referencing pkgs.<name> avoids needless dependency paths through the Home Manager user tree.
Configured NixOS package options preserve the selected package when a module owns the tool.