about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-02-08 19:56:06 -0800
committerFranck Cuny <franck@fcuny.net>2022-02-08 19:56:06 -0800
commit343e89015a55b627400286a06937175facb1494d (patch)
treec0a466ec7b5e12120435bafced4c73df386c1ea5
parenti3: remove extra packages and fix typo (diff)
downloadworld-343e89015a55b627400286a06937175facb1494d.tar.gz
desktop: new option to control desktop setup
We don't want to install a desktop on all hosts. We add a new option
that we can set to true or false if we want a desktop to be installed.
-rw-r--r--modules/desktop/default.nix10
-rw-r--r--modules/desktop/fonts.nix33
2 files changed, 30 insertions, 13 deletions
diff --git a/modules/desktop/default.nix b/modules/desktop/default.nix
index f150066..3ee9fb5 100644
--- a/modules/desktop/default.nix
+++ b/modules/desktop/default.nix
@@ -1,5 +1,15 @@
 {lib, config, pkgs, ...}:
+with lib;
+
 {
+  options.sys.graphics = {
+    desktopProtocols = mkOption {
+      type = with types; listOf (enum ["xorg" "wayland"]);
+      default = [];
+      description = "Desktop protocols you want to use for your desktop environment. If unset, no desktop is installed (headless host).";
+    };
+  };
+
   imports = [
     ./fonts.nix
     ./sound.nix
diff --git a/modules/desktop/fonts.nix b/modules/desktop/fonts.nix
index a840582..367e42e 100644
--- a/modules/desktop/fonts.nix
+++ b/modules/desktop/fonts.nix
@@ -1,18 +1,25 @@
-{ pkgs, config, lib, ... }:
+{pkgs, config, lib, ... }:
+with lib;
 
-{
-  fonts = {
-    fontconfig.enable = true;
-    fonts = with pkgs; [
-      noto-fonts-emoji
-      dejavu_fonts
-      source-code-pro
-      source-sans-pro
-      source-serif-pro
-    ];
+let
+  xorg = (elem "xorg" config.sys.graphics.desktopProtocols);
+  wayland = (elem "wayland" config.sys.graphics.desktopProtocols);
+  desktopMode = xorg || wayland;
+in {
+  config= mkIf desktopMode {
+    fonts = {
+      fontconfig.enable = true;
+      fonts = with pkgs; [
+        noto-fonts-emoji
+        dejavu_fonts
+        source-code-pro
+        source-sans-pro
+        source-serif-pro
+      ];
 
-    fontconfig.defaultFonts = {
-      monospace = [ "Source Code Pro" ];
+      fontconfig.defaultFonts = {
+        monospace = [ "Source Code Pro" ];
+      };
     };
   };
 }