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

introduce lib.mkFlake

This makes the most common use-case a tiny bit less verbose.
This commit is contained in:
zimbatm 2022-05-18 13:59:21 +02:00
parent 0f0b1633a6
commit ad19f920cf
No known key found for this signature in database
GPG key ID: 71BAF6D40C1D63D7
3 changed files with 29 additions and 32 deletions

View file

@ -34,18 +34,15 @@ Otherwise, add the input,
flake-modules-core.inputs.nixpkgs.follows = "nixpkgs"; flake-modules-core.inputs.nixpkgs.follows = "nixpkgs";
``` ```
then slide `evalFlakeModule` between your outputs function head and body, then slide `mkFlake` between your outputs function head and body,
``` ```
outputs = { self, flake-modules-core, ... }: outputs = { self, flake-modules-core, ... }:
(flake-modules-core.lib.evalFlakeModule flake-modules-core.lib.mkFlake { inherit self; } {
{ inherit self; }
{
flake = { flake = {
# Put your original flake attributes here. # Put your original flake attributes here.
} }
} };
).config.flake;
``` ```
Now you can add the remaining module attributes like in the [the template](./template/default/flake.nix). Now you can add the remaining module attributes like in the [the template](./template/default/flake.nix).

View file

@ -38,6 +38,9 @@ let
modules = [ ./all-modules.nix module ]; modules = [ ./all-modules.nix module ];
}; };
mkFlake = args: module:
(flake-modules-core-lib.evalFlakeModule args module).config.flake;
# For extending options in an already declared submodule. # For extending options in an already declared submodule.
# Workaround for https://github.com/NixOS/nixpkgs/issues/146882 # Workaround for https://github.com/NixOS/nixpkgs/issues/146882
mkSubmoduleOptions = mkSubmoduleOptions =

View file

@ -8,9 +8,7 @@
}; };
outputs = { self, flake-modules-core, ... }: outputs = { self, flake-modules-core, ... }:
(flake-modules-core.lib.evalFlakeModule flake-modules-core.mkFlake { inherit self; } {
{ inherit self; }
{
imports = [ imports = [
# To import a flake module # To import a flake module
# 1. Add foo to inputs # 1. Add foo to inputs
@ -33,6 +31,5 @@
# those are more easily expressed in perSystem. # those are more easily expressed in perSystem.
}; };
} };
).config.flake;
} }