Replace `riley` namespace with `custom` namespace

This commit is contained in:
Riley Apeldoorn 2022-07-25 13:31:09 +02:00
parent 071577b83d
commit d7e64ff1d6
10 changed files with 197 additions and 88 deletions

View File

@ -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;
ide.nix = true;
};
net.interfaces = [
"eth0"
];
};
users.users."riley" = {
isNormalUser = true;
extraGroups = [ "wheel" ];

View File

@ -7,8 +7,11 @@
../../modules
];
riley = {
gui = true;
custom = {
gui = {
enable = true;
theme = (import ../../colors.nix).dark;
};
kak = {
enable = true;

View File

@ -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 ];
})
}

View File

@ -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";
options.custom.gui = {
config = mkIf config.riley.gui {
# Use a nested enable option, to allow extension of this option
# namespace later on.
enable = mkEnableOption "gui applications and window manager";
# Graphical applications
users.users."riley".packages = with pkgs; [
};
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
};
}

View File

@ -1,10 +1,21 @@
{ lib, config, pkgs, ... }:
{ pkgs, lib, config, ... }:
let gui = config.custom.gui; in
with lib; {
# Define pulseaudio toggle under the `audio` option set.
options.custom.gui.audio.pulseaudio = mkEnableOption "PulseAudio sound server";
config = mkIf (gui.audio.pulseaudio) {
(lib.mkIf (config.riley.gui) {
sound.enable = true;
hardware.pulseaudio.enable = true;
users.users."riley".packages = with pkgs; [
pavucontrol
];
})
};
}

View File

@ -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;

View File

@ -1,10 +1,15 @@
# 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 = {
with lib; mkIf (gui.enable) {
home-manager.users."riley".programs.kitty = {
# Use kitty because it supports cool ligatures and
# has nice scripting capabilities.
enable = true;
font = {
@ -12,7 +17,7 @@ with lib; (mkIf config.riley.gui {
size = 11;
};
settings = with config.riley.theme.hex; {
settings = with gui.theme.hex; {
bold_font = "Fira Code Medium";
@ -40,5 +45,4 @@ with lib; (mkIf config.riley.gui {
};
};
};
})
}

58
modules/gui/theme.nix Normal file
View File

@ -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.
'';
};
}

View File

@ -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;

View File

@ -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; };