aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaroline Larimore <caroline@larimo.re>2025-02-04 18:50:11 -0800
committerCaroline Larimore <caroline@larimo.re>2025-04-14 18:58:44 -0700
commit10f11ec042ab468821274636d438f84781cb2408 (patch)
treedde2244d5e9d76f7191e095a621bf23f9adcd9ab
parente45aca9d0cbda0559fb3c6a8075e029faa9c58ac (diff)
migration: desktop role
-rw-r--r--roles/desktop/default.nix78
-rw-r--r--roles/desktop/input.nix37
-rw-r--r--roles/desktop/xserver.nix18
-rw-r--r--snowfall/modules/nixos/apps/i3/default.nix50
-rw-r--r--snowfall/modules/nixos/apps/playerctl/default.nix18
-rw-r--r--snowfall/modules/nixos/fonts/default.nix38
-rw-r--r--snowfall/modules/nixos/hardware/audio/default.nix25
-rw-r--r--snowfall/modules/nixos/hardware/keyboard/default.nix43
-rw-r--r--snowfall/modules/nixos/suites/common/default.nix4
-rw-r--r--snowfall/modules/nixos/suites/desktop/default.nix25
-rw-r--r--snowfall/systems/x86_64-linux/c-pc/default.nix7
11 files changed, 209 insertions, 134 deletions
diff --git a/roles/desktop/default.nix b/roles/desktop/default.nix
deleted file mode 100644
index 7acd1d8..0000000
--- a/roles/desktop/default.nix
+++ /dev/null
@@ -1,78 +0,0 @@
-{ config, pkgs, lib, ... }:
-with lib;
-
-let cfg = config.roles.desktop; in {
- imports = [
- ./input.nix
- ./xserver.nix
- ];
-
- options.roles.desktop = {
- enable = mkEnableOption "desktop";
-
- videoDrivers = mkOption {
- type = types.listOf types.str;
- default = [ "modesetting" "fbdev" ];
- };
-
- setupCommands = mkOption {
- type = types.lines;
- default = "";
- description = ''
- Shell commands executed just after the X server has started.
- '';
- };
- };
-
- config = mkIf cfg.enable {
- environment.systemPackages = with pkgs; [
- pulseaudio
- playerctl
- ];
-
- security.rtkit.enable = true;
-
- i18n.inputMethod.enable = true;
-
- services = {
- displayManager.enable = true;
-
- xserver = {
- enable = true;
- displayManager.lightdm.enable = true;
- windowManager.i3.enable = true;
- };
-
- libinput.enable = true;
- keyd.enable = true;
-
- pipewire = {
- enable = true;
-
- pulse.enable = true;
- alsa.enable = true;
- alsa.support32Bit = true;
- #jack.enable = true;
- };
- };
-
- fonts = {
- packages = with pkgs; [
- noto-fonts
- noto-fonts-cjk-sans
- noto-fonts-cjk-serif
- noto-fonts-emoji
-
- minecraftia
- ] ++ builtins.filter lib.attrsets.isDerivation (builtins.attrValues pkgs.nerd-fonts);
-
- fontconfig = {
- defaultFonts = {
- monospace = [ "CaskaydiaMono Nerd Font" ];
- sansSerif = [ "DejaVu Sans" "Noto Sans CJK JP" "Noto Sans" ];
- serif = [ "DejaVu Serif" "Noto Serif CJK JP" "Noto Serif" ];
- };
- };
- };
- };
-}
diff --git a/roles/desktop/input.nix b/roles/desktop/input.nix
deleted file mode 100644
index c0a722f..0000000
--- a/roles/desktop/input.nix
+++ /dev/null
@@ -1,37 +0,0 @@
-{ pkgs, ... }:
-
-{
- services = {
- libinput = {
- touchpad.naturalScrolling = true;
- };
-
- keyd = {
- keyboards."*".settings = {
- main = {
- # Swap alt and meta keys.
- # I prefer (physical) alt as my WM modifier key because it
- # is easier to reach. This can collide with some programs
- # shortcuts if they inlcude alt. Swapping alt and meta fixes
- # this by making my WM mod key (software) meta, freeing up alt.
-
- leftalt = "leftmeta";
- leftmeta = "leftalt";
-
- rightalt = "rightmeta";
- rightmeta = "rightalt";
- };
- };
- };
- };
-
- i18n.inputMethod = {
- type = "fcitx5";
- fcitx5.addons = with pkgs; [ fcitx5-mozc ];
- };
-
- environment.variables = {
- # Required for fcitx5 support in kitty
- GLFW_IM_MODULE = "ibus";
- };
-}
diff --git a/roles/desktop/xserver.nix b/roles/desktop/xserver.nix
deleted file mode 100644
index 4d6a876..0000000
--- a/roles/desktop/xserver.nix
+++ /dev/null
@@ -1,18 +0,0 @@
-{ config, pkgs, lib, ... }:
-
-{
- services.displayManager = {
- defaultSession = "none+i3";
- };
-
- services.xserver = {
- videoDrivers = config.roles.desktop.videoDrivers;
-
- displayManager = {
- setupCommands = config.roles.desktop.setupCommands;
- };
-
- xkb.layout = "us";
-# xkb.options = "eurosign:e,caps:escape";
- };
-}
diff --git a/snowfall/modules/nixos/apps/i3/default.nix b/snowfall/modules/nixos/apps/i3/default.nix
new file mode 100644
index 0000000..e01c6c2
--- /dev/null
+++ b/snowfall/modules/nixos/apps/i3/default.nix
@@ -0,0 +1,50 @@
+{ options, config, lib, namespace, ... }:
+
+with lib; with lib.${namespace}; let
+ cfg = config.${namespace}.apps.i3;
+in {
+ options.${namespace}.apps.i3 = with types; {
+ enable = mkEnableOption "i3";
+
+ videoDrivers = mkOption {
+ type = types.listOf types.str;
+ default = [ "modesetting" "fbdev" ];
+ };
+
+ setupCommands = mkOption {
+ type = types.lines;
+ default = "";
+ description = ''
+ Shell commands executed just after the X server has started.
+ '';
+ };
+ };
+
+ config = mkIf cfg.enable {
+ services = {
+ displayManager = {
+ enable = true;
+ defaultSession = "none+i3";
+ };
+
+ xserver = {
+ enable = true;
+ windowManager.i3.enable = true;
+
+ displayManager = {
+ lightdm.enable = true;
+ setupCommands = cfg.setupCommands;
+ };
+
+ videoDrivers = cfg.videoDrivers;
+ xkb.layout = "us";
+ };
+
+ libinput = {
+ enable = true;
+ mouse.accelProfile = "flat";
+ touchpad.naturalScrolling = true;
+ };
+ };
+ };
+}
diff --git a/snowfall/modules/nixos/apps/playerctl/default.nix b/snowfall/modules/nixos/apps/playerctl/default.nix
new file mode 100644
index 0000000..9bf95d7
--- /dev/null
+++ b/snowfall/modules/nixos/apps/playerctl/default.nix
@@ -0,0 +1,18 @@
+{ options, config, lib, pkgs, namespace, ... }:
+
+with lib; with lib.${namespace}; let
+ cfg = config.${namespace}.apps.playerctl;
+in {
+ options.${namespace}.apps.playerctl = with types; {
+ enable = mkEnableOption "playerctl";
+ };
+
+ config = mkIf cfg.enable {
+ environment.systemPackages = with pkgs; [
+ playerctl
+ ];
+
+ #TODO: enable, eventually
+ services.playerctld.enable = false;
+ };
+}
diff --git a/snowfall/modules/nixos/fonts/default.nix b/snowfall/modules/nixos/fonts/default.nix
new file mode 100644
index 0000000..8055925
--- /dev/null
+++ b/snowfall/modules/nixos/fonts/default.nix
@@ -0,0 +1,38 @@
+{ options, config, lib, pkgs, namespace, ... }:
+
+with lib; with lib.${namespace}; let
+ cfg = config.${namespace}.fonts;
+in {
+ options.${namespace}.fonts = with types; {
+ enable = mkEnableOption "fonts";
+ nerdfonts = mkEnableOption "nerdfonts";
+ extra = mkOption {
+ type = listOf package;
+ default = [];
+ description = ''
+ additional fonts to install
+ '';
+ };
+ };
+
+ config = mkIf cfg.enable {
+ fonts = {
+ packages = with pkgs; [
+ noto-fonts
+ noto-fonts-cjk-sans
+ noto-fonts-cjk-serif
+ noto-fonts-emoji
+ ] ++ (
+ optionals cfg.nerdfonts (
+ cfg.nerdfonts builtins.filter lib.attrsets.isDerivation (builtins.attrValues pkgs.nerd-fonts)
+ )
+ ) ++ cfg.extra;
+
+ fontconfig.defaultFonts = {
+ monospace = [ "CaskaydiaMono Nerd Font" ];
+ sansSerif = [ "DejaVu Sans" "Noto Sans CJK JP" "Noto Sans" ];
+ serif = [ "DejaVu Serif" "Noto Serif CJK JP" "Noto Serif" ];
+ };
+ };
+ };
+}
diff --git a/snowfall/modules/nixos/hardware/audio/default.nix b/snowfall/modules/nixos/hardware/audio/default.nix
new file mode 100644
index 0000000..d2bfa96
--- /dev/null
+++ b/snowfall/modules/nixos/hardware/audio/default.nix
@@ -0,0 +1,25 @@
+{ options, config, lib, pkgs, namespace, ... }:
+
+with lib; with lib.${namespace}; let
+ cfg = config.${namespace}.hardware.audio;
+in {
+ options.${namespace}.hardware.audio = with types; {
+ enable = mkEnableOption "audio support";
+ };
+
+ config = mkIf cfg.enable {
+ environment.systemPackages = with pkgs; [
+ pulseaudio
+ ];
+
+ security.rtkit.enable = true;
+ services.pipewire = {
+ enable = true;
+
+ pulse.enable = true;
+ alsa.enable = true;
+ alsa.support32Bit = true;
+ #jack.enable = true;
+ };
+ };
+}
diff --git a/snowfall/modules/nixos/hardware/keyboard/default.nix b/snowfall/modules/nixos/hardware/keyboard/default.nix
new file mode 100644
index 0000000..a8c478d
--- /dev/null
+++ b/snowfall/modules/nixos/hardware/keyboard/default.nix
@@ -0,0 +1,43 @@
+{ options, config, lib, pkgs, namespace, ... }:
+
+with lib; with lib.${namespace}; let
+ cfg = config.${namespace}.hardware.keyboard;
+in {
+ options.${namespace}.hardware.keyboard = with types; {
+ enable = mkEnableOption "keyboard hardware tweaks";
+ jp = mkEnableOption "japanese ime support";
+ };
+
+ config = mkIf cfg.enable {
+ services.keyd = {
+ enable = true;
+
+ keyboards."*".settings = {
+ main = {
+ # Swap alt and meta keys.
+ # I prefer (physical) alt as my WM modifier key because it
+ # is easier to reach. This can collide with some programs
+ # shortcuts if they inlcude alt. Swapping alt and meta fixes
+ # this by making my WM mod key (software) meta, freeing up alt.
+
+ leftalt = "leftmeta";
+ leftmeta = "leftalt";
+
+ rightalt = "rightmeta";
+ rightmeta = "rightalt";
+ };
+ };
+ };
+
+ i18n.inputMethod = mkIf cfg.jp {
+ enable = true;
+ type = "fcitx5";
+ fcitx5.addons = with pkgs; [ fcitx5-mozc ];
+ };
+
+ environment.variables = mkIf cfg.jp {
+ # Required for fcitx5 support in kitty
+ GLFW_IM_MODULE = "ibus";
+ };
+ };
+}
diff --git a/snowfall/modules/nixos/suites/common/default.nix b/snowfall/modules/nixos/suites/common/default.nix
index 0090ba3..e7656d1 100644
--- a/snowfall/modules/nixos/suites/common/default.nix
+++ b/snowfall/modules/nixos/suites/common/default.nix
@@ -9,6 +9,10 @@ in {
config = mkIf cfg.enable {
cxl = {
+ hardware = {
+ keyboard.enable = true;
+ };
+
apps = {
bash.enable = true;
};
diff --git a/snowfall/modules/nixos/suites/desktop/default.nix b/snowfall/modules/nixos/suites/desktop/default.nix
new file mode 100644
index 0000000..09dd4e3
--- /dev/null
+++ b/snowfall/modules/nixos/suites/desktop/default.nix
@@ -0,0 +1,25 @@
+{ options, config, lib, namespace, ... }:
+
+with lib; with lib.${namespace}; let
+ cfg = config.${namespace}.suites.desktop;
+in {
+ options.${namespace}.suites.desktop = with types; {
+ enable = mkEnableOption "desktop";
+ };
+
+ config = mkIf cfg.enable {
+ cxl = {
+ hardware = {
+ audio.enable = true;
+ keyboard.jp = true;
+ };
+
+ apps = {
+ i3.enable = true;
+ playerctl.enable = true;
+ };
+
+ fonts.enable = true;
+ };
+ };
+}
diff --git a/snowfall/systems/x86_64-linux/c-pc/default.nix b/snowfall/systems/x86_64-linux/c-pc/default.nix
index 201c999..05f6965 100644
--- a/snowfall/systems/x86_64-linux/c-pc/default.nix
+++ b/snowfall/systems/x86_64-linux/c-pc/default.nix
@@ -1,4 +1,4 @@
-{ lib, namespace, ... }:
+{ lib, pkgs, namespace, ... }:
with lib; with lib.${namespace}; {
imports = [
@@ -14,7 +14,12 @@ with lib; with lib.${namespace}; {
suites = {
common.enable = true;
+ desktop.enable = true;
};
+
+ fonts.extra = with pkgs; [
+ minecraftia
+ ];
};
system.stateVersion = "23.11";