From 03a24ae5e6eb8e270ca604f77ada2db95b753663 Mon Sep 17 00:00:00 2001 From: uttarayan21 Date: Thu, 4 Apr 2024 21:51:27 +0530 Subject: [PATCH] feat(nix): Move all the gui stuff behind a bool --- common/firefox.nix | 2 +- common/gui.nix | 33 +++++++++++++++++++++++++++++++++ common/home.nix | 24 ++++-------------------- common/kitty.nix | 8 ++++++-- common/wezterm.nix | 8 ++++++-- flake.nix | 7 +++++++ linux/anyrun.nix | 2 +- linux/default.nix | 10 ++++------ linux/foot.nix | 8 ++++++-- linux/gtk.nix | 4 ++-- linux/hyprland.nix | 3 ++- linux/ironbar/default.nix | 3 ++- linux/mpd.nix | 6 +----- 13 files changed, 75 insertions(+), 43 deletions(-) create mode 100644 common/gui.nix diff --git a/common/firefox.nix b/common/firefox.nix index 1acb324e..3ae9d8e0 100644 --- a/common/firefox.nix +++ b/common/firefox.nix @@ -4,7 +4,7 @@ ... }: { programs.firefox = { - enable = device.isLinux; + enable = device.hasGui; profiles.default = { userChrome = let # TODO: Move to subflake diff --git a/common/gui.nix b/common/gui.nix new file mode 100644 index 00000000..6907eda5 --- /dev/null +++ b/common/gui.nix @@ -0,0 +1,33 @@ +{ + pkgs, + device, + lib, + ... +}: +lib.attrsets.optionalAttrs device.hasGui { + home.packages = with pkgs; + [] + ++ lib.optionals device.isLinux [ + ferdium + psst + sony-headphones-client + abaddon + catppuccinThemes.gtk + catppuccinThemes.papirus-folders + + gnome.seahorse + gnome.nautilus + nextcloud-client + gparted + polkit_gnome + + mullvad-vpn + mullvad-closest + mullvad-browser + steam-run + + webcord-vencord + spotify + wl-clipboard + ]; +} diff --git a/common/home.nix b/common/home.nix index 758f3833..83b9d7c6 100644 --- a/common/home.nix +++ b/common/home.nix @@ -35,13 +35,15 @@ in { imports = [ inputs.nix-index-database.hmModules.nix-index - ./tmux.nix ./wezterm.nix + ./kitty.nix + ./gui.nix + + ./tmux.nix ./nvim.nix ./goread.nix ./ncmpcpp.nix ./zellij.nix - ./kitty.nix ../modules ] ++ lib.optionals device.isLinux [../linux]; @@ -95,32 +97,14 @@ in { (pkgs.mpv-unwrapped.override {sixelSupport = true;}) {}) ] ++ lib.optionals device.isLinux [ - ferdium - psst - sony-headphones-client - abaddon rr - catppuccinThemes.gtk - catppuccinThemes.papirus-folders - gnome.seahorse - gnome.nautilus - nextcloud-client sbctl - gparted gptfdisk - polkit_gnome dig - mullvad-vpn - mullvad-closest - mullvad-browser - steam-run usbutils handlr-regex handlr-xdg - webcord-vencord - spotify lsof - wl-clipboard ncpamixer ] ++ lib.optionals device.isMac []; diff --git a/common/kitty.nix b/common/kitty.nix index 37d198aa..fe886d1e 100644 --- a/common/kitty.nix +++ b/common/kitty.nix @@ -1,6 +1,10 @@ -{pkgs, ...}: { +{ + pkgs, + device, + ... +}: { programs.kitty = { - enable = true; + enable = device.hasGui; font = { name = "Hasklug Nerd Font Mono"; size = 13; diff --git a/common/wezterm.nix b/common/wezterm.nix index 9ef0f7be..cd75209a 100644 --- a/common/wezterm.nix +++ b/common/wezterm.nix @@ -1,6 +1,10 @@ -{pkgs, ...}: { +{ + pkgs, + device, + ... +}: { programs.wezterm = { - enable = true; + enable = device.hasGui; extraConfig = /* lua diff --git a/flake.nix b/flake.nix index 580d8a23..528f3a25 100644 --- a/flake.nix +++ b/flake.nix @@ -102,6 +102,7 @@ name = "genzai"; system = "x86_64-linux"; user = "fs0c131y"; + hasGui = false; # Don't wan't to run GUI apps on a headless server } { name = "Uttarayans-MacBook-Pro"; @@ -112,11 +113,13 @@ name = "Serviuss-iMac-Pro"; system = "x86_64-darwin"; user = "servius"; + hasGui = false; # It's a vm so no GUI apps are used } { name = "SteamDeck"; system = "x86_64-linux"; user = "deck"; + hasGui = false; # Don't wan't to run GUI apps on the SteamDeck } ]; @@ -127,6 +130,10 @@ then device.isNix else false; isMac = !isNull (builtins.match ".*-darwin" device.system); + hasGui = + if (builtins.hasAttr "hasGui" device) + then device.hasGui + else true; system = device.system; name = device.name; user = device.user; diff --git a/linux/anyrun.nix b/linux/anyrun.nix index 830114e2..b1175fe4 100644 --- a/linux/anyrun.nix +++ b/linux/anyrun.nix @@ -7,7 +7,7 @@ }: { imports = [inputs.anyrun.nixosModules.home-manager]; programs.anyrun = { - enable = true; + enable = device.hasGui; config = { plugins = with inputs.anyrun.packages.${pkgs.system}; [ inputs.anyrun-nixos-options.packages.${pkgs.system}.default diff --git a/linux/default.nix b/linux/default.nix index cc57b344..fed2cc8d 100644 --- a/linux/default.nix +++ b/linux/default.nix @@ -1,8 +1,6 @@ { pkgs, device, - nur, - inputs, ... }: { imports = [ @@ -15,11 +13,11 @@ ../linux/mpd.nix ]; - services.kdeconnect.enable = true; - services.kdeconnect.indicator = true; - services.swayosd.enable = true; + services.kdeconnect.enable = device.hasGui; + services.kdeconnect.indicator = device.hasGui; + services.swayosd.enable = device.hasGui; services.nextcloud-client = { - enable = true; + enable = device.hasGui; startInBackground = true; }; diff --git a/linux/foot.nix b/linux/foot.nix index a65d70b6..9710534a 100644 --- a/linux/foot.nix +++ b/linux/foot.nix @@ -1,6 +1,10 @@ -{pkgs, ...}: { +{ + pkgs, + device, + ... +}: { programs.foot = { - enable = pkgs.stdenv.isLinux; + enable = device.hasGui; server.enable = true; settings = { main = { diff --git a/linux/gtk.nix b/linux/gtk.nix index 347568e9..5a88832a 100644 --- a/linux/gtk.nix +++ b/linux/gtk.nix @@ -1,6 +1,6 @@ -{pkgs, ...}: { +{pkgs, device, ...}: { gtk = { - enable = true; + enable = device.hasGui; theme = { name = "Catppuccin-Mocha-Standard-Mauve-Dark"; package = pkgs.catppuccin-gtk.override { diff --git a/linux/hyprland.nix b/linux/hyprland.nix index 105505bc..fa8a2348 100644 --- a/linux/hyprland.nix +++ b/linux/hyprland.nix @@ -1,6 +1,7 @@ { pkgs, inputs, + device, ... }: { imports = [../modules/hyprpaper.nix inputs.hyprlock.homeManagerModules.hyprlock]; @@ -8,7 +9,7 @@ programs.hyprpaper = let wallpapers = import ../utils/wallhaven.nix {inherit pkgs;}; in { - enable = true; + enable = device.hasGui; systemd.enable = true; systemd.target = "hyprland-session.target"; settings.preload = wallpapers.all; diff --git a/linux/ironbar/default.nix b/linux/ironbar/default.nix index f2e6db97..42998c3d 100644 --- a/linux/ironbar/default.nix +++ b/linux/ironbar/default.nix @@ -1,11 +1,12 @@ { inputs, pkgs, + device, ... }: { imports = [inputs.ironbar.homeManagerModules.default]; programs.ironbar = { - enable = true; + enable = device.hasGui; config.monitors = { DP-1 = { position = "bottom"; diff --git a/linux/mpd.nix b/linux/mpd.nix index 89dd2c12..382f2c2d 100644 --- a/linux/mpd.nix +++ b/linux/mpd.nix @@ -1,8 +1,4 @@ -{ - # pkgs, - # config, - ... -}: { +{...}: { services.mpd = { enable = true; };