mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-02-07 06:19:00 +00:00
flake-parts/setups: refactor Disko integration
This commit is contained in:
parent
27153a368e
commit
a56e3ed759
@ -4,7 +4,7 @@
|
||||
# that. Take note we don't consider integrating this with declarative NixOS
|
||||
# setups since their Disko scripts are already gettable in
|
||||
# `config.system.build.diskoScript` along with its variants (e.g., `noDeps`).
|
||||
{ config, lib, ... }:
|
||||
{ config, lib, inputs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.setups.disko;
|
||||
@ -39,6 +39,40 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
options.setups.nixos.configs =
|
||||
let
|
||||
diskoIntegrationModule = { config, lib, name, ... }: {
|
||||
options = {
|
||||
diskoConfigs = lib.mkOption {
|
||||
type = with lib.types; listOf str;
|
||||
default = [ ];
|
||||
example = [ "external-hdd" ];
|
||||
description = ''
|
||||
A list of declarative Disko configurations to be included alongside
|
||||
the NixOS configuration.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf (config.diskoConfigs != [ ]) (
|
||||
let
|
||||
diskoConfigs =
|
||||
builtins.map (name: import ../../../configs/disko/${name}) config.diskoConfigs;
|
||||
in
|
||||
{
|
||||
modules = lib.singleton {
|
||||
imports =
|
||||
[ inputs.disko.nixosModules.disko ]
|
||||
++ (lib.lists.flatten diskoConfigs);
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
in
|
||||
lib.mkOption {
|
||||
type = with lib.types; attrsOf (submodule diskoIntegrationModule);
|
||||
};
|
||||
|
||||
config = {
|
||||
flake.diskoConfigurations =
|
||||
lib.mapAttrs (name: _: import ../../../configs/disko/${name}) cfg.configs;
|
||||
|
@ -157,16 +157,6 @@ let
|
||||
};
|
||||
};
|
||||
|
||||
diskoConfigs = lib.mkOption {
|
||||
type = with lib.types; listOf str;
|
||||
default = [ ];
|
||||
example = [ "external-hdd" ];
|
||||
description = ''
|
||||
A list of declarative Disko configurations to be included alongside
|
||||
the NixOS configuration.
|
||||
'';
|
||||
};
|
||||
|
||||
shouldBePartOfNixOSConfigurations = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = lib.isAttrs config.deploy || config.formats == null;
|
||||
@ -184,19 +174,6 @@ let
|
||||
# Bring in the required modules.
|
||||
../../../configs/nixos/${config.configName}
|
||||
|
||||
# Then we include the Disko configuration (if there's any).
|
||||
(lib.mkIf (config.diskoConfigs != [ ]) (
|
||||
let
|
||||
diskoConfigs =
|
||||
builtins.map (name: import ../../../configs/disko/${name}) config.diskoConfigs;
|
||||
in
|
||||
{
|
||||
imports =
|
||||
[ inputs.disko.nixosModules.disko ]
|
||||
++ (lib.lists.flatten diskoConfigs);
|
||||
})
|
||||
)
|
||||
|
||||
# Setting up the typical configuration.
|
||||
(
|
||||
{ config, lib, ... }: {
|
||||
|
Loading…
Reference in New Issue
Block a user