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
bors[bot] 0263a393a2
Merge #17
17: introduce lib.mkFlake r=roberth a=zimbatm

This makes the most common use-case a tiny bit less verbose.

I didn't name it mkFlakeModule because it would be redundant with the project name.

Co-authored-by: zimbatm <zimbatm@zimbatm.com>
Co-authored-by: Jonas Chevalier <zimbatm@zimbatm.com>
Co-authored-by: Robert Hensing <robert@roberthensing.nl>
2022-05-19 07:52:52 +00:00
dev Add pkgs parameter to perSystem 2022-05-18 11:06:17 +02:00
modules Add pkgs parameter to perSystem 2022-05-18 11:06:17 +02:00
template templates.multi-module: Use lib.mkFlake 2022-05-19 09:51:39 +02:00
all-modules.nix Add pkgs parameter to perSystem 2022-05-18 11:06:17 +02:00
bors.toml Add bors bot 2022-05-19 09:48:46 +02:00
ci.nix dev: Add nixpkgs-fmt to pre-commit 2022-05-17 10:37:27 +02:00
flake.nix Add multi-module template 2022-05-11 23:05:53 +02:00
lib.nix introduce lib.mkFlake 2022-05-18 14:11:08 +02:00
LICENSE Initial commit 2021-10-27 11:03:43 +02:00
README.md introduce lib.mkFlake 2022-05-18 14:11:08 +02:00
shell.nix Add local tooling and CI wiring without bloating flake.nix 2022-05-17 10:12:40 +02:00

Flake Modules Core

Core of a distributed framework for writing Nix Flakes.

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.

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 mkFlake between your outputs function head and body,

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

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

Example

See the template.