Skip to content

flakeModules

flake-file ships several flakeModules. Import only what you need.

The base module. Provides all flake-file.* options, the write-flake app, and flake checks.

{ inputs, ... }: {
imports = [ inputs.flake-file.flakeModules.default ];
}

Source: modules/default.nix

Adds import-tree — auto-import all .nix files from a directory.

Source: modules/import-tree.nix

A batteries-included setup for Dendritic projects. Includes:

  • flakeModules.default
  • flakeModules.import-tree
  • flake-parts
  • Default outputs set to inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } (inputs.import-tree ./modules)
{ inputs, lib, ... }: {
imports = [ inputs.flake-file.flakeModules.dendritic ];
flake-file = {
description = "My Awesome Flake";
inputs.nixpkgs.url = lib.mkDefault "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.zst";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
}

Source: modules/dendritic/default.nix

Integrates flake-parts-builder. Loads parts from a directory and reads each part’s _meta/ as flake-file configs.

{ inputs, ... }: {
imports = [
(inputs.flake-file.lib.flakeModules.flake-parts-builder ./flake-parts)
];
}

See flake-parts-builder guide for details.

Source: modules/flake-parts-builder/default.nix

Enables automatic flake.lock flattening using spikespaz/allfollow.

Source: modules/prune-lock/allfollow.nix

Enables automatic flake.lock flattening using fzakaria/nix-auto-follow.

Source: modules/prune-lock/nix-auto-follow.nix

Enables automatic follows declarations maintained by flake-edit follow. This is an alternative to the lock-flattening modules above.

Source: modules/auto-follow.nix

Defines flake-file options for npins-based environments. Exposes write-npins. Supports github, gitlab, channel, tarball, and git schemes. Respects follows for deduplication. Prunes stale pins automatically.

Source: modules/npins

Defines flake-file options for lon-based environments. Exposes write-lon, which writes lon.nix and lon.lock. Same input handling as flakeModules.npins (schemes, transitive discovery, follows, pruning); channels and plain URLs are pinned as tarball sources.

Set flake-file.lon.lockDir to keep lon.nix, lon.lock and their sidecar files in a subdirectory instead of the flake root, e.g. flake-file.lon.lockDir = "lon" writes lon/lon.lock. Default: ".".

Source: modules/lon

Defines flake-file options for niv-based environments. Exposes write-niv, which writes nix/sources.json and nix/sources.nix. Same input handling as flakeModules.npins; channels and plain URLs are pinned as tarball sources.

Source: modules/niv

A pin file has nowhere to record a follows, so write-npins, write-lon and write-niv write the follows declared in flake-file.inputs (at any nesting level) to a Nix file next to the lock: npins/follows.nix, lon-follows.nix or nix/follows.nix. For example, flake-file.inputs.flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs" becomes { flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs"; }.

Pass it to with-inputs as its overrides, so a followed input such as flake-parts’ nixpkgs-lib resolves to your nixpkgs pin instead of a missing one:

let
sources = import ./npins;
with-inputs = import sources.with-inputs;
in
with-inputs sources [ ./npins/follows.nix ] outputs

Other overrides can go after it in the list, or be merged into it with //. Commit it alongside the lock; it is rewritten on every run.

write-npins, write-lon and write-niv record the URL each pin was added from in a small file next to the lock: npins/flake-file-urls.tsv, lon-flake-file-urls.tsv or nix/flake-file-urls.tsv. On the next run, a pin whose declared URL changed is removed and re-added; an unchanged pin keeps its locked revision. The lock files themselves don’t record the declared URL in a form that can be compared, which is why a separate file is needed.

Commit it alongside the lock. Without it, another checkout (or CI) can’t tell that an input’s URL changed and keeps the old pin. A pin with no entry in the file, such as one created before the file existed, is kept as it is.

To not keep the file, set flake-file.trackPinUrls = false. No sidecar is then written or read, and an existing pin is never re-added when its URL changes; delete the pin (for example npins remove <name>) to re-pin it.

Defines flake-file options for unflake-based environments. Exposes write-unflake.

Source: modules/unflake

Defines flake-file options for tack-based environments: flake-like TOML pins, lazily fetched, with no flake.lock. Exposes write-tack, which renders flake-file.inputs into .tack/pins.toml and runs tack update to produce .tack/pins.lock.json. Extends flake-file.inputs.<name> with tackType (flake/fetch/fixed) and unpack (tarball/file) pin fields. Configure via flake-file.tack.* (package, shorturls, all-follow rules, recomposability, resolver overrides).

Source: modules/tack

Contribute Community Sponsor