❄️ Simplify Nix Flakes with the module system https://flake.parts
Find a file
Robert Hensing f7c1a2d347
Merge pull request #355 from hercules-ci/fix-doc-for-isolated-doc-evals
doc: fix touchup link for isolated doc evals
2026-05-14 00:57:42 +01:00
dev feat(flakeModules): add packages etc for disabledModules 2026-05-04 14:18:29 +02:00
examples examples/shell-environments/README: typo 2023-07-04 12:19:47 +02:00
extras Merge pull request #324 from hercules-ci/issue-323 2026-05-04 13:21:06 +01:00
lib/memoize Memoize undeclared systems 2025-07-21 20:07:18 +02:00
modules doc: fix touchup link for isolated doc evals 2026-05-14 01:43:50 +02:00
template docs: Clarify internal vs. external import in template 2025-10-18 13:34:14 +02:00
vendor/flake-compat Update and vendor flake-compat 2025-11-06 15:35:41 +01:00
.envrc chore(dev): add direnv 2026-05-02 23:30:50 +01:00
.gitignore chore(dev): add direnv 2026-05-02 23:30:50 +01:00
bors.toml Add bors bot 2022-05-19 09:48:46 +02:00
ChangeLog.md ChangeLog: Document earlier breaking change and deprecations 2026-01-05 11:34:31 +01:00
CONTRIBUTING.md CONTRIBUTING.md: More rules on request 2023-05-07 13:25:12 +02:00
flake.lock flake.lock: Update 2026-05-01 23:35:20 +00:00
flake.nix lib: use builtinModules and extraModules instead of hardcoded paths 2026-05-04 18:41:42 +03:00
lib.nix lib: use builtinModules and extraModules instead of hardcoded paths 2026-05-04 18:41:42 +03:00
LICENSE Initial commit 2021-10-27 11:03:43 +02:00
README.md Add quote by Pol Dellaiera to readme 2025-05-03 17:07:46 +07:00
shell.nix Dogfood flakeModules.partitions 2024-08-29 14:03:28 +02:00

Flake Parts

Core of a distributed framework for writing Nix Flakes.

flake-parts provides the options that represent standard flake attributes and establishes a way of working with system. Opinionated features are provided by an ecosystem of modules that you can import.

flake-parts itself has the goal to be a minimal mirror of the Nix flake schema. Used by itself, it is very lightweight.

It is definitely the best Flake framework and it is simply out of this world!

—Pol Dellaiera (source)


Documentation: flake.parts


Why Modules?

Flakes are configuration. The module system lets you refactor configuration into modules that can be shared.

It reduces the proliferation of custom Nix glue code, similar to what the module system has done for NixOS configurations.

Unlike NixOS, but following Flakes' spirit, flake-parts is not a monorepo with the implied goal of absorbing all of open source, but rather a single module that other repositories can build upon, while ensuring a baseline level of compatibility: the core attributes that constitute a flake.

Features

  • Split your flake.nix into focused units, each in their own file.

  • Take care of system.

  • Allow users of your library flake to easily integrate your generated flake outputs into their flake.

  • Reuse project logic written by others

Getting Started

If your project does not have a flake yet:

nix flake init -t github:hercules-ci/flake-parts

Migrate

Otherwise, add the input,

    flake-parts.url = "github:hercules-ci/flake-parts";

then slide mkFlake between your outputs function head and body,

  outputs = inputs@{ flake-parts, ... }:
    flake-parts.lib.mkFlake { inherit inputs; } {
      flake = {
        # Put your original flake attributes here.
      };
      systems = [
        # systems for which you want to build the `perSystem` attributes
        "x86_64-linux"
        # ...
      ];
    };

Now you can add the remaining module attributes like in the the template.

Templates

See the template.

Examples

See the examples/ directory.

Projects using flake-parts

Options Reference

See flake.parts options