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"; system.stateVersion = "21.11";
riley = { # Custom modules defined by myself.
gui = false; custom = {
gui.enable = false;
kak = { kak = {
enable = true; enable = true;
nix = true; ide.nix = true;
}; };
net.interfaces = [
"eth0"
];
}; };
users.users."riley" = { users.users."riley" = {
isNormalUser = true; isNormalUser = true;
extraGroups = [ "wheel" ]; extraGroups = [ "wheel" ];

View file

@ -7,8 +7,11 @@
../../modules ../../modules
]; ];
riley = { custom = {
gui = true; gui = {
enable = true;
theme = (import ../../colors.nix).dark;
};
kak = { kak = {
enable = true; 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; inherit pkgs;
}); });
in (lib.mkIf (config.riley.gui) { in lib.mkIf (gui.enable) {
# Add some shell scripts that abstract away the # Add some shell scripts that abstract away the
# horrible reality that the clipboard is managed by # horrible reality that the clipboard is managed by
# the display server. # the display server.
users.users."riley".packages = users.users."riley".packages = with scripts; [ c p ];
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; { with lib; {
@ -7,21 +16,33 @@ with lib; {
./wm ./wm
./pulseaudio.nix ./pulseaudio.nix
./clipboard.nix
./statusbar.nix ./statusbar.nix
./terminal.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 google-chrome
# Telegram client
tdesktop 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; sound.enable = true;
hardware.pulseaudio.enable = true; hardware.pulseaudio.enable = true;
users.users."riley".packages = with pkgs; [ users.users."riley".packages = with pkgs; [
pavucontrol pavucontrol
]; ];
})
};
}

View file

@ -1,6 +1,6 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
(lib.mkIf (config.riley.gui && false) { (lib.mkIf (config.custom.gui.enable && false) {
home-manager.users."riley" = { home-manager.users."riley" = {
services.polybar = { services.polybar = {
enable = true; enable = true;

View file

@ -1,10 +1,15 @@
# Module that adds my terminal emulator of choice to my environment.
{ pkgs, lib, config, ... }: { pkgs, lib, config, ... }:
with lib; (mkIf config.riley.gui { let gui = config.custom.gui; in
home-manager.users."riley" = {
# Kitty lets me use cool ligatures with lib; mkIf (gui.enable) {
programs.kitty = {
home-manager.users."riley".programs.kitty = {
# Use kitty because it supports cool ligatures and
# has nice scripting capabilities.
enable = true; enable = true;
font = { font = {
@ -12,7 +17,7 @@ with lib; (mkIf config.riley.gui {
size = 11; size = 11;
}; };
settings = with config.riley.theme.hex; { settings = with gui.theme.hex; {
bold_font = "Fira Code Medium"; 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 in
with lib; (mkIf config.riley.gui { with lib; (mkIf config.custom.gui.enable {
services.xserver = { services.xserver = {
enable = true; enable = true;

View file

@ -2,8 +2,8 @@
with pkgs.kakouneUtils; with pkgs.kakouneUtils;
let cfg = config.riley.kak; let cfg = config.custom.kak;
theme = config.riley.theme; theme = config.custom.gui.theme;
kak-crosshairs = buildKakounePlugin (rec { kak-crosshairs = buildKakounePlugin (rec {
name = "kak-crosshairs"; name = "kak-crosshairs";
src = (pkgs.fetchFromGitHub { src = (pkgs.fetchFromGitHub {
@ -17,7 +17,7 @@ in
with lib; { with lib; {
options.riley.kak = { options.custom.kak = {
enable = (mkEnableOption "kakoune editor") // { default = true; }; enable = (mkEnableOption "kakoune editor") // { default = true; };