Skip to content

Commit

Permalink
feat: add support for flake-parts
Browse files Browse the repository at this point in the history
  • Loading branch information
oddlama committed Jul 12, 2024
1 parent a676a5c commit 8a69249
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
70 changes: 70 additions & 0 deletions flake-module.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
A module to import into flakes based on flake-parts.
Makes integration into a flake easy and tidy.
See https://flake.parts, https://flake.parts/options/agenix-rekey
*/
{
lib,
self,
config,
flake-parts-lib,
...
}: let
inherit
(lib)
mkOption
types
;
in {
options = {
flake = flake-parts-lib.mkSubmoduleOptions {
topology = mkOption {
type = types.lazyAttrsOf types.unspecified;
default =
lib.mapAttrs
(_system: config':
import ./. {
inherit (config'.topology) pkgs;
modules =
config'.topology.modules
++ [
{inherit (config'.topology) nixosConfigurations;}
];
})
config.allSystems;
defaultText = "Automatically filled by nix-topology";
readOnly = true;
description = ''
The evaluated topology configuration, for each of the specified systems.
Build the output by running `nix build .#topology.$system.config.output`.
'';
};
};

perSystem = flake-parts-lib.mkPerSystemOption ({
lib,
pkgs,
...
}: {
options.topology = {
nixosConfigurations = mkOption {
type = types.lazyAttrsOf types.unspecified;
description = "All nixosSystems that should be evaluated for topology definitions.";
default = self.nixosConfigurations;
defaultText = lib.literalExpression "self.nixosConfigurations";
};
pkgs = mkOption {
type = types.unspecified;
description = "The package set to use for the topology evaluation on this system.";
default = pkgs;
defaultText = lib.literalExpression "pkgs # (module argument)";
};
modules = mkOption {
type = types.listOf types.unspecified;
description = "A list of additional topology modules to evaluate in your global topology.";
default = [];
};
};
});
};
}
2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
...
} @ inputs:
{
flakeModule = ./flake-module.nix;

# Expose NixOS module
nixosModules.topology = ./nixos/module.nix;
nixosModules.default = self.nixosModules.topology;
Expand Down

0 comments on commit 8a69249

Please sign in to comment.