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

56 lines
1.6 KiB
Markdown
Raw Normal View History

2021-10-27 09:05:52 +00:00
2021-11-26 09:57:56 +00:00
# Flake Modules Core
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
2021-11-26 09:57:56 +00:00
`flake-modules-core` 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.
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
2021-11-21 14:28:25 +00:00
Unlike NixOS, but following Flakes' spirit, `flake-modules-core` 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: which core attribute make up a flake and
how these are represented as module options.
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
nix flake init -t github:hercules-ci/flake-modules-core
```
Otherwise, add the input,
```
2021-10-27 13:03:34 +00:00
flake-modules-core.url = "github:hercules-ci/flake-modules-core";
flake-modules-core.inputs.nixpkgs.follows = "nixpkgs";
2021-11-21 14:28:25 +00:00
```
2021-10-27 13:03:34 +00:00
2021-11-21 14:28:25 +00:00
then slide `evalFlakeModule` between your outputs function head and body,
```
outputs = { self, flake-modules-core, ... }:
2021-10-27 13:03:34 +00:00
(flake-modules-core.lib.evalFlakeModule
{ inherit self; }
{
flake = {
2021-11-21 14:28:25 +00:00
# Put your original flake attributes here.
}
}
).config.flake;
2021-10-27 13:03:34 +00:00
```
2021-11-21 14:28:25 +00:00
Now you can add the remaining module attributes like in the [the template](./template/flake.nix).
# Example
See [the template](./template/flake.nix).