From 2723186f49b1d622eb918956d7a258a6f7228620 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 19 Apr 2021 14:29:38 +0200 Subject: [PATCH] home: basic i3 setup --- home/default.nix | 4 +++ home/x/default.nix | 10 ++++++ home/x/i3.nix | 77 ++++++++++++++++++++++++++++++++++++++++ hosts/boreal/default.nix | 2 ++ hosts/boreal/home.nix | 7 ++++ 5 files changed, 100 insertions(+) create mode 100644 home/x/default.nix create mode 100644 home/x/i3.nix create mode 100644 hosts/boreal/home.nix diff --git a/home/default.nix b/home/default.nix index 5a16987..1cb28cb 100644 --- a/home/default.nix +++ b/home/default.nix @@ -1,5 +1,9 @@ { ... }: { + imports = [ + ./x + ]; + home.stateVersion = "20.09"; home.username = "alarsyo"; diff --git a/home/x/default.nix b/home/x/default.nix new file mode 100644 index 0000000..382e0e5 --- /dev/null +++ b/home/x/default.nix @@ -0,0 +1,10 @@ +{ config, lib, pkgs, ... }: +{ + imports = [ + ./i3.nix + ]; + + options.my.home.x = with lib; { + enable = mkEnableOption "X server configuration"; + }; +} diff --git a/home/x/i3.nix b/home/x/i3.nix new file mode 100644 index 0000000..307b7b8 --- /dev/null +++ b/home/x/i3.nix @@ -0,0 +1,77 @@ +{ config, lib, pkgs, ... }: +let + isEnabled = config.my.home.x.enable; + + myTerminal = + # FIXME: fix when terminal is setup in home + # if config.my.home.terminal.program != null + if true + then "alacritty" + else "i3-sensible-terminal"; + + alt = "Mod1"; # `Alt` key + modifier = "Mod4"; # `Super` key + + logoutMode = "[L]ogout, [S]uspend, [P]oweroff, [R]eboot"; +in +{ + config = lib.mkIf isEnabled { + # FIXME: enable flameshot when added + # my.home = {}; + + xsession.windowManager.i3 = { + enable = true; + + config = { + inherit modifier; + + bars = + [ + { + statusCommand = "i3status"; + position = "top"; + } + ]; + + focus = { + followMouse = true; + mouseWarping = true; + }; + + fonts = [ + "DejaVu Sans Mono 8" + ]; + + keybindings = lib.mkOptionDefault { + "${modifier}+Shift+e" = ''mode "${logoutMode}"''; + }; + + modes = + let + makeModeBindings = attrs: attrs // { + "Escape" = "mode default"; + "Return" = "mode default"; + }; + in + { + ${logoutMode} = makeModeBindings { + "l" = "exec --no-startup-id i3-msg exit, mode default"; + "s" = "exec --no-startup-id systemctl suspend, mode default"; + "p" = "exec --no-startup-id systemctl poweroff, mode default"; + "r" = "exec --no-startup-id systemctl reboot, mode default"; + }; + }; + + startup = [ + # FIXME: make it conditional on "nvidia" being part of video drivers + { + command = "nvidia-settings -a '[gpu:0]/GPUPowerMizerMode=1'"; + notification = false; + } + ]; + + terminal = myTerminal; + }; + }; + }; +} diff --git a/hosts/boreal/default.nix b/hosts/boreal/default.nix index 71615c6..347132a 100644 --- a/hosts/boreal/default.nix +++ b/hosts/boreal/default.nix @@ -10,6 +10,8 @@ in imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix + + ./home.nix ]; # Use the systemd-boot EFI boot loader. diff --git a/hosts/boreal/home.nix b/hosts/boreal/home.nix new file mode 100644 index 0000000..fe3fea0 --- /dev/null +++ b/hosts/boreal/home.nix @@ -0,0 +1,7 @@ +{ ... }: +{ + home-manager.users.alarsyo = { + # Keyboard settings & i3 settings + my.home.x.enable = true; + }; +}