diff --git a/flake.nix b/flake.nix index 19877ec..e5115ea 100644 --- a/flake.nix +++ b/flake.nix @@ -121,16 +121,8 @@ ║ Modules ║ ╚══════════════════════════════════════════════════════════╝ */ - nixosModules = utils.lib.exportModules [ - ./modules/profiles/base.nix - ./modules/profiles/gaming.nix - ./modules/profiles/desktop.nix - ./modules/profiles/personal.nix - ]; - hostDefaults.modules = [ ./modules/default.nix - self.nixosModules.base inputs.home-manager.nixosModule { home-manager = { @@ -145,16 +137,11 @@ hosts.nixos-laptop.modules = [ ./hosts/nixos-laptop - self.nixosModules.desktop - self.nixosModules.personal ]; hosts.nixos-desktop.modules = [ ./hosts/nixos-desktop - self.nixosModules.desktop - self.nixosModules.gaming - self.nixosModules.personal ]; /* diff --git a/hosts/nixos-desktop/default.nix b/hosts/nixos-desktop/default.nix index b88a65e..f0c06dd 100644 --- a/hosts/nixos-desktop/default.nix +++ b/hosts/nixos-desktop/default.nix @@ -10,7 +10,13 @@ # Include the results of the hardware scan. ./hardware-configuration.nix ]; + my = { + profiles = { + desktop.enable = true; + gaming.enable = true; + personal.enable = true; + }; programs.hyprland.nvidiaSupport = true; services.mullvad.enable = true; programs.ledger.enable = true; diff --git a/hosts/nixos-laptop/default.nix b/hosts/nixos-laptop/default.nix index 42c242c..f58998f 100644 --- a/hosts/nixos-laptop/default.nix +++ b/hosts/nixos-laptop/default.nix @@ -10,6 +10,11 @@ ./hardware-configuration.nix ]; + my.profiles = { + desktop.enable = true; + personal.enable = true; + }; + # BOOT boot = { supportedFilesystems = [ "btrfs" ]; diff --git a/lib/default.nix b/lib/default.nix index f7a8b1c..a19b79b 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -47,4 +47,34 @@ lib.makeExtensible (_: rec { mapModules' = f: dir: lib.attrValues (mapModules f dir); listModules = mapModules' (path: path); + + mapModulesRec = f: dir: + let + filterDirs = name: type: + let + isPublic = !(lib.hasPrefix "_" name); + isSomething = type != null; + isDir = type == "directory"; + isDefault = isDir && builtins.pathExists "${toString dir}/${name}/default.nix"; + in + isPublic && isSomething && isDir && !isDefault; + + subDirs = lib.filterAttrs filterDirs (builtins.readDir dir); + + mkSubModule = name: _: + let + path = "${toString dir}/${name}"; + in + lib.nameValuePair name (mapModulesRec f path); + in + mapModules f dir // + (lib.mapAttrs' mkSubModule subDirs); + + mapModulesRec' = f: dir: + let + attrValuesRec = attrs: map (values: if lib.isAttrs values then attrValuesRec values else values) (lib.attrValues attrs); + in + lib.flatten (attrValuesRec (mapModulesRec f dir)); + + listModulesRec = mapModulesRec' (path: path); }) diff --git a/modules/config/bin/cycleSinks.nix b/modules/config/bin/_cycleSinks.nix similarity index 100% rename from modules/config/bin/cycleSinks.nix rename to modules/config/bin/_cycleSinks.nix diff --git a/modules/config/bin/protonge.nix b/modules/config/bin/_protonge.nix similarity index 100% rename from modules/config/bin/protonge.nix rename to modules/config/bin/_protonge.nix diff --git a/modules/config/bin/share.nix b/modules/config/bin/_share.nix similarity index 100% rename from modules/config/bin/share.nix rename to modules/config/bin/_share.nix diff --git a/modules/config/bin/sxhkdHelp.nix b/modules/config/bin/_sxhkdHelp.nix similarity index 100% rename from modules/config/bin/sxhkdHelp.nix rename to modules/config/bin/_sxhkdHelp.nix diff --git a/modules/config/bin/default.nix b/modules/config/bin/default.nix index 5cbf5ed..abf3926 100644 --- a/modules/config/bin/default.nix +++ b/modules/config/bin/default.nix @@ -7,10 +7,10 @@ with lib; let cfg = config.my.bin; - cycleSinks = import ./cycleSinks.nix { inherit pkgs; }; - protonge = import ./protonge.nix { inherit pkgs; }; - share = import ./share.nix { inherit pkgs; }; - sxhkdHelp = import ./sxhkdHelp.nix { inherit pkgs; }; + cycleSinks = import ./_cycleSinks.nix { inherit pkgs; }; + protonge = import ./_protonge.nix { inherit pkgs; }; + share = import ./_share.nix { inherit pkgs; }; + sxhkdHelp = import ./_sxhkdHelp.nix { inherit pkgs; }; in { options.my.bin.enable = mkEnableOption "bin"; diff --git a/modules/config/default.nix b/modules/config/default.nix deleted file mode 100644 index 1a044e4..0000000 --- a/modules/config/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ lib, ... }: - -{ - imports = lib.my.listModules ./.; -} diff --git a/modules/config/theming/catppuccin.nix b/modules/config/theming/_catppuccin.nix similarity index 100% rename from modules/config/theming/catppuccin.nix rename to modules/config/theming/_catppuccin.nix diff --git a/modules/config/theming/catppuccin-frappe.nix b/modules/config/theming/catppuccin-frappe.nix index 6be8d62..0a98a0f 100644 --- a/modules/config/theming/catppuccin-frappe.nix +++ b/modules/config/theming/catppuccin-frappe.nix @@ -6,7 +6,7 @@ let in { config = mkIf (cfg.enable && cfg.scheme == "catppuccin-frappe") - (import ./catppuccin.nix + (import ./_catppuccin.nix { inherit config lib pkgs; flavor = "mocha"; diff --git a/modules/config/theming/catppuccin-latte.nix b/modules/config/theming/catppuccin-latte.nix index 96051cb..3c64d83 100644 --- a/modules/config/theming/catppuccin-latte.nix +++ b/modules/config/theming/catppuccin-latte.nix @@ -6,7 +6,7 @@ let in { config = mkIf (cfg.enable && cfg.scheme == "catppuccin-latte") - (import ./catppuccin.nix + (import ./_catppuccin.nix { inherit config lib pkgs; flavor = "mocha"; diff --git a/modules/config/theming/catppuccin-macchiato.nix b/modules/config/theming/catppuccin-macchiato.nix index c8e0a6c..f65449f 100644 --- a/modules/config/theming/catppuccin-macchiato.nix +++ b/modules/config/theming/catppuccin-macchiato.nix @@ -6,7 +6,7 @@ let in { config = mkIf (cfg.enable && cfg.scheme == "catppuccin-macchiato") - (import ./catppuccin.nix + (import ./_catppuccin.nix { inherit config lib pkgs; flavor = "mocha"; diff --git a/modules/config/theming/catppuccin-mocha.nix b/modules/config/theming/catppuccin-mocha.nix index 4cfc510..732ab23 100644 --- a/modules/config/theming/catppuccin-mocha.nix +++ b/modules/config/theming/catppuccin-mocha.nix @@ -6,7 +6,7 @@ let in { config = mkIf (cfg.enable && cfg.scheme == "catppuccin-mocha") - (import ./catppuccin.nix + (import ./_catppuccin.nix { inherit config lib pkgs; flavor = "mocha"; diff --git a/modules/config/wallpapers.nix b/modules/config/wallpapers/default.nix similarity index 100% rename from modules/config/wallpapers.nix rename to modules/config/wallpapers/default.nix diff --git a/modules/config/wallpapers/a_short_walk.png b/modules/config/wallpapers/wallpapers/a_short_walk.png similarity index 100% rename from modules/config/wallpapers/a_short_walk.png rename to modules/config/wallpapers/wallpapers/a_short_walk.png diff --git a/modules/config/wallpapers/blender_pink_blue.jpg b/modules/config/wallpapers/wallpapers/blender_pink_blue.jpg similarity index 100% rename from modules/config/wallpapers/blender_pink_blue.jpg rename to modules/config/wallpapers/wallpapers/blender_pink_blue.jpg diff --git a/modules/config/wallpapers/elephants.jpg b/modules/config/wallpapers/wallpapers/elephants.jpg similarity index 100% rename from modules/config/wallpapers/elephants.jpg rename to modules/config/wallpapers/wallpapers/elephants.jpg diff --git a/modules/config/wallpapers/forest_road.jpg b/modules/config/wallpapers/wallpapers/forest_road.jpg similarity index 100% rename from modules/config/wallpapers/forest_road.jpg rename to modules/config/wallpapers/wallpapers/forest_road.jpg diff --git a/modules/config/wallpapers/little-ships.png b/modules/config/wallpapers/wallpapers/little-ships.png similarity index 100% rename from modules/config/wallpapers/little-ships.png rename to modules/config/wallpapers/wallpapers/little-ships.png diff --git a/modules/config/wallpapers/old-hardware.jpg b/modules/config/wallpapers/wallpapers/old-hardware.jpg similarity index 100% rename from modules/config/wallpapers/old-hardware.jpg rename to modules/config/wallpapers/wallpapers/old-hardware.jpg diff --git a/modules/config/wallpapers/stardust.jpg b/modules/config/wallpapers/wallpapers/stardust.jpg similarity index 100% rename from modules/config/wallpapers/stardust.jpg rename to modules/config/wallpapers/wallpapers/stardust.jpg diff --git a/modules/config/wallpapers/whale_in_sky.jpg b/modules/config/wallpapers/wallpapers/whale_in_sky.jpg similarity index 100% rename from modules/config/wallpapers/whale_in_sky.jpg rename to modules/config/wallpapers/wallpapers/whale_in_sky.jpg diff --git a/modules/default.nix b/modules/default.nix index 6e3b243..70fe578 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,9 +1,4 @@ +{ lib, ... }: { - imports = [ - ./config - ./programs - ./security - ./services - ./virtualisation - ]; + imports = lib.my.listModulesRec ./.; } diff --git a/modules/profiles/desktop.nix b/modules/profiles/desktop.nix index ac348a0..678df5c 100644 --- a/modules/profiles/desktop.nix +++ b/modules/profiles/desktop.nix @@ -1,73 +1,83 @@ { lib +, config , pkgs , ... }: -with lib; { - my = { - yubikey = { - enable = mkDefault true; - luksSupport = { + +with lib; +let + cfg = config.my.profiles.desktop; +in +{ + options.my.profiles.desktop.enable = mkEnableOption "desktop profile"; + + config = mkIf cfg.enable { + my = { + yubikey = { enable = mkDefault true; - devices = mkDefault [ "enc" ]; + luksSupport = { + enable = mkDefault true; + devices = mkDefault [ "enc" ]; + }; + }; + wallpapers.enable = mkDefault true; + theming = { + enable = mkDefault true; + scheme = mkDefault "catppuccin-macchiato"; + }; + virtualisation.podman.enable = mkDefault true; + + programs = { + chromium.enable = mkDefault true; + firefox.enable = mkDefault true; + gpg.enable = mkDefault true; + hyprland.enable = mkDefault true; + logseq.enable = mkDefault true; + nvim.enable = mkDefault true; + python.versions."311".enable = mkDefault true; + spotify.enable = mkDefault true; + ssh.enable = mkDefault true; + thunar.enable = mkDefault true; + wallpaper.enable = mkDefault true; + zathura.enable = mkDefault true; + }; + services = { + dunst.enable = mkDefault true; + gammastep.enable = true; + kdeconnect.enable = mkDefault true; + printing.enable = true; + wireguard.enable = true; }; }; - wallpapers.enable = mkDefault true; - theming = { - enable = mkDefault true; - scheme = mkDefault "catppuccin-macchiato"; - }; - virtualisation.podman.enable = mkDefault true; - programs = { - chromium.enable = mkDefault true; - firefox.enable = mkDefault true; - gpg.enable = mkDefault true; - hyprland.enable = mkDefault true; - logseq.enable = mkDefault true; - nvim.enable = mkDefault true; - python.versions."311".enable = mkDefault true; - spotify.enable = mkDefault true; - ssh.enable = mkDefault true; - thunar.enable = mkDefault true; - wallpaper.enable = mkDefault true; - zathura.enable = mkDefault true; + environment.systemPackages = with pkgs; [ + anki + calibre + keepassxc + nixpkgs-review + pavucontrol + stable.libreoffice # HACK to fix build error + stable.signal-desktop + texlive.combined.scheme-full + thunderbird + vlc + ]; + + programs.nix-ld.enable = true; + + home-manager.users.moritz = { + services.nextcloud-client = { + enable = true; + startInBackground = true; + }; }; services = { - dunst.enable = mkDefault true; - gammastep.enable = true; - kdeconnect.enable = mkDefault true; - printing.enable = true; - wireguard.enable = true; - }; - }; - - environment.systemPackages = with pkgs; [ - anki - calibre - keepassxc - nixpkgs-review - pavucontrol - stable.libreoffice # HACK to fix build error - stable.signal-desktop - texlive.combined.scheme-full - thunderbird - vlc - ]; - - programs.nix-ld.enable = true; - - home-manager.users.moritz = { - services.nextcloud-client = { - enable = true; - startInBackground = true; - }; - }; - services = { - gnome.gnome-keyring.enable = true; - pipewire = { - enable = true; - alsa.enable = true; - pulse.enable = true; + gnome.gnome-keyring.enable = true; + pipewire = { + enable = true; + alsa.enable = true; + pulse.enable = true; + }; }; }; } diff --git a/modules/profiles/gaming.nix b/modules/profiles/gaming.nix index e773f20..bf493fd 100644 --- a/modules/profiles/gaming.nix +++ b/modules/profiles/gaming.nix @@ -1,11 +1,23 @@ -{ pkgs +{ lib +, config +, pkgs , ... -}: { - programs.steam.enable = true; - environment.systemPackages = with pkgs; [ - lutris - legendary-gl - heroic - mangohud - ]; +}: + +with lib; +let + cfg = config.my.profiles.gaming; +in +{ + options.my.profiles.gaming.enable = mkEnableOption "Enable gaming profile"; + + config = mkIf cfg.enable { + programs.steam.enable = true; + environment.systemPackages = with pkgs; [ + lutris + legendary-gl + heroic + mangohud + ]; + }; } diff --git a/modules/profiles/personal.nix b/modules/profiles/personal.nix index 2b227c3..37cca50 100644 --- a/modules/profiles/personal.nix +++ b/modules/profiles/personal.nix @@ -1,63 +1,74 @@ -{ lib, ... }: +{ lib +, config +, ... +}: with lib; +let + cfg = config.my.profiles.personal; +in { - my = { - services = { - openconnect.enable = true; - synology-drive.enable = true; - }; - programs = { - ssh.includeSecrets = mkDefault [ ../../secrets/ssh-home.age ]; - git.signing = mkDefault true; - hub.enable = mkDefault true; - firefox.arkenfox = { - enable = mkDefault true; - overrides = mkDefault { - ## arkenfox overrides - # automatic search - "keyword.enabled" = true; - "browser.search.suggest.enabled" = true; - "browser.urlbar.suggest.searches" = true; + options.my.profiles.personal.enable = mkEnableOption "personal profile"; - # startup page - "browser.startup.homepage" = "https://searxng.moritzboeh.me/"; - "browser.startup.page" = 1; + config = mkIf cfg.enable + { + my = { + services = { + openconnect.enable = true; + synology-drive.enable = true; + }; + programs = { + ssh.includeSecrets = mkDefault [ ../../secrets/ssh-home.age ]; + git.signing = mkDefault true; + hub.enable = mkDefault true; + firefox.arkenfox = { + enable = mkDefault true; + overrides = mkDefault { + ## arkenfox overrides + # automatic search + "keyword.enabled" = true; + "browser.search.suggest.enabled" = true; + "browser.urlbar.suggest.searches" = true; - # drm - "media.eme.enabled" = true; + # startup page + "browser.startup.homepage" = "https://searxng.moritzboeh.me/"; + "browser.startup.page" = 1; - # sanitisation - "privacy.clearOnShutdown.history" = false; + # drm + "media.eme.enabled" = true; - # disable letterboxing - "privacy.resistFingerprinting.letterboxing" = false; + # sanitisation + "privacy.clearOnShutdown.history" = false; - ## OTHER - # Dont show warning when accessing about:config - "browser.aboutConfig.showWarning" = false; + # disable letterboxing + "privacy.resistFingerprinting.letterboxing" = false; - # Hide bookmarks - "browser.toolbars.bookmarks.visibility" = "never"; + ## OTHER + # Dont show warning when accessing about:config + "browser.aboutConfig.showWarning" = false; - # Smooth scrolling - "general.smoothScroll.lines.durationMaxMS" = 125; - "general.smoothScroll.lines.durationMinMS" = 125; - "general.smoothScroll.mouseWheel.durationMaxMS" = 200; - "general.smoothScroll.mouseWheel.durationMinMS" = 100; - "general.smoothScroll.msdPhysics.enabled" = true; - "general.smoothScroll.other.durationMaxMS" = 125; - "general.smoothScroll.other.durationMinMS" = 125; - "general.smoothScroll.pages.durationMaxMS" = 125; - "general.smoothScroll.pages.durationMinMS" = 125; - "mousewheel.min_line_scroll_amount" = 40; - "mousewheel.system_scroll_override_on_root_content.enabled" = true; - "mousewheel.system_scroll_override_on_root_content.horizontal.factor" = 175; - "mousewheel.system_scroll_override_on_root_content.vertical.factor" = 175; - "toolkit.scrollbox.horizontalScrollDistance" = 6; - "toolkit.scrollbox.verticalScrollDistance" = 2; + # Hide bookmarks + "browser.toolbars.bookmarks.visibility" = "never"; + + # Smooth scrolling + "general.smoothScroll.lines.durationMaxMS" = 125; + "general.smoothScroll.lines.durationMinMS" = 125; + "general.smoothScroll.mouseWheel.durationMaxMS" = 200; + "general.smoothScroll.mouseWheel.durationMinMS" = 100; + "general.smoothScroll.msdPhysics.enabled" = true; + "general.smoothScroll.other.durationMaxMS" = 125; + "general.smoothScroll.other.durationMinMS" = 125; + "general.smoothScroll.pages.durationMaxMS" = 125; + "general.smoothScroll.pages.durationMinMS" = 125; + "mousewheel.min_line_scroll_amount" = 40; + "mousewheel.system_scroll_override_on_root_content.enabled" = true; + "mousewheel.system_scroll_override_on_root_content.horizontal.factor" = 175; + "mousewheel.system_scroll_override_on_root_content.vertical.factor" = 175; + "toolkit.scrollbox.horizontalScrollDistance" = 6; + "toolkit.scrollbox.verticalScrollDistance" = 2; + }; + }; }; }; }; - }; } diff --git a/modules/profiles/ripping.nix b/modules/profiles/ripping.nix index 61289f9..d01d1ac 100644 --- a/modules/profiles/ripping.nix +++ b/modules/profiles/ripping.nix @@ -1,10 +1,23 @@ -{ pkgs }: +{ lib +, config +, pkgs +, ... +}: + +with lib; +let + cfg = config.my.profiles.ripping; +in { - environment.systemPackages = with pkgs; [ - # ripping - abcde - handbrake - picard - ]; + options.my.profiles.ripping.enable = mkEnableOption "ripping profile"; + + config = mkIf cfg.enable { + environment.systemPackages = with pkgs; [ + # ripping + abcde + handbrake + picard + ]; + }; } diff --git a/modules/programs/default.nix b/modules/programs/default.nix deleted file mode 100644 index 1a044e4..0000000 --- a/modules/programs/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ lib, ... }: - -{ - imports = lib.my.listModules ./.; -} diff --git a/modules/programs/hyprland/config.nix b/modules/programs/hyprland/_config.nix similarity index 100% rename from modules/programs/hyprland/config.nix rename to modules/programs/hyprland/_config.nix diff --git a/modules/programs/hyprland/default.nix b/modules/programs/hyprland/default.nix index 654a13a..42f39c6 100644 --- a/modules/programs/hyprland/default.nix +++ b/modules/programs/hyprland/default.nix @@ -48,7 +48,7 @@ in enable = true; package = hyprland; recommendedEnvironment = true; - extraConfig = import ./config.nix args; + extraConfig = import ./_config.nix args; }; }; diff --git a/modules/programs/wallpaper/wallpaper.sh b/modules/programs/wallpaper/wallpaper.sh index 5b52710..2cc7e17 100644 --- a/modules/programs/wallpaper/wallpaper.sh +++ b/modules/programs/wallpaper/wallpaper.sh @@ -5,7 +5,7 @@ WALLPAPERS=$(find "$WALLPAPERS_PATH" -type f,l) function help() { echo "Usage:" - echo -e " wallpaper [OPTIONS] [PATH]" + echo -e " wallpaper [OPTIONS] [PATH]" echo "" echo "Options:" echo -e " -h, --help \n\t Show this help message and exit" @@ -60,12 +60,12 @@ done set -- "${POSITIONAL[@]}" # restore positional arguments if [[ $# -gt 1 ]]; then - help - exit 1 + help + exit 1 fi if [[ $# -eq 1 ]]; then - WALLPAPER="$1" + WALLPAPER="$1" fi if [[ -z ${WALLPAPER+x} ]]; then diff --git a/modules/services/default.nix b/modules/services/default.nix deleted file mode 100644 index 1a044e4..0000000 --- a/modules/services/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ lib, ... }: - -{ - imports = lib.my.listModules ./.; -} diff --git a/modules/virtualisation/default.nix b/modules/virtualisation/default.nix deleted file mode 100644 index 1a044e4..0000000 --- a/modules/virtualisation/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ lib, ... }: - -{ - imports = lib.my.listModules ./.; -}