From d7e64ff1d67fede4f207a27ca7d92347a934a0ff Mon Sep 17 00:00:00 2001 From: Riley Apeldoorn Date: Mon, 25 Jul 2022 13:31:09 +0200 Subject: [PATCH] Replace `riley` namespace with `custom` namespace --- machines/sif/configuration.nix | 17 +++++++-- machines/thor/configuration.nix | 51 +++++++++++++------------ modules/gui/clipboard.nix | 19 ++++++---- modules/gui/default.nix | 37 ++++++++++++++---- modules/gui/pulseaudio.nix | 27 ++++++++++---- modules/gui/statusbar.nix | 2 +- modules/gui/terminal.nix | 66 +++++++++++++++++---------------- modules/gui/theme.nix | 58 +++++++++++++++++++++++++++++ modules/gui/wm/default.nix | 2 +- modules/kak/default.nix | 6 +-- 10 files changed, 197 insertions(+), 88 deletions(-) create mode 100644 modules/gui/theme.nix diff --git a/machines/sif/configuration.nix b/machines/sif/configuration.nix index 55d8211..08e720f 100644 --- a/machines/sif/configuration.nix +++ b/machines/sif/configuration.nix @@ -34,14 +34,23 @@ system.stateVersion = "21.11"; - riley = { - gui = false; + # Custom modules defined by myself. + custom = { + + gui.enable = false; + kak = { - enable = true; - nix = true; + enable = true; + ide.nix = true; }; + + net.interfaces = [ + "eth0" + ]; + }; + users.users."riley" = { isNormalUser = true; extraGroups = [ "wheel" ]; diff --git a/machines/thor/configuration.nix b/machines/thor/configuration.nix index 587e7fa..16f3745 100644 --- a/machines/thor/configuration.nix +++ b/machines/thor/configuration.nix @@ -1,31 +1,34 @@ { config, lib, pkgs, agenix, ... }: { - imports = [ - agenix.nixosModule - ./hardware-configuration.nix - ../../modules - ]; + imports = [ + agenix.nixosModule + ./hardware-configuration.nix + ../../modules + ]; - riley = { - gui = true; - kak = { + custom = { + gui = { + enable = true; + theme = (import ../../colors.nix).dark; + }; + kak = { - enable = true; + enable = true; - haskell = true; - rust = true; - nix = true; + haskell = true; + rust = true; + nix = true; - }; - }; + }; + }; - system.stateVersion = "21.11"; + system.stateVersion = "21.11"; - networking = { - hostName = "thor"; - interfaces.enp9s0.useDHCP = true; - }; + networking = { + hostName = "thor"; + interfaces.enp9s0.useDHCP = true; + }; boot = { loader.systemd-boot = { @@ -39,10 +42,10 @@ }; }; - users.users."riley".packages = with pkgs; [ - minecraft - cockatrice - ]; + users.users."riley".packages = with pkgs; [ + minecraft + cockatrice + ]; programs.steam = { enable = true; @@ -68,7 +71,7 @@ external = "alsa_output.pci-0000_0a_00.1.hdmi-stereo"; headset = null; # Thor doesn't have bluetooth support (yet) - # Inputs + # Inputs main-mic = "alsa_input.usb-046d_C922_Pro_Stream_Webcam_CC9E75BF-02.analog-stereo"; }; diff --git a/modules/gui/clipboard.nix b/modules/gui/clipboard.nix index 43d023d..76c0803 100644 --- a/modules/gui/clipboard.nix +++ b/modules/gui/clipboard.nix @@ -1,17 +1,20 @@ -{ config, lib, pkgs, ... }: +# This is a simple module that does not define its own options. +# Rather, it just looks at the `custom.gui.enable` option to +# determine if it needs to add anything. -let scripts = (import ../../scripts/clip.nix { +{ pkgs, lib, config, ... }: + +let gui = config.custom.gui; + + scripts = (import ../../scripts/clip.nix { inherit pkgs; }); -in (lib.mkIf (config.riley.gui) { +in lib.mkIf (gui.enable) { # Add some shell scripts that abstract away the # horrible reality that the clipboard is managed by # the display server. - users.users."riley".packages = - with scripts; [ - c p - ]; + users.users."riley".packages = with scripts; [ c p ]; -}) +} diff --git a/modules/gui/default.nix b/modules/gui/default.nix index 0eef214..862cbfc 100644 --- a/modules/gui/default.nix +++ b/modules/gui/default.nix @@ -1,4 +1,13 @@ -{ pkgs, config, lib, ... }: +{ pkgs, lib, config, ... }: + +let gui = config.custom.gui; + + # Clipboard wrapper scripts + clip = (import ../../scripts/clip.nix { + inherit pkgs; + }); + +in with lib; { @@ -7,21 +16,33 @@ with lib; { ./wm ./pulseaudio.nix - ./clipboard.nix ./statusbar.nix ./terminal.nix + ./theme.nix + ]; - options.riley.gui = mkEnableOption "gui applications and window manager"; - - config = mkIf config.riley.gui { + options.custom.gui = { - # Graphical applications - users.users."riley".packages = with pkgs; [ + # Use a nested enable option, to allow extension of this option + # namespace later on. + enable = mkEnableOption "gui applications and window manager"; + + }; + + config = mkIf (gui.enable) { + + # Import some applications I use on all my graphical systems + users.users."riley".packages = (with pkgs; [ + + # My browser google-chrome + + # Telegram client tdesktop - ]; + + ]) ++ (with clip; [ c p ]); # Add clipboard scripts }; } diff --git a/modules/gui/pulseaudio.nix b/modules/gui/pulseaudio.nix index 93261d8..104fcbd 100644 --- a/modules/gui/pulseaudio.nix +++ b/modules/gui/pulseaudio.nix @@ -1,10 +1,21 @@ -{ lib, config, pkgs, ... }: +{ pkgs, lib, config, ... }: -(lib.mkIf (config.riley.gui) { - sound.enable = true; - hardware.pulseaudio.enable = true; +let gui = config.custom.gui; in - users.users."riley".packages = with pkgs; [ - pavucontrol - ]; -}) +with lib; { + + # Define pulseaudio toggle under the `audio` option set. + options.custom.gui.audio.pulseaudio = mkEnableOption "PulseAudio sound server"; + + config = mkIf (gui.audio.pulseaudio) { + + sound.enable = true; + hardware.pulseaudio.enable = true; + + users.users."riley".packages = with pkgs; [ + pavucontrol + ]; + + }; + +} diff --git a/modules/gui/statusbar.nix b/modules/gui/statusbar.nix index 6a77903..6a13deb 100644 --- a/modules/gui/statusbar.nix +++ b/modules/gui/statusbar.nix @@ -1,6 +1,6 @@ { pkgs, config, lib, ... }: -(lib.mkIf (config.riley.gui && false) { +(lib.mkIf (config.custom.gui.enable && false) { home-manager.users."riley" = { services.polybar = { enable = true; diff --git a/modules/gui/terminal.nix b/modules/gui/terminal.nix index 327342d..b9fcaf6 100644 --- a/modules/gui/terminal.nix +++ b/modules/gui/terminal.nix @@ -1,44 +1,48 @@ +# Module that adds my terminal emulator of choice to my environment. + { pkgs, lib, config, ... }: -with lib; (mkIf config.riley.gui { - home-manager.users."riley" = { +let gui = config.custom.gui; in - # Kitty lets me use cool ligatures - programs.kitty = { - enable = true; +with lib; mkIf (gui.enable) { + + home-manager.users."riley".programs.kitty = { - font = { - name = "Fira Code"; - size = 11; - }; + # Use kitty because it supports cool ligatures and + # has nice scripting capabilities. + enable = true; + + font = { + name = "Fira Code"; + size = 11; + }; + + settings = with gui.theme.hex; { + + bold_font = "Fira Code Medium"; - settings = with config.riley.theme.hex; { + background = background.primary; + foreground = foreground.primary; - bold_font = "Fira Code Medium"; - - background = background.primary; - foreground = foreground.primary; + color1 = red.normal; + color9 = red.bright; - color1 = red.normal; - color9 = red.bright; + color2 = green.normal; + color10 = green.bright; - color2 = green.normal; - color10 = green.bright; + color3 = yellow.normal; + color11 = yellow.bright; - color3 = yellow.normal; - color11 = yellow.bright; + color4 = blue.normal; + color12 = blue.bright; - color4 = blue.normal; - color12 = blue.bright; + color5 = purple.normal; + color13 = purple.bright; - color5 = purple.normal; - color13 = purple.bright; + color6 = cyan.normal; + color14 = cyan.bright; - color6 = cyan.normal; - color14 = cyan.bright; - - }; - }; - + }; }; -}) + +} diff --git a/modules/gui/theme.nix b/modules/gui/theme.nix new file mode 100644 index 0000000..f269edd --- /dev/null +++ b/modules/gui/theme.nix @@ -0,0 +1,58 @@ +# Defines the global color theme option. + +{ lib, ... }: + +with lib; with types; + +# Define the type in a let binding to prevent too much rightward +# drift in the option configuration. +let themeType = + + let # Named colors are colors like "red" or "black". + named = submodule { + options = { + normal = mkOption { type = str; }; + bright = mkOption { type = str; }; + pastel = mkOption { type = str; }; + }; + }; + + # Special colors are more abstract, for example + # "foreground". + special = submodule { + options = { + primary = mkOption { type = str; }; + normal = mkOption { type = str; }; + slight = mkOption { type = str; }; + }; + }; + + in submodule { + options = { + foreground = mkOption { type = special; }; + background = mkOption { type = special; }; + grayscales = mkOption { type = listOf str; }; + red = mkOption { type = named; }; + green = mkOption { type = named; }; + blue = mkOption { type = named; }; + yellow = mkOption { type = named; }; + purple = mkOption { type = named; }; + cyan = mkOption { type = named; }; + pink = mkOption { type = named; }; + orange = mkOption { type = named; }; + misc = mkOption { type = attrsOf str; }; + hex = mkOption { type = themeType; }; + }; + }; + +in { + + options.custom.gui.theme = mkOption { + type = themeType; + description = '' + Color theme used across the installation for various + GUI elements and terminal colors. + ''; + }; + +} diff --git a/modules/gui/wm/default.nix b/modules/gui/wm/default.nix index 4752aa2..5eb1d3c 100644 --- a/modules/gui/wm/default.nix +++ b/modules/gui/wm/default.nix @@ -32,7 +32,7 @@ let scripts = (import ./scripts.nix { inherit pkgs; }); }); in -with lib; (mkIf config.riley.gui { +with lib; (mkIf config.custom.gui.enable { services.xserver = { enable = true; diff --git a/modules/kak/default.nix b/modules/kak/default.nix index 70e193c..adb971e 100644 --- a/modules/kak/default.nix +++ b/modules/kak/default.nix @@ -2,8 +2,8 @@ with pkgs.kakouneUtils; -let cfg = config.riley.kak; - theme = config.riley.theme; +let cfg = config.custom.kak; + theme = config.custom.gui.theme; kak-crosshairs = buildKakounePlugin (rec { name = "kak-crosshairs"; src = (pkgs.fetchFromGitHub { @@ -17,7 +17,7 @@ in with lib; { - options.riley.kak = { + options.custom.kak = { enable = (mkEnableOption "kakoune editor") // { default = true; };