From bb55875491c4d3bc4da4c4039072ab6052d5c552 Mon Sep 17 00:00:00 2001 From: Anthony Rodriguez Date: Tue, 14 Jan 2025 10:56:34 +0100 Subject: [PATCH] treewide: move shared/nixosModules to modules The idea of this refactor is, as the configuration is getting bigger and more complex, to move everything into a local modules system. The idea is to simplify hosts declaration and add a new layer of abstraction to avoid the long and redundant imports in hosts/default.nix, that I am currently using. First, we're going to move everything to the modules directory, and split options from the proper configuration. That allows us to have an easier time understanding how the options are structured, as they will follow the directory structure and won't be mixed with the module configuration. --- hosts/default.nix | 2 +- modules/default.nix | 6 ++++ .../options}/default.nix | 4 +-- .../options}/homeVars.nix | 0 .../options.nix => modules/options/style.nix | 2 +- .../options}/systemVars.nix | 0 modules/style/default.nix | 29 ++++++++++++++++ .../style/modules/discord.nix | 0 .../style/modules/fish.nix | 0 .../style/modules/foot.nix | 0 .../style/modules/fuzzel.nix | 0 .../style/modules/gtk.nix | 0 .../style/modules/hyprland.nix | 0 .../style/modules/hyprlock.nix | 0 .../style/modules/niri.nix | 0 .../style/modules/nvf.nix | 0 .../style/modules/regreet.nix | 0 .../style/modules/starship.nix | 0 .../style/modules/swaylock.nix | 0 .../style/modules/swaync.nix | 0 .../style/modules/tidal-hifi.nix | 0 .../style/modules/walker.nix | 0 .../style/modules/waybar.nix | 0 .../style/modules/zathura.nix | 0 shared/nixosModules/style/default.nix | 34 ------------------- 25 files changed, 39 insertions(+), 38 deletions(-) create mode 100644 modules/default.nix rename {shared/nixosModules => modules/options}/default.nix (79%) rename {shared/nixosModules => modules/options}/homeVars.nix (100%) rename shared/nixosModules/style/options.nix => modules/options/style.nix (98%) rename {shared/nixosModules => modules/options}/systemVars.nix (100%) create mode 100644 modules/style/default.nix rename {shared/nixosModules => modules}/style/modules/discord.nix (100%) rename {shared/nixosModules => modules}/style/modules/fish.nix (100%) rename {shared/nixosModules => modules}/style/modules/foot.nix (100%) rename {shared/nixosModules => modules}/style/modules/fuzzel.nix (100%) rename {shared/nixosModules => modules}/style/modules/gtk.nix (100%) rename {shared/nixosModules => modules}/style/modules/hyprland.nix (100%) rename {shared/nixosModules => modules}/style/modules/hyprlock.nix (100%) rename {shared/nixosModules => modules}/style/modules/niri.nix (100%) rename {shared/nixosModules => modules}/style/modules/nvf.nix (100%) rename {shared/nixosModules => modules}/style/modules/regreet.nix (100%) rename {shared/nixosModules => modules}/style/modules/starship.nix (100%) rename {shared/nixosModules => modules}/style/modules/swaylock.nix (100%) rename {shared/nixosModules => modules}/style/modules/swaync.nix (100%) rename {shared/nixosModules => modules}/style/modules/tidal-hifi.nix (100%) rename {shared/nixosModules => modules}/style/modules/walker.nix (100%) rename {shared/nixosModules => modules}/style/modules/waybar.nix (100%) rename {shared/nixosModules => modules}/style/modules/zathura.nix (100%) delete mode 100644 shared/nixosModules/style/default.nix diff --git a/hosts/default.nix b/hosts/default.nix index 257e16b..6ef58aa 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -11,7 +11,7 @@ }; base = [ - ../shared/nixosModules + ../modules "${self}/config/nixos" "${self}/config/nixos/core/home-manager.nix" diff --git a/modules/default.nix b/modules/default.nix new file mode 100644 index 0000000..aa9aa72 --- /dev/null +++ b/modules/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./style + ./options + ]; +} diff --git a/shared/nixosModules/default.nix b/modules/options/default.nix similarity index 79% rename from shared/nixosModules/default.nix rename to modules/options/default.nix index 8286746..816a12e 100644 --- a/shared/nixosModules/default.nix +++ b/modules/options/default.nix @@ -1,7 +1,7 @@ { imports = [ - ./systemVars.nix ./homeVars.nix - ./style + ./style.nix + ./systemVars.nix ]; } diff --git a/shared/nixosModules/homeVars.nix b/modules/options/homeVars.nix similarity index 100% rename from shared/nixosModules/homeVars.nix rename to modules/options/homeVars.nix diff --git a/shared/nixosModules/style/options.nix b/modules/options/style.nix similarity index 98% rename from shared/nixosModules/style/options.nix rename to modules/options/style.nix index 5160be3..63a9a09 100644 --- a/shared/nixosModules/style/options.nix +++ b/modules/options/style.nix @@ -67,7 +67,7 @@ in { description = '' Path to an avatar image (used for hyprlock). ''; - default = ../../../assets/avatar.png; # TODO silly, change this + default = ../../assets/avatar.png; # TODO silly, change this }; gtk = { diff --git a/shared/nixosModules/systemVars.nix b/modules/options/systemVars.nix similarity index 100% rename from shared/nixosModules/systemVars.nix rename to modules/options/systemVars.nix diff --git a/modules/style/default.nix b/modules/style/default.nix new file mode 100644 index 0000000..bce44b0 --- /dev/null +++ b/modules/style/default.nix @@ -0,0 +1,29 @@ +{ + inputs, + config, + lib, + ... +}: let + inherit (lib) mkIf; + + cfg = config.local.style; +in { + imports = + [ + inputs.niri.nixosModules.niri + inputs.hyprland.nixosModules.default + ] + ++ lib.filesystem.listFilesRecursive ./modules; + + config = mkIf cfg.enable { + home-manager.sharedModules = [ + { + home.pointerCursor = { + inherit (cfg.cursorTheme) name package size; + x11.enable = true; + gtk.enable = true; + }; + } + ]; + }; +} diff --git a/shared/nixosModules/style/modules/discord.nix b/modules/style/modules/discord.nix similarity index 100% rename from shared/nixosModules/style/modules/discord.nix rename to modules/style/modules/discord.nix diff --git a/shared/nixosModules/style/modules/fish.nix b/modules/style/modules/fish.nix similarity index 100% rename from shared/nixosModules/style/modules/fish.nix rename to modules/style/modules/fish.nix diff --git a/shared/nixosModules/style/modules/foot.nix b/modules/style/modules/foot.nix similarity index 100% rename from shared/nixosModules/style/modules/foot.nix rename to modules/style/modules/foot.nix diff --git a/shared/nixosModules/style/modules/fuzzel.nix b/modules/style/modules/fuzzel.nix similarity index 100% rename from shared/nixosModules/style/modules/fuzzel.nix rename to modules/style/modules/fuzzel.nix diff --git a/shared/nixosModules/style/modules/gtk.nix b/modules/style/modules/gtk.nix similarity index 100% rename from shared/nixosModules/style/modules/gtk.nix rename to modules/style/modules/gtk.nix diff --git a/shared/nixosModules/style/modules/hyprland.nix b/modules/style/modules/hyprland.nix similarity index 100% rename from shared/nixosModules/style/modules/hyprland.nix rename to modules/style/modules/hyprland.nix diff --git a/shared/nixosModules/style/modules/hyprlock.nix b/modules/style/modules/hyprlock.nix similarity index 100% rename from shared/nixosModules/style/modules/hyprlock.nix rename to modules/style/modules/hyprlock.nix diff --git a/shared/nixosModules/style/modules/niri.nix b/modules/style/modules/niri.nix similarity index 100% rename from shared/nixosModules/style/modules/niri.nix rename to modules/style/modules/niri.nix diff --git a/shared/nixosModules/style/modules/nvf.nix b/modules/style/modules/nvf.nix similarity index 100% rename from shared/nixosModules/style/modules/nvf.nix rename to modules/style/modules/nvf.nix diff --git a/shared/nixosModules/style/modules/regreet.nix b/modules/style/modules/regreet.nix similarity index 100% rename from shared/nixosModules/style/modules/regreet.nix rename to modules/style/modules/regreet.nix diff --git a/shared/nixosModules/style/modules/starship.nix b/modules/style/modules/starship.nix similarity index 100% rename from shared/nixosModules/style/modules/starship.nix rename to modules/style/modules/starship.nix diff --git a/shared/nixosModules/style/modules/swaylock.nix b/modules/style/modules/swaylock.nix similarity index 100% rename from shared/nixosModules/style/modules/swaylock.nix rename to modules/style/modules/swaylock.nix diff --git a/shared/nixosModules/style/modules/swaync.nix b/modules/style/modules/swaync.nix similarity index 100% rename from shared/nixosModules/style/modules/swaync.nix rename to modules/style/modules/swaync.nix diff --git a/shared/nixosModules/style/modules/tidal-hifi.nix b/modules/style/modules/tidal-hifi.nix similarity index 100% rename from shared/nixosModules/style/modules/tidal-hifi.nix rename to modules/style/modules/tidal-hifi.nix diff --git a/shared/nixosModules/style/modules/walker.nix b/modules/style/modules/walker.nix similarity index 100% rename from shared/nixosModules/style/modules/walker.nix rename to modules/style/modules/walker.nix diff --git a/shared/nixosModules/style/modules/waybar.nix b/modules/style/modules/waybar.nix similarity index 100% rename from shared/nixosModules/style/modules/waybar.nix rename to modules/style/modules/waybar.nix diff --git a/shared/nixosModules/style/modules/zathura.nix b/modules/style/modules/zathura.nix similarity index 100% rename from shared/nixosModules/style/modules/zathura.nix rename to modules/style/modules/zathura.nix diff --git a/shared/nixosModules/style/default.nix b/shared/nixosModules/style/default.nix deleted file mode 100644 index b45a5a2..0000000 --- a/shared/nixosModules/style/default.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ - inputs, - config, - lib, - ... -}: let - inherit (lib) mkIf; - - cfg = config.local.style; -in { - imports = - [ - inputs.niri.nixosModules.niri - inputs.hyprland.nixosModules.default - - ./options.nix - ] - ++ lib.filesystem.listFilesRecursive ./modules; - - config = - mkIf - cfg.enable - { - home-manager.sharedModules = [ - { - home.pointerCursor = { - inherit (cfg.cursorTheme) name package size; - x11.enable = true; - gtk.enable = true; - }; - } - ]; - }; -}