diff options
author | Mx Kookie <kookie@spacekookie.de> | 2020-12-21 13:17:20 +0100 |
---|---|---|
committer | Mx Kookie <kookie@spacekookie.de> | 2020-12-22 20:42:17 +0100 |
commit | 9a10d19ced763cccf64aa662fd3bc0fa811ce3af (patch) | |
tree | 101d0ec1983f5b3730de7549fa7dc971f720f1a7 /infra/libkookie/modules/workstation | |
parent | a3be97011845fefd94d0ec926448629f8f5e5cac (diff) |
libkookie: i3: adding module, configurations, and tempest config
Diffstat (limited to 'infra/libkookie/modules/workstation')
12 files changed, 260 insertions, 0 deletions
diff --git a/infra/libkookie/modules/workstation/default.nix b/infra/libkookie/modules/workstation/default.nix new file mode 100644 index 000000000000..e6f016b4acbe --- /dev/null +++ b/infra/libkookie/modules/workstation/default.nix @@ -0,0 +1,7 @@ +{ ... }: { + imports = [ + + # Exposes both a nixos, and home-manager module + ./ui/i3 + ]; +} diff --git a/infra/libkookie/modules/workstation/ui/i3/core/config.nix b/infra/libkookie/modules/workstation/ui/i3/core/config.nix new file mode 100644 index 000000000000..e0fd5938ef2f --- /dev/null +++ b/infra/libkookie/modules/workstation/ui/i3/core/config.nix @@ -0,0 +1,21 @@ +/** A base configuration template for i3 + * + * This set of configuration values is meant to work on _all_ + * systems. No device specifics are included. This set must be + * merged with device specific options before being applied + */ +{ config, pkgs, ... } @ args: + +let + cfg = config.libkookie.ui.i3; + xtraPkgs = pkgs // (import ./tools args); +in +rec { + # This is not configurable by design + modifier = "Mod4"; + + inherit (cfg) fonts; + + keybindings = (import ./keys.nix { inherit modifier; + pkgs = xtraPkgs; }); +} diff --git a/infra/libkookie/modules/workstation/ui/i3/core/default.nix b/infra/libkookie/modules/workstation/ui/i3/core/default.nix new file mode 100644 index 000000000000..ad9b269cf711 --- /dev/null +++ b/infra/libkookie/modules/workstation/ui/i3/core/default.nix @@ -0,0 +1,38 @@ +{ lib, config, pkgs, ... }: + +{ + # Set the basic xfce/xserver configuration + services.xserver = { + enable = true; + desktopManager = { + xfce = { + enable = true; + noDesktop = true; + enableXfwm = false; + }; + }; + displayManager.defaultSession = "xfce+i3"; + windowManager.i3.enable = true; + + useGlamor = true; + + inherit (config.libkookie.ui.i3) videoDrivers; + + deviceSection = '' + Option "DRI" "2" + Option "TearFree" "true" + ''; + }; + + # Enable OpenGL support on the hardware, with some extra packages + # FIXME: add 32bit driver support only if steam support is enabled + hardware.opengl = { + enable = true; + driSupport = true; + extraPackages = with pkgs; [ + libGL xorg.xf86videoati xorg.xf86inputlibinput + ]; + driSupport32Bit = true; + }; +} + diff --git a/infra/libkookie/modules/workstation/ui/i3/core/keys.nix b/infra/libkookie/modules/workstation/ui/i3/core/keys.nix new file mode 100644 index 000000000000..05497926cc5c --- /dev/null +++ b/infra/libkookie/modules/workstation/ui/i3/core/keys.nix @@ -0,0 +1,63 @@ +{ pkgs, modifier }: + +{ + # Start a terminal + "${modifier}+Return" = "exec ${pkgs.kitty}/bin/kitty"; + + # Area screenshot support + "${modifier}+9" = "exec ${pkgs.libkookie-i3-scrcap}"; + + # Close individual windows + "${modifier}+Shift+q" = "kill"; + + # Full-screen window + "${modifier}+f" = "fullscreen"; + + # Start software on <this> or <other> workspace + "${modifier}+e" = "exec ${pkgs.dmenu}/bin/dmenu_run"; + + # Switch to workspace (optionally take current window) + "${modifier}+o" = "exec ${pkgs.libkookie-i3-switch}"; + "${modifier}+Shift+o" = "exec ${pkgs.libkookie-i3-move}"; + + # Rename workspaces + "${modifier}+Ctrl+r" = "exec ${pkgs.libkookie-i3-rename}"; + # Move focus around - vim style + "${modifier}+h" = "focus left"; + "${modifier}+t" = "focus up"; + "${modifier}+n" = "focus down"; + "${modifier}+s" = "focus right"; + + # Move focus around - boring style + "${modifier}+Up" = "focus up"; + "${modifier}+Down" = "focus down"; + "${modifier}+Left" = "focus left"; + "${modifier}+Right" = "focus right"; + + # Move windows - vim style + "${modifier}+Shift+h" = "move left"; + "${modifier}+Shift+t" = "move up"; + "${modifier}+Shift+n" = "move down"; + "${modifier}+Shift+s" = "move right"; + + # Move windows - boring style + "${modifier}+Shift+Up" = "move up"; + "${modifier}+Shift+Down" = "move down"; + "${modifier}+Shift+Left" = "move left"; + "${modifier}+Shift+Right" = "move right"; + + # Move workspaces between multi-monitor setups + "${modifier}+Ctrl+Shift+Up" = "move workspace to output up"; + "${modifier}+Ctrl+Shift+Down" = "move workspace to output down"; + "${modifier}+Ctrl+Shift+Left" = " move workspace to output left"; + "${modifier}+Ctrl+Shift+Right" = "move workspace to output right"; + + # Define split behaviours + "${modifier}+2" = "split h"; + "${modifier}+1" = "split v"; + + # Some layout modifiers + "${modifier}+3" = "layout default"; + "${modifier}+4" = "layout tabbed"; + "${modifier}+5" = "layout stacked"; +} diff --git a/infra/libkookie/modules/workstation/ui/i3/core/setup.nix b/infra/libkookie/modules/workstation/ui/i3/core/setup.nix new file mode 100644 index 000000000000..85c913d6a298 --- /dev/null +++ b/infra/libkookie/modules/workstation/ui/i3/core/setup.nix @@ -0,0 +1,11 @@ +{ lib, config, pkgs, home-manager, ... } @ args: + +let config = (import ./config.nix args); +in +{ + xsession.windowManager.i3 = { + enable = true; + package = pkgs.i3; + inherit config; + }; +} diff --git a/infra/libkookie/modules/workstation/ui/i3/core/tools/default.nix b/infra/libkookie/modules/workstation/ui/i3/core/tools/default.nix new file mode 100644 index 000000000000..40ce022c6144 --- /dev/null +++ b/infra/libkookie/modules/workstation/ui/i3/core/tools/default.nix @@ -0,0 +1,8 @@ +{ pkgs, ... } @ args: + +{ + libkookie-i3-move = (import ./i3-move.nix args); + libkookie-i3-switch = (import ./i3-switch.nix args); + libkookie-i3-rename = (import ./i3-rename.nix args); + libkookie-i3-scrcap = (import ./i3-scrcap.nix args); +} diff --git a/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-move.nix b/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-move.nix new file mode 100644 index 000000000000..1ba4a45bcab6 --- /dev/null +++ b/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-move.nix @@ -0,0 +1,17 @@ +/** A utility script to move a window to a workspace + * + * This tool relies on i3-msg, jq, and dmenu to move a window to a + * different workspace. In the future, maybe the display mechanism + * (dmenu) could be made configurable, so not to rely on nazi code. + */ + +{ pkgs, ... }: with pkgs; writeShellScript "libkookie-i3-move" '' + + WS=$(${i3}/bin/i3-msg -t get_workspaces | \ + ${jq}/bin/jq -M '.[] | .name' | tr -d '"' \ + | sort -u | ${dmenu}/bin/dmenu -b -i "$@") + + + ${i3}/bin/i3-msg -t command move workspace $WS + ${i3}/bin/i3-msg workspace $WS +'' diff --git a/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-rename.nix b/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-rename.nix new file mode 100644 index 000000000000..68bd32364452 --- /dev/null +++ b/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-rename.nix @@ -0,0 +1,10 @@ +/** A utility to rename the current workspace + * + * This tool relies on i3-msg, jq, and dmenu to move a window to a + * different workspace. In the future, maybe the display mechanism + * (dmenu) could be made configurable, so not to rely on nazi code. + */ + +{ pkgs, ... }: with pkgs; writeShellScript "libkookie-i3-rename" '' + exec i3-input -F 'rename workspace to \"%s\"' -P 'New name: ' +'' diff --git a/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-scrcap.nix b/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-scrcap.nix new file mode 100644 index 000000000000..6146dabee67a --- /dev/null +++ b/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-scrcap.nix @@ -0,0 +1,10 @@ +/** A utility script to take screenshots + * + * This tool relies on scrot to take screenshot, independent of a + * complete windowing compositor running. gnome-screenshot was + * used in the past, but has weird behaviour on non-gnome systems. + */ + +{ pkgs, ... }: with pkgs; writeShellScript "libkookie-i3-move" '' + ${scrot}/bin/scrot -s +'' diff --git a/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-switch.nix b/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-switch.nix new file mode 100644 index 000000000000..691e9470db83 --- /dev/null +++ b/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-switch.nix @@ -0,0 +1,15 @@ +/** A utility script to switch to a workspace + * + * This tool relies on i3-msg, jq, and dmenu to switch to a different + * workspace. In the future, maybe the display mechanism (dmenu) + * could be made configurable, so not to rely on nazi code. + */ + +{ pkgs, ... }: with pkgs; writeShellScript "libkookie-i3-switch" '' + + WS=$(${i3}/bin/i3-msg -t get_workspaces | \ + ${jq}/bin/jq -M '.[] | .name' | tr -d '"' \ + | sort -u | ${dmenu}/bin/dmenu -b -i "$@") + + ${i3}/bin/i3-msg workspace $WS +'' diff --git a/infra/libkookie/modules/workstation/ui/i3/default.nix b/infra/libkookie/modules/workstation/ui/i3/default.nix new file mode 100644 index 000000000000..e4fa23b28784 --- /dev/null +++ b/infra/libkookie/modules/workstation/ui/i3/default.nix @@ -0,0 +1,29 @@ +/** + * A custom nixos module to configure i3. + * + * This nixos module provides a simple API + * The special thing about this configuration is the way workspaces + * are handled. Instead of numerical workspaces, this configuration + * sets up scripts to manage named workspaces + */ + +{ config, lib, pkgs, home-manager, ... } @ args: + +let cfg = config.libkookie.ui.i3; +in +with lib; +{ + options.libkookie.ui.i3 = { + enable = mkEnableOption "i3 + xfce4 display manager"; + + videoDrivers = with lib; mkOption { + type = with types; listOf str; + default = []; + description = '' + The set of video drivers to instantiate on a given system + ''; + }; + }; + + config = mkIf cfg.enable (import ./core args); +} diff --git a/infra/libkookie/modules/workstation/ui/i3/hm.nix b/infra/libkookie/modules/workstation/ui/i3/hm.nix new file mode 100644 index 000000000000..0341fc5b07ac --- /dev/null +++ b/infra/libkookie/modules/workstation/ui/i3/hm.nix @@ -0,0 +1,31 @@ +/** + * A home-manager module to configure userspace i3 + * + */ + +{ config, lib, pkgs, home-manager, ... } @ args: + +let cfg = config.libkookie.ui.i3; +in +{ + options.libkookie.ui.i3 = with lib; { + compton = mkEnableOption "window composition with compton"; + + wallpaper = mkOption { + type = types.path; + description = '' + Specify the wallpaper to set. + ''; + }; + + fonts = mkOption { + type = with types; listOf package; + default = [ "monospace" ]; + description = '' + A set of fonts to use by the i3 module for rendering text + ''; + }; + }; + + config = (import core/setup.nix args); +} |