From 3ac1cded693906eed87481835847fa73f0a67733 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Fri, 5 Apr 2024 09:19:48 +0100 Subject: [PATCH] docs: document flake-parts module --- docs/manual/nix-flakes.md | 1 + docs/manual/nix-flakes/flake-parts.md | 40 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 docs/manual/nix-flakes/flake-parts.md diff --git a/docs/manual/nix-flakes.md b/docs/manual/nix-flakes.md index 9ac5c0cf1..940f480c6 100644 --- a/docs/manual/nix-flakes.md +++ b/docs/manual/nix-flakes.md @@ -30,6 +30,7 @@ nix-flakes/prerequisites.md nix-flakes/standalone.md nix-flakes/nixos.md nix-flakes/nix-darwin.md +nix-flakes/flake-parts.md ``` diff --git a/docs/manual/nix-flakes/flake-parts.md b/docs/manual/nix-flakes/flake-parts.md new file mode 100644 index 000000000..1c6d60d33 --- /dev/null +++ b/docs/manual/nix-flakes/flake-parts.md @@ -0,0 +1,40 @@ +# flake-parts module {#sec-flakes-flake-parts-module} + +When using [flake-parts](https://flake.parts) +you may wish to import home-manager's flake module, +`flakeModules.home-manager`. + +``` nix +{ + description = "flake-parts configuration"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager.url = "github:nix-community/home-manager"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + flake-parts.url = "github:hercules-ci/flake-parts"; + }; + + outputs = inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ + # Import home-manager's flake module + inputs.home-manager.flakeModules.home-manager + ]; + flake = { + # Define `homeModules`, `homeConfigurations`, + # `nixosConfigurations`, etc here + }; + # See flake.parts for more features, such as `perSystem` + }; +} +``` + +The flake module defines the `flake.homeModules` and `flake.homeConfigurations` +options, allowing them to be properly merged if they are defined in multiple +modules. + +If you are only defining `homeModules` and/or `homeConfigurations` once in a +single module, flake-parts should work fine without importing +`flakeModules.home-manager`. +