1
0
Fork 0
mirror of https://github.com/hercules-ci/flake-parts.git synced 2024-12-14 11:47:31 +00:00
❄️ Simplify Nix Flakes with the module system
Find a file
Hercules CI Effects 6e7574aa8f dev/flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/71e88077ca0d82ca09cb3f4975fb96d1313607fb' (2024-07-01)
  → 'github:NixOS/nixpkgs/fcdc2b93639594f48bcf00d675fc015ccacf9b79' (2024-08-01)
• Updated input 'pre-commit-hooks-nix':
    'github:cachix/pre-commit-hooks.nix/0ff4381bbb8f7a52ca4a851660fc7a437a4c6e07' (2024-06-24)
  → 'github:cachix/pre-commit-hooks.nix/f451c19376071a90d8c58ab1a953c6e9840527fd' (2024-07-15)
• Updated input 'pre-commit-hooks-nix/nixpkgs-stable':
    'github:NixOS/nixpkgs/03d771e513ce90147b65fe922d87d3a0356fc125' (2024-06-19)
  → 'github:NixOS/nixpkgs/194846768975b7ad2c4988bdb82572c00222c0d7' (2024-07-07)
2024-08-01 23:35:51 +00:00
dev dev/flake.lock: Update 2024-08-01 23:35:51 +00:00
examples examples/shell-environments/README: typo 2023-07-04 12:19:47 +02:00
extras Add class: imports "type checking" 2024-05-16 15:09:50 +02:00
modules Add class: imports "type checking" 2024-05-16 15:09:50 +02:00
template template/package: Use fileset 2024-06-30 12:54:51 +02:00
.gitignore Unignore flake.lock. We use a committed lock now. 2022-11-12 16:38:48 +01:00
all-modules.nix remove unused code 2023-05-29 13:52:03 -04:00
bors.toml Add bors bot 2022-05-19 09:48:46 +02:00
ChangeLog.md Update ChangeLog 2023-05-30 15:43:56 +02:00
ci.nix dev: Add nixpkgs-fmt to pre-commit 2022-05-17 10:37:27 +02:00
CONTRIBUTING.md CONTRIBUTING.md: More rules on request 2023-05-07 13:25:12 +02:00
flake.lock flake.lock: Update 2024-08-01 23:35:39 +00:00
flake.nix flake.nix: Update nixpkgs-lib tree 2024-08-01 23:35:38 +00:00
lib.nix Merge pull request #154 from hercules-ci/class 2024-05-16 15:16:44 +02:00
LICENSE Initial commit 2021-10-27 11:03:43 +02:00
README.md docs: update to comments 2023-06-30 09:31:36 +02:00
shell.nix Add local tooling and CI wiring without bloating flake.nix 2022-05-17 10:12:40 +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.


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