From 47278f895a6cb560e5ec72962b619c1a3fbc6308 Mon Sep 17 00:00:00 2001 From: Sean Buckley Date: Mon, 29 Mar 2021 21:16:19 -0400 Subject: [PATCH] move desktop environments into modules --- default.nix | 3 +++ modules/gnome.nix | 39 ++++++++++++++-------------- modules/plasma.nix | 19 +++++++++----- modules/profiles.nix | 10 ++----- modules/sway.nix | 62 +++++++++++++++++++++++--------------------- 5 files changed, 71 insertions(+), 62 deletions(-) diff --git a/default.nix b/default.nix index 85bdaef..3db8943 100644 --- a/default.nix +++ b/default.nix @@ -7,11 +7,14 @@ ./modules/cli.nix ./modules/fix-gnome-mouse-lag.nix ./modules/flakes.nix + ./modules/gnome.nix ./modules/phpipam.nix + ./modules/plasma.nix ./modules/profiles.nix ./modules/scansnap_s1300.nix ./modules/scroll-boost ./modules/security-tools.nix ./modules/status-on-console.nix + ./modules/sway.nix ]; } diff --git a/modules/gnome.nix b/modules/gnome.nix index 894df1d..82725cd 100644 --- a/modules/gnome.nix +++ b/modules/gnome.nix @@ -1,9 +1,24 @@ -{ pkgs, ... }: +{ config, pkgs, lib, ... }: +let + cfg = config.sconfig.gnome; +in { - environment = { - systemPackages = with pkgs; [ - numix-icon-theme + options.sconfig.gnome = lib.mkEnableOption "Enable Gnome Desktop"; + + config = lib.mkIf cfg { + + services.xserver = { + enable = true; + libinput.enable = true; + displayManager.gdm.enable = true; + displayManager.gdm.autoSuspend = false; + desktopManager.gnome3.enable = true; + }; + + environment.systemPackages = with pkgs; [ gnome3.gnome-tweaks + gnomeExtensions.appindicator + numix-icon-theme qemu_kvm (writeShellScriptBin "red" '' @@ -39,21 +54,7 @@ gsettings set org.gnome.desktop.interface icon-theme 'Numix'; sleep 1 gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita-dark' '') + ]; - ] ++ (with pkgs.gnomeExtensions; [ - appindicator - dash-to-panel - drop-down-terminal - sound-output-device-chooser - no-title-bar - ]); - }; - - services.xserver = { - enable = true; - libinput.enable = true; - displayManager.gdm.enable = true; - displayManager.gdm.autoSuspend = false; - desktopManager.gnome3.enable = true; }; } diff --git a/modules/plasma.nix b/modules/plasma.nix index 068c3fb..2674aa9 100644 --- a/modules/plasma.nix +++ b/modules/plasma.nix @@ -1,9 +1,16 @@ -{ ... }: +{ config, pkgs, lib, ... }: +let + cfg = config.sconfig.plasma; +in { - services.xserver = { - enable = true; - libinput.enable = true; - displayManager.sddm.enable = true; - desktopManager.plasma5.enable = true; + options.sconfig.plasma = lib.mkEnableOption "Enable Plasma Desktop"; + + config = lib.mkIf cfg { + services.xserver = { + enable = true; + libinput.enable = true; + displayManager.sddm.enable = true; + desktopManager.plasma5.enable = true; + }; }; } diff --git a/modules/profiles.nix b/modules/profiles.nix index 7c97ea2..60f9fb9 100644 --- a/modules/profiles.nix +++ b/modules/profiles.nix @@ -5,7 +5,7 @@ let in { options.sconfig.profile = mkOption { - type = types.enum [ "server" "desktop-gnome" "desktop-sway" "desktop-plasma" ]; + type = types.enum [ "server" "desktop" ]; }; config = mkMerge [ @@ -22,13 +22,7 @@ in }; }) - (mkIf (cfg == "desktop-sway") (import ./sway.nix { inherit pkgs; })) - (mkIf (cfg == "desktop-gnome") (import ./gnome.nix { inherit pkgs; })) - (mkIf (cfg == "desktop-plasma") (import ./plasma.nix { inherit pkgs; })) - - (mkIf ("desktop-" == builtins.substring 0 8 cfg) (mkMerge [ - (import ./graphical.nix { inherit pkgs; }) - ])) + (mkIf (cfg == "desktop") (import ./graphical.nix { inherit pkgs; })) ]; } diff --git a/modules/sway.nix b/modules/sway.nix index 785634f..5d32f1c 100644 --- a/modules/sway.nix +++ b/modules/sway.nix @@ -1,35 +1,39 @@ -{ pkgs, ... }: +{ config, pkgs, lib, ... }: +let + cfg = config.sconfig.sway; +in { - programs.sway.enable = true; + options.sconfig.sway = lib.mkEnableOption "Enable Sway Window Manager"; + config = lib.mkIf cfg { + programs.sway.enable = true; + programs.bash.interactiveShellInit = '' [ "$(tty)" = "/dev/tty1" ] && exec sway ''; - environment.variables.GTK_THEME = "Yaru-dark"; - environment.variables.MOZ_ENABLE_WAYLAND = "1"; + environment.variables.GTK_THEME = "Yaru-dark"; + environment.variables.MOZ_ENABLE_WAYLAND = "1"; + environment.etc."xdg/gtk-3.0/settings.ini".text = '' + [Settings] + gtk-theme-name=Yaru-dark + gtk-icon-theme-name=Numix + ''; - environment.etc."xdg/gtk-3.0/settings.ini".text = '' - [Settings] - gtk-theme-name=Yaru-dark - gtk-icon-theme-name=Numix - ''; + services.gvfs.enable = true; + programs.dconf.enable = true; + networking.networkmanager.enable = true; - services.gvfs.enable = true; - programs.dconf.enable = true; - networking.networkmanager.enable = true; - - environment.systemPackages = with pkgs; [ - numix-icon-theme - yaru-theme - gnome3.networkmanagerapplet - gnome3.file-roller - gnome3.adwaita-icon-theme - mate.mate-terminal - xfce.thunar - i3status - xfce.thunar-archive-plugin - caffeine-ng - wf-recorder - xdg_utils - ]; - - programs.bash.interactiveShellInit = '' [ "$(tty)" = "/dev/tty1" ] && exec sway ''; + environment.systemPackages = with pkgs; [ + numix-icon-theme + yaru-theme + gnome3.networkmanagerapplet + gnome3.file-roller + gnome3.adwaita-icon-theme + mate.mate-terminal + xfce.thunar + i3status + xfce.thunar-archive-plugin + caffeine-ng + wf-recorder + xdg_utils + ]; + }; }