nilla-nix/flake-compat
A Nix helper for loading flakes with support for replacing inputs.
{ "createdAt": "2025-05-13T01:25:35Z", "defaultBranch": "main", "description": "A Nix helper for loading flakes with support for replacing inputs.", "fullName": "nilla-nix/flake-compat", "homepage": null, "language": "Nix", "name": "flake-compat", "pushedAt": "2025-05-13T09:03:53Z", "stargazersCount": 8, "topics": [], "updatedAt": "2025-11-16T19:39:51Z", "url": "https://github.com/nilla-nix/flake-compat"}Flake Compat
Section titled “Flake Compat”Load Nix flakes with support for replacing inputs.
First, fetch this repository using either a built-in fetcher or a tool like npins.
npins init --bare
npins add github nilla-nix flake-compatWith the library fetched, you can import it and use the
compat.load function.
let pins = import ./npins;
compat = import pins.flake-compat;
flake = compat.load { # Specify the directory of the flake you want to load. src = ./.;
# Optionally specify replacements for any inputs. replacements = {}; };in flakeReplacements
Section titled “Replacements”A replacement can be specified for any Flake input named in the
associated flake.lock file. The value will be substituted directly,
so it is necessary to ensure that valid input values are used. This
means that if you are replacing an input that is loaded as a flake
then your value must also provide things like outputs, sourceInfo,
etc.
The compat.fetch and compat.lib.info.from.*
helpers simplify this process.
let pins = import ./npins;
compat = import pins.flake-compat;
flake = compat.load { src = ./.;
replacements = { nixpkgs-stable = flake.inputs.nixpkgs-unstable;
my-archive = compat.fetch (compat.lib.info.from.path ./my-archive); }; };in flake