1

Refactor home modules into config + options

This commit is contained in:
2023-04-26 12:32:29 +02:00
parent 6a8d003f4a
commit 156f87c077
29 changed files with 244 additions and 173 deletions

View File

@ -8,20 +8,20 @@
...
}: {
imports = [
./audio.nix
./emacs.nix
./email.nix
./firefox.nix
./fish.nix
./flatpak.nix
./gaming.nix
./gnome.nix
./hyprland.nix
./kitty.nix
./misc.nix
./neovim.nix
./nextcloud.nix
./plasma.nix
./ranger.nix
./audio/default.nix
./emacs/default.nix
./email/default.nix
./firefox/default.nix
./fish/default.nix
./flatpak/default.nix
./gaming/default.nix
./gnome/default.nix
./hyprland/default.nix
./kitty/default.nix
./misc/default.nix
./neovim/default.nix
./nextcloud/default.nix
./plasma/default.nix
./ranger/default.nix
];
}

View File

@ -18,20 +18,7 @@ in {
# Options is a vector of options this module defines
# This module defines only the "emacs" option and suboptions "enable" and "doom"
options.modules.emacs = {
enable = mkEnableOpt "Emacs module";
# TODO: Use an enum for this not individual options
nixpkgs = mkBoolOpt false "Use Emacs from the official repositories";
nativeComp = mkBoolOpt false "Use Emacs 28.x branch with native comp support";
pgtkNativeComp = mkBoolOpt false "Use Emacs 29.x branch with native comp and pure gtk support";
doom = {
enable = mkEnableOpt "Doom Emacs framework";
autoSync = mkBoolOpt false "Sync Doom Emacs on nixos-rebuild";
autoUpgrade = mkBoolOpt false "Upgrade Doom Emacs on nixos-rebuild";
};
};
options.modules.emacs = import ./options.nix { inherit lib; };
# Config is the merged set of all module configurations
# Here we define what happens to the config if the module is active (but only if the module is active)

View File

@ -0,0 +1,18 @@
{
lib
}:
with lib;
{
enable = mkEnableOpt "Emacs module";
# TODO: Use an enum for this not individual options
nixpkgs = mkBoolOpt false "Use Emacs from the official repositories";
nativeComp = mkBoolOpt false "Use Emacs 28.x branch with native comp support";
pgtkNativeComp = mkBoolOpt false "Use Emacs 29.x branch with native comp and pure gtk support";
doom = {
enable = mkEnableOpt "Doom Emacs framework";
autoSync = mkBoolOpt false "Sync Doom Emacs on nixos-rebuild";
autoUpgrade = mkBoolOpt false "Upgrade Doom Emacs on nixos-rebuild";
};
}

View File

@ -14,16 +14,7 @@ with lib;
with mylib.modules; let
cfg = config.modules.email;
in {
options.modules.email = {
enable = mkEnableOpt "Email";
autosync = mkEnableOpt "Automatically call \"notmuch new\" via systemd timer";
imapnotify = mkEnableOpt "Use imapnotify to sync and index mail automatically";
kmail = {
enable = mkEnableOpt "Kmail";
autostart = mkEnableOpt "Autostart Kmail";
};
};
options.modules.email = import ./options.nix { inherit lib; };
# TODO: Add Maildir to nextcloud sync
config = mkIf cfg.enable {

View File

@ -0,0 +1,14 @@
{
lib
}:
with lib;
{
enable = mkEnableOpt "Email";
autosync = mkEnableOpt "Automatically call \"notmuch new\" via systemd timer";
imapnotify = mkEnableOpt "Use imapnotify to sync and index mail automatically";
kmail = {
enable = mkEnableOpt "Kmail";
autostart = mkEnableOpt "Autostart Kmail";
};
}

View File

@ -12,14 +12,7 @@ with lib;
with mylib.modules; let
cfg = config.modules.firefox;
in {
options.modules.firefox = {
enable = mkEnableOpt "Firefox";
wayland = mkBoolOpt false "Enable firefox wayland support";
vaapi = mkBoolOpt false "Enable firefox vaapi support";
disableTabBar = mkBoolOpt false "Disable the firefox tab bar (for TST)";
defaultBookmarks = mkBoolOpt false "Preset standard bookmarks and folders";
gnomeTheme = mkBoolOpt false "Use Firefox gnome theme (rafaelmardojai)";
};
options.modules.firefox = import ./options.nix { inherit lib; };
config = mkIf cfg.enable {
home.packages = with pkgs;

View File

@ -0,0 +1,12 @@
{
lib
}:
with lib;
{
enable = mkEnableOpt "Firefox";
wayland = mkBoolOpt false "Enable firefox wayland support";
vaapi = mkBoolOpt false "Enable firefox vaapi support";
disableTabBar = mkBoolOpt false "Disable the firefox tab bar (for TST)";
defaultBookmarks = mkBoolOpt false "Preset standard bookmarks and folders";
gnomeTheme = mkBoolOpt false "Use Firefox gnome theme (rafaelmardojai)";
}

View File

@ -10,9 +10,7 @@ with lib;
with mylib.modules; let
cfg = config.modules.fish;
in {
options.modules.fish = {
enable = mkEnableOpt "Fish";
};
options.modules.fish = import ./options.nix { inherit lib; };
config = mkIf cfg.enable {
programs.fish = {
@ -90,7 +88,7 @@ in {
blk = batify "lsblk -o NAME,LABEL,UUID,FSTYPE,SIZE,FSUSE%,MOUNTPOINT,MODEL";
grep = "grep --color=auto -E"; # grep with extended regex
watch = "watch -d -c -n 0.5";
n = "nnncd -a -P p"; # Doesn't work with abbrify because I have nnn.override?
n = "nnncd -a -P p -e"; # Doesn't work with abbrify because I have nnn.override?
# systemd
failed = "systemctl --failed";

View File

@ -0,0 +1,7 @@
{
lib
}:
with lib;
{
enable = mkEnableOpt "Fish";
}

View File

@ -14,54 +14,7 @@ with mylib.modules;
let
cfg = config.modules.flatpak;
in {
options.modules.flatpak = {
enable = mkEnableOpt "Flatpak module";
fontFix = mkBoolOpt true "Link fonts to ~/.local/share/fonts so flatpak apps can find them";
iconFix = mkBoolOpt true "Link icons to ~/.local/share/icons so flatpak apps can find them";
autoUpdate = mkBoolOpt false "Update flatpak apps on nixos-rebuild";
autoPrune = mkBoolOpt false "Remove unused packages on nixos-rebuild";
# TODO: Add library function to make this easier
# TODO: The flatpak name should be included and a list of all enabled apps should be available
# TODO: Do this for strings + packages
discord.enable = mkEnableOpt "Discord";
spotify.enable = mkEnableOpt "Spotify";
flatseal.enable = mkEnableOpt "Flatseal";
bottles.enable = mkEnableOpt "Bottles";
obsidian.enable = mkEnableOpt "Obsidian";
jabref.enable = mkEnableOpt "Jabref";
# xwaylandvideobridge = mkEnableOpt "XWayland Video Bridge"; # TODO
# This is mainly used by other modules to allow them to use flatpak packages
extraInstall = mkOption {
type = types.listOf types.str;
default = [];
description = "Flatpaks that will be installed additionally";
};
# This doesn't uninstall if any flatpak is still present in the extraInstall list
extraRemove = mkOption {
type = types.listOf types.str;
default = [];
description = "Flatpaks that will be removed additionally (use with extraInstall)";
};
extraOverride = mkOption {
type = types.listOf types.attrs;
default = [];
# TODO: Change the format to { "com.usebottles.bottles" = [ "~/Documents" "~/Downloads" ]; }
# TODO: This requires that the lists of the same key are being merged recursively, mkMerge would override the key
example = [{"com.usebottles.bottles" = "\${config.home.homeDirectory}/Documents";}];
description = "Additional overrides";
};
extraGlobalOverride = mkOption {
type = types.listOf types.str;
default = [];
example = ["\${config.home.homeDirectory}/Documents:ro"];
description = "Additional global overrides";
};
};
options.modules.flatpak = import ./options.nix { inherit lib; };
config = mkIf cfg.enable {
assertions = [

View File

@ -0,0 +1,53 @@
{
lib
}:
with lib;
{
enable = mkEnableOpt "Flatpak module";
fontFix = mkBoolOpt true "Link fonts to ~/.local/share/fonts so flatpak apps can find them";
iconFix = mkBoolOpt true "Link icons to ~/.local/share/icons so flatpak apps can find them";
autoUpdate = mkBoolOpt false "Update flatpak apps on nixos-rebuild";
autoPrune = mkBoolOpt false "Remove unused packages on nixos-rebuild";
# TODO: Add library function to make this easier
# TODO: The flatpak name should be included and a list of all enabled apps should be available
# TODO: Do this for strings + packages
discord.enable = mkEnableOpt "Discord";
spotify.enable = mkEnableOpt "Spotify";
flatseal.enable = mkEnableOpt "Flatseal";
bottles.enable = mkEnableOpt "Bottles";
obsidian.enable = mkEnableOpt "Obsidian";
jabref.enable = mkEnableOpt "Jabref";
# xwaylandvideobridge = mkEnableOpt "XWayland Video Bridge"; # TODO
# TODO: Can I use extraInstall = { "com.valve.Steam" = true/false; } and pass the module option as value?
# This is mainly used by other modules to allow them to use flatpak packages
extraInstall = mkOption {
type = types.listOf types.str;
default = [];
description = "Flatpaks that will be installed additionally";
};
# This doesn't uninstall if any flatpak is still present in the extraInstall list
extraRemove = mkOption {
type = types.listOf types.str;
default = [];
description = "Flatpaks that will be removed additionally (use with extraInstall)";
};
extraOverride = mkOption {
type = types.listOf types.attrs;
default = [];
# TODO: Change the format to { "com.usebottles.bottles" = [ "~/Documents" "~/Downloads" ]; }
# TODO: This requires that the lists of the same key are being merged recursively, mkMerge would override the key
example = [{"com.usebottles.bottles" = "\${config.home.homeDirectory}/Documents";}];
description = "Additional overrides";
};
extraGlobalOverride = mkOption {
type = types.listOf types.str;
default = [];
example = ["\${config.home.homeDirectory}/Documents:ro"];
description = "Additional global overrides";
};
}

View File

@ -19,22 +19,7 @@ in {
# TODO: SteamTinkerLaunch option
# TODO: Dolphin + SteamRomManager option
options.modules.gaming = {
enable = mkEnableOpt "Gaming module";
# discordElectron.enable = mkEnableOpt "Discord (Electron) (nixpkgs)";
# discordChromium.enable = mkEnableOpt "Discord (Chromium)";
prism.enable = mkEnableOpt "PrismLauncher for Minecraft (flatpak)";
bottles.enable = mkEnableOpt "Bottles (flatpak)";
# dwarffortress.enable = mkEnableOpt "Dwarf Fortress";
steam = {
enable = mkEnableOpt "Steam (flatpak)";
gamescope = mkBoolOpt false "Enable the gamescope micro compositor (flatpak)";
adwaita = mkBoolOpt false "Enable the adwaita-for-steam skin";
protonup = mkBoolOpt false "Enable ProtonUP-QT";
};
};
options.modules.gaming = import ./options.nix { inherit lib; };
config = mkIf cfg.enable {
assertions = [

View File

@ -0,0 +1,20 @@
{
lib
}:
with lib;
{
enable = mkEnableOpt "Gaming module";
# discordElectron.enable = mkEnableOpt "Discord (Electron) (nixpkgs)";
# discordChromium.enable = mkEnableOpt "Discord (Chromium)";
prism.enable = mkEnableOpt "PrismLauncher for Minecraft (flatpak)";
bottles.enable = mkEnableOpt "Bottles (flatpak)";
# dwarffortress.enable = mkEnableOpt "Dwarf Fortress";
steam = {
enable = mkEnableOpt "Steam (flatpak)";
gamescope = mkBoolOpt false "Enable the gamescope micro compositor (flatpak)";
adwaita = mkBoolOpt false "Enable the adwaita-for-steam skin";
protonup = mkBoolOpt false "Enable ProtonUP-QT";
};
}

View File

@ -10,25 +10,7 @@ with lib;
with mylib.modules; let
cfg = config.modules.gnome;
in {
options.modules.gnome = {
enable = mkEnableOpt "Gnome Desktop";
# TODO: Add option for dash-to-dock
extensions = mkBoolOpt false "Enable Gnome shell-extensions";
# TODO: Add other themes, whitesur for example
theme = {
papirusIcons = mkBoolOpt false "Enable the Papirus icon theme";
numixCursor = mkBoolOpt false "Enable the Numix cursor theme";
wallpaper = mkOption {
type = types.str;
default = "constructionsite";
description = "What wallpaper to use";
};
};
settings = {
};
};
options.modules.gnome = import ./options.nix { inherit lib; };
config = mkIf cfg.enable {
assertions = [

View File

@ -0,0 +1,23 @@
{
lib
}:
with lib;
{
enable = mkEnableOpt "Gnome Desktop";
# TODO: Add option for dash-to-dock
extensions = mkBoolOpt false "Enable Gnome shell-extensions";
# TODO: Add other themes, whitesur for example
theme = {
papirusIcons = mkBoolOpt false "Enable the Papirus icon theme";
numixCursor = mkBoolOpt false "Enable the Numix cursor theme";
wallpaper = mkOption {
type = types.str;
default = "constructionsite";
description = "What wallpaper to use";
};
};
settings = {
};
}

View File

@ -10,14 +10,7 @@ with lib;
with mylib.modules; let
cfg = config.modules.hyprland;
in {
options.modules.hyprland = {
enable = mkEnableOpt "Hyprland Window Manager + Compositor";
theme = mkOption {
type = types.str;
description = "Wallpaper and colorscheme to use";
};
};
options.modules.hyprland = import ./options.nix { inherit lib; };
config = let
# Taken from https://github.com/Ruixi-rebirth/flakes/blob/main/modules/programs/wayland/waybar/workspace-patch.nix

View File

@ -0,0 +1,12 @@
{
lib
}:
with lib;
{
enable = mkEnableOpt "Hyprland Window Manager + Compositor";
theme = mkOption {
type = types.str;
description = "Wallpaper and colorscheme to use";
};
}

View File

@ -11,9 +11,7 @@ with mylib.modules; let
cfg = config.modules.kitty;
# cfgnv = config.modules.neovim;
in {
options.modules.kitty = {
enable = mkEnableOpt "Kitty";
};
options.modules.kitty = import ./options.nix { inherit lib; };
config = mkIf cfg.enable {
programs.kitty = {

View File

@ -0,0 +1,7 @@
{
lib
}:
with lib;
{
enable = mkEnableOpt "Kitty";
}

View File

@ -10,19 +10,7 @@ with lib;
with mylib.modules; let
cfg = config.modules.misc;
in {
options.modules.misc = {
enable = mkEnableOpt "Misc module";
keepass = {
enable = mkEnableOpt "KeePassXC";
autostart = mkBoolOpt false "Autostart KeePassXC";
};
protonmail = {
enable = mkEnableOpt "ProtonMail";
autostart = mkBoolOpt false "Autostart ProtonMail Bridge";
};
};
options.modules.misc = import ./options.nix { inherit lib; };
config = mkIf cfg.enable {
home.packages = with pkgs;

View File

@ -0,0 +1,17 @@
{
lib
}:
with lib;
{
enable = mkEnableOpt "Misc module";
keepass = {
enable = mkEnableOpt "KeePassXC";
autostart = mkBoolOpt false "Autostart KeePassXC";
};
protonmail = {
enable = mkEnableOpt "ProtonMail";
autostart = mkBoolOpt false "Autostart ProtonMail Bridge";
};
}

View File

@ -10,10 +10,7 @@ with lib;
with mylib.modules; let
cfg = config.modules.neovim;
in {
options.modules.neovim = {
enable = mkEnableOpt "NeoVim";
alias = mkBoolOpt false "Link nvim to vim/vi";
};
options.modules.neovim = import ./options.nix { inherit lib; };
config = mkIf cfg.enable {
# TODO: Configure by option

View File

@ -0,0 +1,8 @@
{
lib
}:
with lib;
{
enable = mkEnableOpt "NeoVim";
alias = mkBoolOpt false "Link nvim to vim/vi";
}

View File

@ -13,10 +13,7 @@ with lib;
with mylib.modules; let
cfg = config.modules.nextcloud;
in {
options.modules.nextcloud = {
enable = mkEnableOpt "Nextcloud Client";
autostart = mkBoolOpt false "Autostart the Nextcloud client (systemd)";
};
options.modules.nextcloud = import ./options.nix { inherit lib; };
config = mkIf cfg.enable {
assertions = [

View File

@ -0,0 +1,8 @@
{
lib
}:
with lib;
{
enable = mkEnableOpt "Nextcloud Client";
autostart = mkBoolOpt false "Autostart the Nextcloud client (systemd)";
}

View File

@ -11,9 +11,7 @@ with lib;
with mylib.modules; let
cfg = config.modules.plasma;
in {
options.modules.plasma = {
enable = mkEnableOpt "Plasma Desktop";
};
options.modules.plasma = import ./options.nix { inherit lib; };
config = mkIf cfg.enable {
assertions = [

View File

@ -0,0 +1,7 @@
{
lib
}:
with lib;
{
enable = mkEnableOpt "Plasma Desktop";
}

View File

@ -10,10 +10,7 @@ with lib;
with mylib.modules; let
cfg = config.modules.ranger;
in {
options.modules.ranger = {
enable = mkEnableOpt "Ranger";
preview = mkBoolOpt false "Enable Ranger image preview";
};
options.modules.ranger = import ./options.nix { inherit lib; };
config = mkIf cfg.enable {
home.packages = with pkgs;

View File

@ -0,0 +1,8 @@
{
lib
}:
with lib;
{
enable = mkEnableOpt "Ranger";
preview = mkBoolOpt false "Enable Ranger image preview";
}