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, home.packages = with pkgs; [
lib, go
pkgs, gopls
... ];
}:
{
options.go = {
enable = lib.mkEnableOption "go language";
};
config = lib.mkIf config.go.enable {
home.packages = with pkgs; [
go
gopls
];
};
} }

View File

@@ -1,21 +1,6 @@
{ pkgs, ... }:
{ {
config, home.packages = [
lib, (pkgs.proxmark3.override { withGeneric = true; })
pkgs, ];
...
}:
let
cfg = config.nfc.proxmark3;
in
{
options.nfc.proxmark3 = {
enable = lib.mkEnableOption "proxmark3 (iceman fork)";
};
config = lib.mkIf cfg.enable {
home.packages = [
(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)"; type = lib.types.package;
package = lib.mkOption { default = pkgs.nodejs_24;
type = lib.types.package;
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, home.packages = with pkgs; [
lib, haskellPackages.pandoc-crossref
pkgs, pandoc
... texliveSmall
}: ];
{
options.pandoc = {
enable = lib.mkEnableOption "pandoc";
};
config = lib.mkIf config.pandoc.enable {
home.packages = with pkgs; [
haskellPackages.pandoc-crossref
pandoc
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,26 +1,19 @@
{ {
config,
lib, lib,
pkgs, pkgs,
... ...
}: }:
{ {
options.shell-utils = { programs.fzf = {
enable = lib.mkEnableOption "shell utilities"; enable = true;
enableBashIntegration = lib.mkDefault true;
}; };
config = lib.mkIf config.shell-utils.enable { home.packages = with pkgs; [
programs.fzf = { ripgrep
enable = true; bat
enableBashIntegration = lib.mkDefault true; jq
}; entr
parallel
home.packages = with pkgs; [ ];
ripgrep
bat
jq
entr
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"; type = types.str;
username = mkOption { default = "h";
type = types.str;
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,39 +1,30 @@
{ {
config,
lib,
pkgs, pkgs,
... ...
}: }:
let
cfg = config.my.uptime-kuma;
in
{ {
options.my.uptime-kuma.enable = lib.mkEnableOption "Uptime Kuma monitoring service (Docker container)"; virtualisation.oci-containers = {
backend = "docker";
config = lib.mkIf cfg.enable { containers.uptime-kuma = {
virtualisation.oci-containers = { image = "louislam/uptime-kuma:latest";
backend = "docker"; ports = [ "127.0.0.1:3001:3001" ];
containers.uptime-kuma = { volumes = [ "/var/lib/uptime-kuma:/app/data" ];
image = "louislam/uptime-kuma:latest"; environment = {
ports = [ "127.0.0.1:3001:3001" ]; TZ = "UTC";
volumes = [ "/var/lib/uptime-kuma:/app/data" ]; UMASK = "0022";
environment = {
TZ = "UTC";
UMASK = "0022";
};
extraOptions = [
"--network=proxiable"
];
}; };
extraOptions = [
"--network=proxiable"
];
}; };
systemd.tmpfiles.settings."uptime-kuma" = {
"/var/lib/uptime-kuma".d = {
mode = "0755";
};
};
environment.systemPackages = with pkgs; [ docker-compose ];
}; };
systemd.tmpfiles.settings."uptime-kuma" = {
"/var/lib/uptime-kuma".d = {
mode = "0755";
};
};
environment.systemPackages = with pkgs; [ docker-compose ];
} }