From 7938019d55c0a3bf322edfd4023d2bdfc34f8b03 Mon Sep 17 00:00:00 2001 From: Artur Manuel Date: Tue, 21 Jan 2025 15:45:42 +0000 Subject: [PATCH] refactor(modules): rewrite some modules; add dconf --- hosts/micronix/fonts.nix | 2 +- hosts/python/apps.nix | 16 +++++---- hosts/python/fonts.nix | 2 +- hosts/python/theme.nix | 28 +++++---------- hosts/shared/aliases.nix | 14 ++++++-- hosts/shared/dconf.nix | 71 +++++++++++++++++++++++++++++++++++++++ hosts/shared/default.nix | 1 + hosts/shared/direnv.nix | 4 +-- hosts/shared/fonts.nix | 4 +-- hosts/shared/git.nix | 4 +-- hosts/shared/libvirt.nix | 4 +-- hosts/shared/pipewire.nix | 4 +-- hosts/shared/river.nix | 4 +-- hosts/shared/ssh.nix | 4 +-- hosts/shared/xonsh.nix | 28 +++++++-------- 15 files changed, 131 insertions(+), 59 deletions(-) create mode 100644 hosts/shared/dconf.nix diff --git a/hosts/micronix/fonts.nix b/hosts/micronix/fonts.nix index 2cb41d6..e2a8aa5 100644 --- a/hosts/micronix/fonts.nix +++ b/hosts/micronix/fonts.nix @@ -1,5 +1,5 @@ {pkgs, ...}: { - alqueva.fonts = { + alqueva.system.fonts = { enable = true; names = { sansSerif = ["Liberation Sans"]; diff --git a/hosts/python/apps.nix b/hosts/python/apps.nix index e22db47..c511f70 100644 --- a/hosts/python/apps.nix +++ b/hosts/python/apps.nix @@ -18,16 +18,18 @@ }; alqueva = { - xonsh = { + programs = { + libvirt.enable = true; + direnv.enable = true; + git.enable = true; + openssh.enable = true; + }; + shells.xonsh = { enable = true; package = pkgs.amadaluzian-xonsh; }; - libvirt.enable = true; - direnv.enable = true; - git.enable = true; - pipewire.enable = true; - openssh.enable = true; - river.enable = true; + system.pipewire.enable = true; + wms.river.enable = true; }; xdg.mime = { diff --git a/hosts/python/fonts.nix b/hosts/python/fonts.nix index 0ee74ea..3eebb7f 100644 --- a/hosts/python/fonts.nix +++ b/hosts/python/fonts.nix @@ -1,5 +1,5 @@ {pkgs, ...}: { - alqueva.fonts = { + alqueva.system.fonts = { names = { sansSerif = ["Fira Sans"]; monospace = ["Fira Mono"]; diff --git a/hosts/python/theme.nix b/hosts/python/theme.nix index 597b28e..47dbbe7 100644 --- a/hosts/python/theme.nix +++ b/hosts/python/theme.nix @@ -1,8 +1,4 @@ -{ - pkgs, - lib, - ... -}: let +{pkgs, ...}: let themes = { gtk-theme = pkgs.nightfox-gtk-theme.override { colorVariants = ["dark"]; @@ -14,21 +10,15 @@ cursor-theme = pkgs.simp1e-cursors; }; in { - programs.dconf = { + alqueva.system.dconf = { enable = true; - profiles.user.databases = [ - { - settings = { - "org/gnome/desktop/interface" = { - color-scheme = "prefer-dark"; - cursor-size = lib.gvariant.mkUint32 24; - cursor-theme = "Simp1e-Adw-Dark"; - icon-theme = "Colloid-Dark"; - gtk-theme = "Nightfox-Purple-Dark-Compact-Carbon"; - }; - }; - } - ]; + luminosity = "dark"; + theme = "Nightfox-Purple-Dark-Compact-Carbon"; + icon.theme = "Colloid-Dark"; + cursor = { + size = 24; + theme = "Simp1e-Adw-Dark"; + }; }; qt = { diff --git a/hosts/shared/aliases.nix b/hosts/shared/aliases.nix index ace9f73..f39e21e 100644 --- a/hosts/shared/aliases.nix +++ b/hosts/shared/aliases.nix @@ -1,10 +1,20 @@ -{pkgs, ...}: let +{ + pkgs, + config, + lib, + ... +}: let ezaOptions = "--colour=always --icons=never --group-directories-first --octal-permissions"; + cfg = config.alqueva.shells.aliases; in { - config = { + options.alqueva.shells.aliases = { + enable = (lib.mkEnableOption "default aliases") // {default = true;}; + }; + config = lib.mkIf cfg.enable { environment = { shellAliases = builtins.mapAttrs (_: v: "${v} ${ezaOptions}") { l = "eza -alh"; + la = "eza -ah"; ls = "eza"; ll = "eza -l"; }; diff --git a/hosts/shared/dconf.nix b/hosts/shared/dconf.nix new file mode 100644 index 0000000..10db9ae --- /dev/null +++ b/hosts/shared/dconf.nix @@ -0,0 +1,71 @@ +{ + config, + lib, + ... +}: let + cfg = config.alqueva.system.dconf; + inherit (lib) types; +in { + options.alqueva.system.dconf = { + enable = lib.mkEnableOption "configuration with DConf"; + luminosity = lib.mkOption { + type = types.enum ["dark" "light"]; + default = "dark"; + description = "The luminosity you want to use for GTK."; + apply = lum: "prefer-${lum}"; + }; + theme = lib.mkOption { + type = types.str; + description = "The theme you want to use for GTK."; + default = ""; + }; + icon.theme = lib.mkOption { + type = types.str; + description = "The icon theme you want to use for GTK."; + default = ""; + }; + cursor = { + theme = lib.mkOption { + type = types.str; + description = "The cursor theme you want to use for GTK."; + default = ""; + }; + size = lib.mkOption { + type = types.ints.u32; + default = 24; + description = "The cursor size you want to use for GTK."; + apply = size: lib.gvariant.mkUint32 size; + }; + }; + extraDconfPackages = lib.mkOption { + type = types.listOf types.package; + description = "Extra packages to install for DConf."; + default = []; + }; + extraDconfSettings = lib.mkOption { + type = types.attrsOf types.anything; + description = "Extra settings you want to apply to DConf."; + default = {}; + }; + }; + config = lib.mkIf cfg.enable { + programs.dconf = { + profiles.user.databases = [ + { + settings = + { + "org/gnome/desktop/interface" = { + color-scheme = cfg.luminosity; + cursor-size = cfg.cursor.size; + cursor-theme = cfg.cursor.theme; + icon-theme = cfg.icon.theme; + gtk-theme = cfg.theme; + }; + } + // cfg.extraDconfSettings; + } + ]; + packages = cfg.extraDconfPackages; + }; + }; +} diff --git a/hosts/shared/default.nix b/hosts/shared/default.nix index 386331c..e3e3f22 100644 --- a/hosts/shared/default.nix +++ b/hosts/shared/default.nix @@ -11,5 +11,6 @@ ./support.nix ./users.nix ./xonsh.nix + ./dconf.nix ]; } diff --git a/hosts/shared/direnv.nix b/hosts/shared/direnv.nix index 862c1bb..2968ba9 100644 --- a/hosts/shared/direnv.nix +++ b/hosts/shared/direnv.nix @@ -3,9 +3,9 @@ lib, ... }: let - cfg = config.alqueva.direnv; + cfg = config.alqueva.programs.direnv; in { - options.alqueva.direnv = { + options.alqueva.programs.direnv = { enable = lib.mkEnableOption "direnv"; }; diff --git a/hosts/shared/fonts.nix b/hosts/shared/fonts.nix index d0bf662..c4cde79 100644 --- a/hosts/shared/fonts.nix +++ b/hosts/shared/fonts.nix @@ -4,7 +4,7 @@ lib, ... }: let - cfg = config.alqueva.fonts; + cfg = config.alqueva.system.fonts; inherit (lib) types mkOption; mkStringsOption = default: letterform: mkOption { @@ -19,7 +19,7 @@ description = "The packages you want to use for your ${letterform} fonts."; }; in { - options.alqueva.fonts = { + options.alqueva.system.fonts = { enable = lib.mkEnableOption "" // {description = "Whether you want to use this fonts module.";}; packages = { diff --git a/hosts/shared/git.nix b/hosts/shared/git.nix index e4f9551..b9c8075 100644 --- a/hosts/shared/git.nix +++ b/hosts/shared/git.nix @@ -3,9 +3,9 @@ lib, ... }: let - cfg = config.alqueva.git; + cfg = config.alqueva.programs.git; in { - options.alqueva.git = { + options.alqueva.programs.git = { enable = lib.mkEnableOption "git"; }; diff --git a/hosts/shared/libvirt.nix b/hosts/shared/libvirt.nix index 11f0c50..52c5ea9 100644 --- a/hosts/shared/libvirt.nix +++ b/hosts/shared/libvirt.nix @@ -4,9 +4,9 @@ pkgs, ... }: let - cfg = config.alqueva.libvirt; + cfg = config.alqueva.programs.libvirt; in { - options.alqueva.libvirt = { + options.alqueva.programs.libvirt = { enable = lib.mkEnableOption "libvirt"; }; diff --git a/hosts/shared/pipewire.nix b/hosts/shared/pipewire.nix index 58ab110..18aa47d 100644 --- a/hosts/shared/pipewire.nix +++ b/hosts/shared/pipewire.nix @@ -4,9 +4,9 @@ lib, ... }: let - cfg = config.alqueva.pipewire; + cfg = config.alqueva.system.pipewire; in { - options.alqueva.pipewire = { + options.alqueva.system.pipewire = { enable = lib.mkEnableOption "PipeWire"; }; diff --git a/hosts/shared/river.nix b/hosts/shared/river.nix index 1ddeb9b..a5b7f3b 100644 --- a/hosts/shared/river.nix +++ b/hosts/shared/river.nix @@ -4,9 +4,9 @@ pkgs, ... }: let - cfg = config.alqueva.river; + cfg = config.alqueva.wms.river; in { - options.alqueva.river = { + options.alqueva.wms.river = { enable = lib.mkEnableOption "River"; }; diff --git a/hosts/shared/ssh.nix b/hosts/shared/ssh.nix index bc97a13..ba02ed0 100644 --- a/hosts/shared/ssh.nix +++ b/hosts/shared/ssh.nix @@ -3,9 +3,9 @@ lib, ... }: let - cfg = config.alqueva.openssh; + cfg = config.alqueva.programs.openssh; in { - options.alqueva.openssh = { + options.alqueva.programs.openssh = { enable = lib.mkEnableOption "OpenSSH"; }; diff --git a/hosts/shared/xonsh.nix b/hosts/shared/xonsh.nix index 0c82424..42eaa88 100644 --- a/hosts/shared/xonsh.nix +++ b/hosts/shared/xonsh.nix @@ -4,15 +4,12 @@ lib, ... }: let - cfg = config.alqueva.xonsh; - attrsToPyDict = attrs: (lib.pipe attrs [ - (builtins.mapAttrs (n: v: "aliases['${n}'] = '${v}'")) - builtins.attrValues - (lib.concatStringsSep "\n") - (s: s + "\n") - ]); + cfg = config.alqueva.shells.xonsh; + aliasesToPyDict = aliases: + lib.concatStringsSep "\n" + (lib.mapAttrsToList (k: v: "aliases['${k}'] = '${v}'") aliases); in { - options.alqueva.xonsh = { + options.alqueva.shells.xonsh = { enable = lib.mkEnableOption "xonsh"; package = lib.mkPackageOption pkgs "xonsh" {}; }; @@ -20,13 +17,14 @@ in { config = lib.mkIf cfg.enable { programs = { xonsh = { - config = - "from xonsh.xontribs import get_xontribs\n" - + attrsToPyDict config.environment.shellAliases - + '' - for xontrib in get_xontribs(): - xontrib load @(xontrib) - ''; + config = '' + from xonsh.xontribs import get_xontribs + + ${aliasesToPyDict config.environment.shellAliases} + + for xontrib in get_xontribs(): + xontrib load @(xontrib) + ''; inherit (cfg) package; enable = true; };