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
Robert Hensing d591857e9d
Merge pull request #73 from hercules-ci/tidy-readme
Remove docs that have been moved to flake.parts and improved
2022-11-14 19:36:17 +01:00
dev Explain hci effect tests 2022-11-13 12:25:55 +01:00
modules formatter: Use markdown 2022-11-13 11:51:28 +01:00
template Only depend on nixpkgs/lib. 2022-10-11 13:59:40 -04:00
.gitignore Unignore flake.lock. We use a committed lock now. 2022-11-12 16:38:48 +01:00
all-modules.nix Generalize transposed attributes 2022-10-26 14:06:02 +02:00
bors.toml Add bors bot 2022-05-19 09:48:46 +02:00
ChangeLog.md Update ChangeLog.md 2022-10-11 19:20:13 +01:00
ci.nix dev: Add nixpkgs-fmt to pre-commit 2022-05-17 10:37:27 +02:00
flake.lock Only depend on nixpkgs/lib. 2022-10-11 13:59:40 -04:00
flake.nix Only depend on nixpkgs/lib. 2022-10-11 13:59:40 -04:00
lib.nix Remove redundant lib.mdDoc 2022-11-11 07:41:10 +01:00
LICENSE Initial commit 2021-10-27 11:03:43 +02:00
README.md Remove docs that have been moved to flake.parts and improved 2022-11-14 19:34:51 +01: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.

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 = { self, flake-parts, ... }:
    flake-parts.lib.mkFlake { inherit self; } {
      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.

Example

See the template.

Options Reference

See flake.parts options

Documentation

See flake.parts