1
0
Fork 0
mirror of https://github.com/hercules-ci/flake-parts.git synced 2024-12-14 11:47:31 +00:00
flake-parts/README.md

85 lines
2.2 KiB
Markdown
Raw Normal View History

2021-10-27 09:05:52 +00:00
2022-05-25 14:36:33 +00:00
# Flake Parts
2021-10-27 09:05:52 +00:00
2021-11-26 09:57:56 +00:00
_Core of a distributed framework for writing Nix Flakes._
2021-10-27 09:05:52 +00:00
`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.
2021-10-27 13:03:34 +00:00
2021-11-21 14:28:25 +00:00
# Why Modules?
2021-10-27 13:03:34 +00:00
2021-11-21 14:28:25 +00:00
Flakes are configuration. The module system lets you refactor configuration
into modules that can be shared.
2021-10-27 13:03:34 +00:00
2021-11-21 14:28:25 +00:00
It reduces the proliferation of custom Nix glue code, similar to what the
module system has done for NixOS configurations.
2021-10-27 13:03:34 +00:00
2022-05-25 14:36:33 +00:00
Unlike NixOS, but following Flakes' spirit, `flake-parts` is not a
2021-11-21 14:28:25 +00:00
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](./system.md).
- Allow users of your library flake to easily integrate your generated flake outputs
into their flake.
- Reuse project logic written by others
<!-- end_of_intro -->
<!-- ^^^^^^^^^^^^ used by https://github.com/hercules-ci/flake.parts-website -->
2021-10-27 13:03:34 +00:00
2021-11-21 14:28:25 +00:00
# Getting Started
2021-10-27 13:03:34 +00:00
2021-11-21 14:28:25 +00:00
If your project does not have a flake yet:
2021-10-27 13:03:34 +00:00
2021-11-21 14:28:25 +00:00
```console
2022-05-25 14:36:33 +00:00
nix flake init -t github:hercules-ci/flake-parts
2021-11-21 14:28:25 +00:00
```
# Migrate
2021-11-21 14:28:25 +00:00
Otherwise, add the input,
```
2022-05-25 14:36:33 +00:00
flake-parts.url = "github:hercules-ci/flake-parts";
2021-11-21 14:28:25 +00:00
```
2021-10-27 13:03:34 +00:00
then slide `mkFlake` between your outputs function head and body,
2021-11-21 14:28:25 +00:00
```
2022-05-25 14:36:33 +00:00
outputs = { self, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit self; } {
flake = {
# Put your original flake attributes here.
2022-06-18 13:59:50 +00:00
};
systems = [
# systems for which you want to build the `perSystem` attributes
"x86_64-linux"
# ...
];
};
2021-10-27 13:03:34 +00:00
```
2021-11-21 14:28:25 +00:00
2022-05-14 23:14:11 +00:00
Now you can add the remaining module attributes like in the [the template](./template/default/flake.nix).
2021-11-21 14:28:25 +00:00
# Example
2022-05-14 22:35:08 +00:00
See [the template](./template/default/flake.nix).
2022-05-25 14:37:40 +00:00
# Options Reference
See [flake.parts options](https://flake.parts/options/flake-parts.html)
2022-05-27 15:41:52 +00:00
2022-11-12 15:33:56 +00:00
# Documentation
See [flake.parts](https://flake.parts)