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-21 16:33:33 +01:00
modules Add more descriptions 2021-11-21 16:33:33 +01:00
all-modules.nix Small beginnings 2021-10-27 11:05:52 +02:00
flake.nix Remove unnecessary flakeModules from flake 2021-11-21 16:33:33 +01:00
lib.nix Small beginnings 2021-10-27 11:05:52 +02:00
LICENSE Initial commit 2021-10-27 11:03:43 +02:00
README.md Update README.md 2021-10-27 15:03:34 +02: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.

This allows anyone to bundle up tooling into reusable modules.

For users, this makes Flakes easier to wire up.

Non-goals:

  • Replace general Nix expressions, which are needed for advanced and/or ad-hoc use cases.
  • Accumulate everything into a single repository. As the name might suggest, it focuses only on options that have to do with well-known Nix Flakes attributes.

Example Flake

{
  description = "A very basic flake";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    flake-modules-core.url = "github:hercules-ci/flake-modules-core";
    flake-modules-core.inputs.nixpkgs.follows = "nixpkgs";
    devshell.url = "github:hercules-ci/devshell/flake-modules"; # credit to numtide
  };

  outputs = { self, nixpkgs, flake-modules-core, devshell, ... }:
    (flake-modules-core.lib.evalFlakeModule
      { inherit self; }
      {
        systems = [ "x86_64-linux" ];
        imports = [
          devshell.flakeModule
        ];
        flake = {
          nixosConfigurations.foo = lib.nixosSystem { /* ... */ };
        };
        perSystem = system: { config, pkgs, self', inputs', ... }: {
          _module.args.pkgs = inputs'.nixpkgs.legacyPackages;
          devshell.settings.commands = [
            {
              help = "format nix code";
              package = pkgs.nixpkgs-fmt;
            }
          ];
          packages.hello = pkgs.hello;
          packages.hello2 = self'.packages.hello;
          checks.hello = self'.packages.hello;
        };
      }).config.flake;

}