rework cfg options for programs

This commit is contained in:
Tyler Starr 2025-05-29 22:19:15 -07:00
parent 24557adfe5
commit 244b244c10
13 changed files with 65 additions and 62 deletions

View File

@ -7,5 +7,16 @@ in {
../programs/borg.nix ../programs/borg.nix
../programs/yt-dlp.nix ../programs/yt-dlp.nix
]; ];
options.modules.base-plus.enable = lib.mkEnableOption "base-plus"; options.modules.base-plus.enable = lib.mkEnableOption "base-plus";
config = {
modules = {
programs = {
borg.enable = true;
beancount.enable = true;
yt-dlp.enable = true;
};
};
};
} }

View File

@ -7,9 +7,6 @@ in {
./keyd.nix ./keyd.nix
./gnome.nix ./gnome.nix
./peripherals.nix ./peripherals.nix
../programs/chrome.nix
../programs/firefox.nix
../programs/kitty.nix
]; ];
options.modules.desktop.enable = lib.mkEnableOption "desktop"; options.modules.desktop.enable = lib.mkEnableOption "desktop";
@ -46,5 +43,13 @@ in {
"application/x-extension-xht" = [ "google-chrome.desktop" ]; "application/x-extension-xht" = [ "google-chrome.desktop" ];
"application/pdf" = [ "google-chrome.desktop" ]; }; "application/pdf" = [ "google-chrome.desktop" ]; };
}; };
modules = {
programs = {
chrome.enable = true;
firefox.enable = true;
kitty.enable = true;
};
};
}; };
} }

View File

@ -3,6 +3,7 @@
let cfg = config.modules.programs.appgate-sdp; let cfg = config.modules.programs.appgate-sdp;
in { in {
options.modules.programs.appgate-sdp.enable = lib.mkEnableOption "appgate-sdp"; options.modules.programs.appgate-sdp.enable = lib.mkEnableOption "appgate-sdp";
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
appgate-sdp appgate-sdp

View File

@ -1,7 +1,9 @@
{ config, lib, pkgs, user, ... }: { config, lib, pkgs, user, ... }:
let cfg = config.modules.base-plus; let cfg = config.modules.programs.beancount;
in { in {
options.modules.programs.beancount.enable = lib.mkEnableOption "beancount";
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
fava # Web interface for the double-entry bookkeeping software Beancount fava # Web interface for the double-entry bookkeeping software Beancount

View File

@ -1,7 +1,9 @@
{ config, pkgs, user, lib, ... }: { config, pkgs, user, lib, ... }:
let cfg = config.modules.base-plus; let cfg = config.modules.programs.borg;
in { in {
options.modules.programs.borg.enable = lib.mkEnableOption "borg";
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
borgbackup # Deduplicating backup program borgbackup # Deduplicating backup program

View File

@ -1,20 +1,10 @@
{ config, lib, pkgs, user, home-manager, ... }: { config, lib, pkgs, user, home-manager, ... }:
{
let cfg = config.modules.programs.chezmoi;
in {
options.modules.programs.chezmoi = with lib; {
apply = lib.mkOption {
type = with types; bool;
default = true;
};
};
config = {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
chezmoi # Manage your dotfiles across multiple machines, securely chezmoi # Manage your dotfiles across multiple machines, securely
]; ];
home-manager.users.${user} = lib.mkIf cfg.apply { home-manager.users.${user} = {
home.activation.chezmoi = home-manager.lib.hm.dag.entryAfter [ "installPackages" ] '' home.activation.chezmoi = home-manager.lib.hm.dag.entryAfter [ "installPackages" ] ''
_saved_path=$PATH _saved_path=$PATH
PATH="${pkgs.git}/bin:$PATH" PATH="${pkgs.git}/bin:$PATH"
@ -22,5 +12,4 @@ in {
PATH=$_saved_path PATH=$_saved_path
''; '';
}; };
};
} }

View File

@ -2,12 +2,7 @@
let cfg = config.modules.programs.chrome; let cfg = config.modules.programs.chrome;
in { in {
options.modules.programs.chrome = with lib; { options.modules.programs.chrome.enable = lib.mkEnableOption "chrome";
enable = lib.mkOption {
type = types.bool;
default = true;
};
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [

View File

@ -2,6 +2,15 @@
{ {
imports = [ imports = [
./appgate-sdp.nix ./appgate-sdp.nix
./beancount.nix
./borg.nix
./chezmoi.nix
./chrome.nix
./firefox.nix
./git.nix
./kitty.nix
./nvim.nix
./virt-manager.nix ./virt-manager.nix
./yt-dlp.nix
]; ];
} }

View File

@ -2,12 +2,7 @@
let cfg = config.modules.programs.firefox; let cfg = config.modules.programs.firefox;
in { in {
options.modules.programs.firefox = with lib; { options.modules.programs.firefox.enable = lib.mkEnableOption "firefox";
enable = lib.mkOption {
type = types.bool;
default = true;
};
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [

View File

@ -1,25 +1,14 @@
{ config, lib, pkgs, user, ... }: { config, lib, pkgs, user, ... }:
{
let cfg = config.modules.programs.git;
in {
options.modules.programs.git = with lib; {
keys = lib.mkOption {
type = with types; bool;
default = true;
};
};
config = {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
git # Version control system for tracking changes in source code during software development git # Version control system for tracking changes in source code during software development
git-annex # Manages files with git, without checking the file contents into git git-annex # Manages files with git, without checking the file contents into git
lazygit # Terminal-based GUI for git, making it easier to use and visualize git repositories lazygit # Terminal-based GUI for git, making it easier to use and visualize git repositories
]; ];
age.secrets."git/github_personal" = lib.mkIf cfg.keys { age.secrets."git/github_personal" = {
file = ../../secrets/git/github_personal.age; file = ../../secrets/git/github_personal.age;
owner = "${user}"; owner = "${user}";
group = "users"; group = "users";
}; };
};
} }

View File

@ -1,7 +1,9 @@
{ config, lib, pkgs, user, inputs, home-manager, ... }: { config, lib, pkgs, user, inputs, home-manager, ... }:
let cfg = config.modules.desktop; let cfg = config.modules.programs.kitty;
in { in {
options.modules.programs.kitty.enable = lib.mkEnableOption "kitty";
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
home-manager.users.${user} = { home-manager.users.${user} = {
home.packages = with pkgs; [ home.packages = with pkgs; [

View File

@ -3,6 +3,7 @@
let cfg = config.modules.programs.virt-manager; let cfg = config.modules.programs.virt-manager;
in { in {
options.modules.programs.virt-manager.enable = lib.mkEnableOption "virt-manager"; options.modules.programs.virt-manager.enable = lib.mkEnableOption "virt-manager";
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
virt-manager # Desktop application for managing virtual machines through libvirt virt-manager # Desktop application for managing virtual machines through libvirt

View File

@ -1,7 +1,9 @@
{ config, lib, pkgs, user, ... }: { config, lib, pkgs, user, ... }:
let cfg = config.modules.base-plus; let cfg = config.modules.programs.yt-dlp;
in { in {
options.modules.programs.yt-dlp.enable = lib.mkEnableOption "yt-dlp";
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
yt-dlp # Command-line tool to download videos yt-dlp # Command-line tool to download videos