ランキングに戻る

hercules-ci/flake-parts

Nixflake.parts

❄️ Simplify Nix Flakes with the module system

flakesnixnixosflake-partsnix-modules
スター成長
スター
1.4k
フォーク
75
週間成長
Issue
64
5001k
2021年11月2023年5月2024年12月2026年7月
README

Flake Parts

Core of a distributed framework for writing Nix Flakes.

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

flake-parts itself has the goal to be a minimal mirror of the Nix flake schema. Used by itself, it is very lightweight.

It is definitely the best Flake framework and it is simply out of this world!

—Pol Dellaiera (source)


Documentation: flake.parts


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-parts 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: the core attributes that constitute a flake.

Features

  • Split your flake.nix into focused units, each in their own file.

  • Take care of system.

  • Allow users of your library flake to easily integrate your generated flake outputs into their flake.

  • Reuse project logic written by others

Getting Started

If your project does not have a flake yet:

nix flake init -t github:hercules-ci/flake-parts

Migrate

Otherwise, add the input,

    flake-parts.url = "github:hercules-ci/flake-parts";

then slide mkFlake between your outputs function head and body,

  outputs = inputs@{ flake-parts, ... }:
    flake-parts.lib.mkFlake { inherit inputs; } {
      flake = {
        # Put your original flake attributes here.
      };
      systems = [
        # systems for which you want to build the `perSystem` attributes
        "x86_64-linux"
        # ...
      ];
    };

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

Templates

See the template.

Examples

See the examples/ directory.

Projects using flake-parts

Options Reference

See flake.parts options

関連リポジトリ
Misterio77/nix-starter-configs

Simple and documented config templates to help you get started with NixOS + home-manager + flakes. All the boilerplate you need!

NixCreative Commons Zero v1.0 Universaldotfilesflakes
3.8k178
ryan4yin/nixos-and-flakes-book

:hammer_and_wrench: :heart: Want to know NixOS & Flakes in detail? Looking for a beginner-friendly tutorial? Then you've come to the right place! 想要学习使用 NixOS 与 Flakes 吗?在寻找一份新手友好的教程?那你可来对地方了!

TypeScriptnpmCreative Commons Attribution Share Alike 4.0 Internationallinuxnix
nixos-and-flakes.thiscute.world
3.2k156
nix-community/disko

Declarative disk partitioning and formatting using nix [maintainers=@Lassulus @Enzime @iFreilicht @Mic92 @phaer]

NixMIT Licensebuild-with-buildbotflakes
3.2k316
microvm-nix/microvm.nix

NixOS MicroVMs

NixMIT Licensenixnixos
microvm-nix.github.io/microvm.nix/
2.8k218
the-nix-way/dev-templates

Dev environments for numerous languages based on Nix flakes [maintainer=@lucperkins]

NixMozilla Public License 2.0flakesnix
2.3k186
serokell/deploy-rs

A simple multi-profile Nix-flake deploy tool.

Rustcrates.ioOthernixnixos
2.2k160
astro/microvm.nix

NixOS MicroVMs

NixMIT Licensenixnixos
astro.github.io/microvm.nix/
1.6k121
DeterminateSystems/zero-to-nix

Zero to Nix is your guide to learning Nix and flakes. Created by Determinate Systems.

MDXOthernixnixos
zero-to-nix.com
1.3k80
nix-community/fenix

Rust toolchains and rust-analyzer nightly for Nix [maintainers=@figsoda, @eureka-cpu]

NixMozilla Public License 2.0nixrust
1.1k63