reduce boilerplate with mkOizysModule

This commit is contained in:
Daylin Morgan 2024-03-21 10:53:27 -05:00
parent ff7f8495f6
commit 55f2e625ec
Signed by: daylin
GPG key ID: 950D13E9719334AD
10 changed files with 41 additions and 55 deletions

View file

@ -1,5 +1,5 @@
final: prev: let
inherit (final) hasSuffix;
inherit (final) hasSuffix mkEnableOption mkIf;
runes = import ../modules/runes;
in rec {
enabled = {enable = true;};
@ -28,4 +28,9 @@ in rec {
runeKind ? "braille",
}:
"[1;3${number}m\n" + runes.${rune}.${runeKind} + "\n";
mkOizysModule = config: attr: content: {
options.oizys.${attr}.enable = mkEnableOption "enable ${attr} support";
config = mkIf config.oizys.${attr}.enable content;
};
}

View file

@ -5,9 +5,8 @@
...
}: let
inherit (lib) mkIf;
cfg = config.oizys.desktop;
in {
config = mkIf cfg.enable {
config = mkIf config.oizys.desktop.enable {
fonts.fontconfig.enable = true;
fonts.packages = with pkgs; [
(nerdfonts.override {fonts = ["FiraCode"];})

View file

@ -5,9 +5,8 @@
...
}: let
inherit (lib) mkIf;
cfg = config.oizys.desktop;
in {
config = mkIf cfg.enable {
config = mkIf config.oizys.desktop.enable {
environment.systemPackages = with pkgs; [
wezterm
alacritty

View file

@ -5,9 +5,7 @@
lib,
...
}: let
inherit (lib) mkIf;
cfg = config.programs.hyprland;
inherit (lib) mkOizysModule;
lock = pkgs.writeShellApplication {
name = "lock";
runtimeInputs = with pkgs; [swaylock];
@ -15,10 +13,8 @@
swaylock -c 1e1e2e
'';
};
in {
config = mkIf cfg.enable {
in mkOizysModule config "hyprland" {
security.pam.services.swaylock = {};
# programs.hyprland.package = inputs.hyprland.packages.${pkgs.system}.default;
# Optional, hint electron apps to use wayland:
environment.sessionVariables.NIXOS_OZONE_WL = "1";
@ -52,5 +48,4 @@ in {
inputs.nixpkgs-wayland.overlay
inputs.hyprland.overlays.default
];
};
}
}

View file

@ -5,9 +5,8 @@
...
}: let
inherit (lib) mkIf;
cfg = config.oizys.desktop;
in {
config = mkIf cfg.enable {
config = mkIf config.oizys.desktop.enable {
environment.systemPackages = with pkgs; [
# vscode
vscode-fhs

View file

@ -4,14 +4,7 @@
pkgs,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.oizys.vpn;
in {
options.oizys.vpn.enable = mkEnableOption ''
Whether to enable openconnect for vpn connection.
'';
config = mkIf cfg.enable {
inherit (lib) mkOizysModule;
in mkOizysModule config "vpn" {
environment.systemPackages = [pkgs.openconnect];
};
}
}

View file

@ -4,11 +4,8 @@
lib,
...
}: let
inherit (lib) mkIf mkEnableOption;
cfg = config.oizys.chrome;
in {
options.oizys.chrome.enable = mkEnableOption "enable chrome + extensions";
config = mkIf cfg.enable {
inherit (lib) mkOizysModule;
in mkOizysModule config "chrome" {
programs.chromium = {
enable = true;
@ -29,5 +26,4 @@ in {
];
})
];
};
}
}

View file

@ -4,11 +4,9 @@
lib,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.oizys.backups;
in {
options.oizys.backups.enable = mkEnableOption "enable restic/rclone backups";
config = mkIf cfg.enable {
inherit (lib) mkOizysModule;
in
mkOizysModule config "backups" {
environment.systemPackages = with pkgs; [rclone];
services.restic.backups.gdrive = {
@ -36,5 +34,4 @@ in {
RandomizedDelaySec = "5h";
};
};
};
}
}

View file

@ -4,15 +4,22 @@
lib,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.oizys.docker;
in {
options.oizys.docker.enable = mkEnableOption "enable docker support";
config = mkIf cfg.enable {
inherit (lib) mkOizysModule;
in
mkOizysModule config "docker" {
virtualisation.docker.enable = true;
environment.systemPackages = with pkgs; [
lazydocker
];
};
}
}
# in {
# options.oizys.docker.enable = mkEnableOption "enable docker support";
#
# config = mkIf cfg.enable {
# virtualisation.docker.enable = true;
# environment.systemPackages = with pkgs; [
# lazydocker
# ];
# };
# }

View file

@ -3,15 +3,11 @@
lib,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.oizys.vbox;
in {
options.oizys.vbox.enable = mkEnableOption "enable virtualbox host";
config = mkIf cfg.enable {
inherit (lib) mkOizysModule;
in
mkOizysModule config "vbox" {
virtualisation.virtualbox = {
host.enable = true;
};
users.extraGroups.vboxusers.members = ["daylin"];
};
}
}