refactor: move options into own module
This commit is contained in:
parent
e1ce751171
commit
f794ce0d9e
@ -1,34 +1,10 @@
|
|||||||
{ config, pkgs, lib, ... }: with lib; let
|
{ config, pkgs, lib, ... }: with lib; let
|
||||||
cfg = config.services.ssh-cert-dist;
|
cfg = config.services.ssh-cert-dist;
|
||||||
directoryModule = { name, ... }: {
|
|
||||||
options = {
|
|
||||||
name = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = last (splitString "/" name);
|
|
||||||
};
|
|
||||||
fetch = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = true;
|
|
||||||
};
|
|
||||||
upload = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.services.ssh-cert-dist = {
|
config.imports = [
|
||||||
enable = mkEnableOption "ssh-cert-dist";
|
./options.nix
|
||||||
endpoint = mkOption {
|
];
|
||||||
type = types.str;
|
|
||||||
description = "API endpoint url";
|
|
||||||
};
|
|
||||||
directories = mkOption {
|
|
||||||
type = with types; attrsOf (submodule directoryModule);
|
|
||||||
default = { };
|
|
||||||
};
|
|
||||||
};
|
|
||||||
config.systemd.user.services = mkIf cfg.enable (mapAttrs'
|
config.systemd.user.services = mkIf cfg.enable (mapAttrs'
|
||||||
(path: options: {
|
(path: options: {
|
||||||
inherit (options) name; value = {
|
inherit (options) name; value = {
|
||||||
|
42
modules/options.nix
Normal file
42
modules/options.nix
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
{ config, lib, pkgs, ... }: with lib; let
|
||||||
|
directoryModule = { name, ... }: {
|
||||||
|
options = {
|
||||||
|
name = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = last (splitString "/" name);
|
||||||
|
};
|
||||||
|
fetch = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
upload = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
endpointOption = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "API endpoint url";
|
||||||
|
default = "https://pki.shimun.net";
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
services.ssh-cert-dist = {
|
||||||
|
enable = mkEnableOption "ssh-cert-dist";
|
||||||
|
endpoint = endpointOption;
|
||||||
|
directories = mkOption {
|
||||||
|
type = with types; attrsOf (submodule directoryModule);
|
||||||
|
default = { };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
programs.ssh-cert-dist = {
|
||||||
|
enable = mkEnableOption "ssh-cert-dist client";
|
||||||
|
endpoint = endpointOption;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user