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
2021-11-22 16:36:16 +01:00
modules Set the default devShell to null 2021-11-22 16:36:16 +01:00
template Add template rewrite README sections 2021-11-22 16:27:49 +01:00
all-modules.nix Add freeformType to flake option 2021-11-21 16:58:54 +01:00
flake.nix Add template rewrite README sections 2021-11-22 16:27:49 +01:00
lib.nix Add freeformType to flake option 2021-11-21 16:58:54 +01:00
LICENSE Initial commit 2021-10-27 11:03:43 +02:00
README.md Add template rewrite README sections 2021-11-22 16:27:49 +01:00

Flake Module Core

Foundational flake attributes represented using the module system.

flake-modules-core provides common options for an ecosystem of modules to extend.

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-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.

Getting Started

If your project does not have a flake yet:

nix flake init -t github:hercules-ci/flake-modules-core

Otherwise, add the input,

    flake-modules-core.url = "github:hercules-ci/flake-modules-core";
    flake-modules-core.inputs.nixpkgs.follows = "nixpkgs";

then slide evalFlakeModule between your outputs function head and body,

  outputs = { self, flake-modules-core, ... }:
    (flake-modules-core.lib.evalFlakeModule
      { inherit self; }
      {
        flake = {
          # Put your original flake attributes here.
        }
      }
    ).config.flake;

Now you can add the remaining module attributes like in the the template.

Example

See the template.