From cf12b4ad6713efc9b66287b265a8d8d35b92fe8a Mon Sep 17 00:00:00 2001 From: "Casper V. Kristensen" Date: Fri, 4 Aug 2023 13:08:58 +0200 Subject: [PATCH] sway --- modules/base/impermanence.nix | 2 +- modules/base/system.nix | 5 +- modules/desktop/default.nix | 10 +++- modules/desktop/sway.nix | 100 ++++++++++++++++++++++++++++++++-- 4 files changed, 109 insertions(+), 8 deletions(-) diff --git a/modules/base/impermanence.nix b/modules/base/impermanence.nix index 822bcae..2225a29 100644 --- a/modules/base/impermanence.nix +++ b/modules/base/impermanence.nix @@ -1,4 +1,4 @@ -{ pkgs, impermanence, ... }: { +{ impermanence, pkgs, ... }: { # The impermanence module bind-mounts persistent files and directories, stored in /nix/persist, into the tmpfs root # partition on startup. For example: /nix/persist/etc/machine-id is mounted to /etc/machine-id. # https://github.com/nix-community/impermanence diff --git a/modules/base/system.nix b/modules/base/system.nix index 1caa2cd..7c5dea3 100644 --- a/modules/base/system.nix +++ b/modules/base/system.nix @@ -1,4 +1,4 @@ -{ pkgs, nix-index-database, ... }: { +{ nix-index-database, lib, pkgs, ... }: { imports = [ nix-index-database.nixosModules.nix-index ]; @@ -63,6 +63,9 @@ LC_TELEPHONE = "en_DK.UTF-8"; LC_TIME = "en_DK.UTF-8"; }; + supportedLocales = lib.mkOptionDefault [ + "da_DK.UTF-8/UTF-8" + ]; }; time = { diff --git a/modules/desktop/default.nix b/modules/desktop/default.nix index 3f05ea2..0239f28 100644 --- a/modules/desktop/default.nix +++ b/modules/desktop/default.nix @@ -1,4 +1,4 @@ -{ ... }: +{ pkgs, ... }: { imports = [ @@ -6,4 +6,12 @@ ./ssh.nix ./sway.nix ]; + + environment.systemPackages = with pkgs; [ + keepassxc + ]; + + services.logind.extraConfig = '' + HandlePowerKey=ignore + ''; } diff --git a/modules/desktop/sway.nix b/modules/desktop/sway.nix index cc5ed59..851b4e8 100644 --- a/modules/desktop/sway.nix +++ b/modules/desktop/sway.nix @@ -1,19 +1,19 @@ -{ pkgs, home-manager, ... }: { +{ home-manager, lib, pkgs, ... }: { # https://nixos.wiki/wiki/Sway # https://nix-community.github.io/home-manager/options.html + security.polkit.enable = true; + home-manager.users.caspervk = { wayland.windowManager.sway = { enable = true; config = { - assigns = { - "1: web" = [{ class = "^Firefox$"; }]; - }; input = { "*" = { # Keyboard xkb_layout = "us"; xkb_variant = "altgr-intl"; + repeat_delay = "250"; # Trackpad tap = "enabled"; @@ -21,15 +21,88 @@ dwt = "disabled"; # don't disable-while-typing }; }; + assigns = { + "1: web" = [{ class = "^Firefox$"; }]; + }; modifier = "Mod4"; # super + keybindings = lib.mkOptionDefault { + "Mod4+z" = "focus child"; + "Mod4+Escape" = "exec loginctl lock-session"; + + # Brightness + "XF86MonBrightnessUp" = "exec light -A 5"; + "XF86MonBrightnessDown" = "exec light -U 5"; + + # Volume + "XF86AudioRaiseVolume" = "exec 'pactl set-sink-volume @DEFAULT_SINK@ +2%'"; + "XF86AudioLowerVolume" = "exec 'pactl set-sink-volume @DEFAULT_SINK@ -2%'"; + "XF86AudioMute" = "exec 'pactl set-sink-mute @DEFAULT_SINK@ toggle'"; + }; terminal = "alacritty"; workspaceAutoBackAndForth = true; + bars = [{ command = "${pkgs.waybar}/bin/waybar"; }]; }; }; + + programs.waybar = + let + mkDefaultConfig = pkgs.stdenv.mkDerivation { + name = "waybarDefaultConfig"; + src = "${pkgs.waybar}/etc/xdg/waybar"; + installPhase = '' + sed 's#//.*##' config | ${pkgs.jq}/bin/jq > $out + ''; + }; + defaultConfig = builtins.fromJSON (lib.readFile "${mkDefaultConfig}"); + in + { + enable = true; + settings = { + bar = lib.mkMerge [ + defaultConfig + { + modules-right = lib.mkForce [ "tray" "idle_inhibitor" "pulseaudio" "cpu" "memory" "backlight" "network" "battery" "clock" ]; + clock = { + interval = 5; + locale = "da_DK.UTF-8"; + format = "{:%a %e. %b %H:%M}"; + calendar = { + mode = "year"; + mode-mon-col = 6; + weeks-pos = "left"; + }; + }; + backlight = { + format-icons = lib.mkForce [ "" ]; + }; + } + ]; + }; + }; + + services.swayidle = + let + lock = "${pkgs.swaylock}/bin/swaylock --daemonize --color=333333"; + in + { + enable = true; + events = [ + { event = "lock"; command = lock; } + { event = "before-sleep"; command = lock; } + ]; + timeouts = [ + { timeout = 600; command = lock; } + ]; + }; }; environment.systemPackages = with pkgs; [ alacritty + clipman + pulseaudio # pactl + pavucontrol # PulseAudio Volume Control + swaylock + wl-clipboard ]; # Audio @@ -49,10 +122,27 @@ # Allow sharing screen #xdg.portal.wlr.enable = true; - security.polkit.enable = true; + security.pam.services.swaylock.text = '' + # PAM configuration file for the swaylock screen locker. By default, it includes + # the 'login' configuration file (see /etc/pam.d/login) + auth include login + ''; hardware.opengl = { enable = true; extraPackages = with pkgs; [ intel-media-driver ]; }; + + fonts.fonts = with pkgs; [ + noto-fonts + noto-fonts-cjk + noto-fonts-emoji + liberation_ttf + fira-code + fira-code-symbols + mplus-outline-fonts.githubRelease + dina-font + proggyfonts + font-awesome # for waybar + ]; }