refactor: use 'import-as-enable' pattern

This commit is contained in:
2026-03-11 16:40:11 +01:00
parent ed39959b61
commit 890146bc9d
15 changed files with 65 additions and 170 deletions

View File

@@ -47,12 +47,7 @@ in
cloud.hetzner.enable = true; cloud.hetzner.enable = true;
comms.signal.enable = true; comms.signal.enable = true;
github.enable = true; github.enable = true;
pandoc.enable = true; shell.bash.aliases.lang-js = true;
shell.bash = {
enable = true;
aliases.lang-js = true;
};
programs = { programs = {
home-manager.enable = true; home-manager.enable = true;

View File

@@ -45,13 +45,7 @@ in
cloud.hetzner.enable = true; cloud.hetzner.enable = true;
comms.signal.enable = true; comms.signal.enable = true;
github.enable = true; github.enable = true;
nfc.proxmark3.enable = true; shell.bash.aliases.lang-js = true;
pandoc.enable = true;
shell.bash = {
enable = true;
aliases.lang-js = true;
};
programs = { programs = {
home-manager.enable = true; home-manager.enable = true;

View File

@@ -106,14 +106,7 @@ in
database.postgresql.enable = true; database.postgresql.enable = true;
github.enable = true; github.enable = true;
gitlab.enable = true; gitlab.enable = true;
pandoc.enable = true; secrets.vault.enable = true;
secrets = {
enable = true;
vault.enable = true;
};
shell.bash.enable = true;
starship.enable = true;
programs = { programs = {
gh.enable = true; gh.enable = true;

View File

@@ -1,18 +1,7 @@
{ pkgs, ... }:
{ {
config,
lib,
pkgs,
...
}:
{
options.go = {
enable = lib.mkEnableOption "go language";
};
config = lib.mkIf config.go.enable {
home.packages = with pkgs; [ home.packages = with pkgs; [
go go
gopls gopls
]; ];
};
} }

View File

@@ -1,21 +1,6 @@
{ pkgs, ... }:
{ {
config,
lib,
pkgs,
...
}:
let
cfg = config.nfc.proxmark3;
in
{
options.nfc.proxmark3 = {
enable = lib.mkEnableOption "proxmark3 (iceman fork)";
};
config = lib.mkIf cfg.enable {
home.packages = [ home.packages = [
(pkgs.proxmark3.override { withGeneric = true; }) (pkgs.proxmark3.override { withGeneric = true; })
]; ];
};
} }

View File

@@ -6,15 +6,12 @@
}: }:
{ {
options.nodejs = { options.nodejs.package = lib.mkOption {
enable = lib.mkEnableOption "nodejs (and related packages)";
package = lib.mkOption {
type = lib.types.package; type = lib.types.package;
default = pkgs.nodejs_24; default = pkgs.nodejs_24;
}; };
};
config = lib.mkIf config.nodejs.enable { config = {
home.packages = with pkgs; [ home.packages = with pkgs; [
config.nodejs.package config.nodejs.package
pnpm pnpm

View File

@@ -1,19 +1,8 @@
{ pkgs, ... }:
{ {
config,
lib,
pkgs,
...
}:
{
options.pandoc = {
enable = lib.mkEnableOption "pandoc";
};
config = lib.mkIf config.pandoc.enable {
home.packages = with pkgs; [ home.packages = with pkgs; [
haskellPackages.pandoc-crossref haskellPackages.pandoc-crossref
pandoc pandoc
texliveSmall texliveSmall
]; ];
};
} }

View File

@@ -1,20 +1,13 @@
{ {
config,
lib, lib,
pkgs, pkgs,
... ...
}: }:
{ {
options.secrets = {
enable = lib.mkEnableOption "secrets";
};
imports = [ ./vault.nix ]; imports = [ ./vault.nix ];
config = lib.mkIf config.secrets.enable {
home.packages = with pkgs; [ home.packages = with pkgs; [
sops sops
age age
]; ];
};
} }

View File

@@ -9,38 +9,32 @@ let
inherit (config.home) username; inherit (config.home) username;
in in
{ {
options.shell.bash = { imports = [ ./utils.nix ];
enable = lib.mkEnableOption "bash configuration";
options.shell.bash = {
aliases = { aliases = {
all = lib.mkOption { all = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
default = true; default = true;
description = "Enable common aliases";
}; };
lang-js = lib.mkOption { lang-js = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
default = false; default = false;
description = "Enable JavaScript/Node.js aliases";
}; };
}; };
addBinToPath = lib.mkOption { addBinToPath = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
default = true; default = true;
description = "Add dots .bin directory to PATH";
}; };
extraInit = lib.mkOption { extraInit = lib.mkOption {
type = lib.types.lines; type = lib.types.lines;
default = ""; default = "";
description = "Additional bash initialization";
}; };
}; };
config = lib.mkIf cfg.enable { config = {
shell-utils.enable = lib.mkDefault true;
programs.bash = { programs.bash = {
enable = true; enable = true;
enableCompletion = true; enableCompletion = true;

View File

@@ -1,16 +1,3 @@
{ {
config, programs.starship.enable = true;
lib,
...
}:
{
options.starship = {
enable = lib.mkEnableOption "starship prompt";
};
config = lib.mkIf config.starship.enable {
programs.starship = {
enable = true;
};
};
} }

View File

@@ -1,15 +1,9 @@
{ {
config,
lib, lib,
pkgs, pkgs,
... ...
}: }:
{ {
options.shell-utils = {
enable = lib.mkEnableOption "shell utilities";
};
config = lib.mkIf config.shell-utils.enable {
programs.fzf = { programs.fzf = {
enable = true; enable = true;
enableBashIntegration = lib.mkDefault true; enableBashIntegration = lib.mkDefault true;
@@ -22,5 +16,4 @@
entr entr
parallel parallel
]; ];
};
} }

View File

@@ -11,6 +11,7 @@ in
imports = [ imports = [
./hard.nix ./hard.nix
../../modules/ssh ../../modules/ssh
# ../../modules/uptime-kuma
]; ];
ssh = { ssh = {

View File

@@ -17,7 +17,6 @@ in
./hard.nix ./hard.nix
../../modules/ssh ../../modules/ssh
../../modules/docker ../../modules/docker
../../modules/uptime-kuma
]; ];
networking.hostName = hostName; networking.hostName = hostName;
@@ -32,8 +31,6 @@ in
docker.user = username; docker.user = username;
my.uptime-kuma.enable = false;
fileSystems."/" = { fileSystems."/" = {
device = "/dev/disk/by-label/nixos"; device = "/dev/disk/by-label/nixos";
fsType = "ext4"; fsType = "ext4";

View File

@@ -10,15 +10,12 @@ let
cfg = config.my.syncthing; cfg = config.my.syncthing;
in in
{ {
options.my.syncthing = { options.my.syncthing.username = mkOption {
enable = mkEnableOption "Syncthing file synchronization";
username = mkOption {
type = types.str; type = types.str;
default = "h"; default = "h";
}; };
};
config = mkIf cfg.enable { config = {
users.groups.${cfg.username} = { }; users.groups.${cfg.username} = { };
users.users.${cfg.username}.extraGroups = [ cfg.username ]; users.users.${cfg.username}.extraGroups = [ cfg.username ];

View File

@@ -1,17 +1,9 @@
{ {
config,
lib,
pkgs, pkgs,
... ...
}: }:
let
cfg = config.my.uptime-kuma;
in
{ {
options.my.uptime-kuma.enable = lib.mkEnableOption "Uptime Kuma monitoring service (Docker container)";
config = lib.mkIf cfg.enable {
virtualisation.oci-containers = { virtualisation.oci-containers = {
backend = "docker"; backend = "docker";
containers.uptime-kuma = { containers.uptime-kuma = {
@@ -35,5 +27,4 @@ in
}; };
environment.systemPackages = with pkgs; [ docker-compose ]; environment.systemPackages = with pkgs; [ docker-compose ];
};
} }