aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMx Kookie <kookie@spacekookie.de>2020-12-21 13:17:20 +0100
committerMx Kookie <kookie@spacekookie.de>2020-12-22 20:42:17 +0100
commit9a10d19ced763cccf64aa662fd3bc0fa811ce3af (patch)
tree101d0ec1983f5b3730de7549fa7dc971f720f1a7
parenta3be97011845fefd94d0ec926448629f8f5e5cac (diff)
libkookie: i3: adding module, configurations, and tempest config
-rw-r--r--infra/libkookie/configuration/users/spacekookie/default.nix14
-rw-r--r--infra/libkookie/configuration/workstation/i3/tempest.nix14
-rw-r--r--infra/libkookie/modules/default.nix11
-rw-r--r--infra/libkookie/modules/workstation/default.nix7
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/core/config.nix21
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/core/default.nix38
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/core/keys.nix63
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/core/setup.nix11
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/core/tools/default.nix8
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/core/tools/i3-move.nix17
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/core/tools/i3-rename.nix10
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/core/tools/i3-scrcap.nix10
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/core/tools/i3-switch.nix15
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/default.nix29
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/hm.nix31
-rw-r--r--infra/libkookie/roots/tempest.nix44
16 files changed, 330 insertions, 13 deletions
diff --git a/infra/libkookie/configuration/users/spacekookie/default.nix b/infra/libkookie/configuration/users/spacekookie/default.nix
new file mode 100644
index 000000000000..86e152cb093e
--- /dev/null
+++ b/infra/libkookie/configuration/users/spacekookie/default.nix
@@ -0,0 +1,14 @@
+{ lib, pkgs, ... }:
+
+{
+ name = "spacekookie"; # FIXME: remove this redundancy
+ cfg = {
+ createHome = true;
+ description = "Katharina Fey";
+ home = lib.mkDefault "/home";
+ uid = lib.mkDefault 1000;
+ group = "spacekookie";
+ extraGroups = [ "wheel" "dialout" ];
+ shell = lib.mkDefault pkgs.fish;
+ };
+}
diff --git a/infra/libkookie/configuration/workstation/i3/tempest.nix b/infra/libkookie/configuration/workstation/i3/tempest.nix
new file mode 100644
index 000000000000..23717d813ed5
--- /dev/null
+++ b/infra/libkookie/configuration/workstation/i3/tempest.nix
@@ -0,0 +1,14 @@
+{ config, lib, pkgs, home-manager, ... }:
+
+{
+ # Load the home-manager i3 module
+ imports = [ <modules/workstation/ui/i3/hm.nix> ];
+
+ # Then configure it
+ libkookie.ui.i3 = {
+ fonts = [ "Iosevka:13" ];
+ };
+
+ # FIXME: make this be included automatically
+ home.packages = with pkgs; [ iosevka ];
+}
diff --git a/infra/libkookie/modules/default.nix b/infra/libkookie/modules/default.nix
new file mode 100644
index 000000000000..5d4e378d01cd
--- /dev/null
+++ b/infra/libkookie/modules/default.nix
@@ -0,0 +1,11 @@
+/** References all modules contained in libkookie */
+
+{ ... }: {
+ imports = [
+ # libkookie module harness runs the show
+ ./harness/users.nix
+
+ # Add modules based on use-case
+ ./workstation
+ ];
+}
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);
+}
diff --git a/infra/libkookie/roots/tempest.nix b/infra/libkookie/roots/tempest.nix
index 7ace933c5d4b..e3ec2c312f72 100644
--- a/infra/libkookie/roots/tempest.nix
+++ b/infra/libkookie/roots/tempest.nix
@@ -9,22 +9,41 @@
* LIBKOOKIE is licensed under the GPL-3.0 (or later) -- see LICENSE
*/
-{ lib, config, pkgs, ... }:
+{ lib, config, pkgs, ... } @ args:
+let klib = (import <modules/harness/lib.nix>) args;
+in
{
- nixpkgs.config.allowUnfree = true;
-
- imports = [
- # ../modules/nix
- # ../modules/nix/home-manager.nix
-
- # ../modules/base
- # ../modules/docker
- # ../modules/workstation
- # ../modules/workstation/hardware/yubikey
- # ../modules/workstation/hardware/xkblayout
+
+
+ ###################################################################
+ # libkookie playground
+ #
+ #
+ #
+
+
+ imports = with klib; [
+ # Load base modules required to bootstrap libkookie
+ <home-manager/nixos> <modules>
+
+ # Import desired userspace modules
+ (loadModule <configuration/workstation/i3> "tempest")
];
+
+ libkookie.activeUsers = [ (klib.load <configuration/users/spacekookie>) ];
+
+ # Configure i3 with the amdgpu driver
+ libkookie.ui.i3 = { enable = true;
+ videoDrivers = [ "amdgpu" ]; };
+
+ #
+ #
+ #
+ #
+ ###################################################################
+
# Use the GRUB 2 boot loader.
boot.loader.grub = {
enable = true;
@@ -78,7 +97,6 @@
# Set your time zone.
time.timeZone = "Europe/Berlin";
- # libkookie.wallpaper = "/home/Pictures/Wallpapers/small-memory.webp";
programs.sway.enable = true;
programs.mtr.enable = true;