split sway module

This commit is contained in:
Casper V. Kristensen 2023-08-25 01:02:54 +02:00
parent 260b9b89cf
commit d0a8ffa12c
7 changed files with 146 additions and 100 deletions

View file

@ -1,28 +1,15 @@
{ pkgs, ... }: {
{ ... }: {
imports = [
./alacritty.nix
./clipman.nix
./gammastep.nix
./kanshi.nix
./network.nix
./pipewire.nix
./programs.nix
./ssh.nix
./sway.nix
./syncthing.nix
./wofi.nix
];
environment.systemPackages = with pkgs; [
firefox-wayland
keepassxc
(kodi-wayland.withPackages (kodiPackages: with kodiPackages; [
jellyfin
]))
libqalculate
mpv
spotify
tor-browser-bundle-bin
vlc
webcord # discord
];
services.logind.extraConfig = ''
HandlePowerKey=ignore
'';
}

View file

@ -0,0 +1,18 @@
{ home-manager, ... }: {
# Gammestep automatically adjusts the screen's colour temperature. It's
# basically redshift for Wayland.
# https://gitlab.com/chinstrap/gammastep
# https://nixos.wiki/wiki/Gammastep
home-manager.users.caspervk = {
services.gammastep = {
enable = true;
dawnTime = "06:00";
duskTime = "22:30";
temperature = {
day = 6500; # default upstream but not in nixpkgs, neutral
night = 4500; # default upstream but not in nixpkgs
};
};
};
}

View file

@ -0,0 +1,35 @@
{ home-manager, ... }: {
# kanshi allows you to define output profiles that are automatically enabled
# and disabled on hotplug. For instance, this can be used to turn a laptop's
# internal screen off when docked. This is a Wayland equivalent for tools
# like autorandr.
# https://sr.ht/~emersion/kanshi/
home-manager.users.caspervk = {
services.kanshi = {
enable = true;
profiles = {
# Output names (criteria) from `swaymsg -t get_outputs`.
omega.outputs = [
{
criteria = "ASUSTek COMPUTER INC ROG XG27AQ M3LMQS370969";
mode = "2560x1440@144Hz";
position = "0,0";
adaptiveSync = false; # seems to flicker
}
{
criteria = "BNQ BenQ XL2411Z SCD06385SL0";
mode = "1920x1080@144Hz";
position = "2560,400";
}
];
zeta.outputs = [
{
criteria = "Chimei Innolux Corporation 0x14D2 Unknown";
mode = "1920x1080@60Hz";
}
];
};
};
};
}

View file

@ -0,0 +1,22 @@
{ home-manager, lib, pkgs, ... }: {
# PipeWire is a new low-level multimedia framework. It aims to offer capture
# and playback for both audio and video with minimal latency and support for
# PulseAudio-, JACK-, ALSA- and GStreamer-based applications.
# https://nixos.wiki/wiki/PipeWire
services.pipewire = {
enable = true;
alsa = {
enable = true;
support32Bit = true;
};
jack.enable = true;
pulse.enable = true;
};
# RealtimeKit is a D-Bus system service that allows user processes to gain
# realtime scheduling priority on request. It is intended to be used as a
# secure mechanism to allow real-time scheduling to be used by normal user
# processes.
security.rtkit.enable = true;
}

View file

@ -0,0 +1,25 @@
{ home-manager, pkgs, ... }: {
# Packages useful on a desktop computer which don't require their own module
environment.systemPackages = with pkgs; [
firefox-wayland
keepassxc
(kodi-wayland.withPackages (kodiPackages: with kodiPackages; [
jellyfin
]))
libqalculate
mpv
spotify
tor-browser-bundle-bin
vlc
webcord # discord
];
home-manager.users.caspervk = {
home.sessionVariables = {
# The firefox-wayland package works with wayland without any further
# configuration, but tor-browser doesn't.
MOZ_ENABLE_WAYLAND = 1;
};
};
}

View file

@ -7,10 +7,6 @@
home-manager.users.caspervk = {
wayland.windowManager.sway = {
enable = true;
# Execute sway with required environment variables for GTK applications
wrapperFeatures = {
gtk = true;
};
config = {
input = {
"type:keyboard" = {
@ -64,12 +60,16 @@
"XF86AudioPrev" = "exec 'playerctl previous'";
};
focus = {
# Don't automatically focus hovered windows
followMouse = "no";
};
gaps = {
smartBorders = "no_gaps";
};
window = {
# Don't show unnecessary window titlebars, e.g. when there is only
# one window on screen. The titlebars will still be shown if tabbing
# or stacking windows.
titlebar = false;
};
colors = {
@ -84,12 +84,21 @@
terminal = "alacritty";
bars = [{ command = "${pkgs.waybar}/bin/waybar"; }];
};
# Execute sway with required environment variables for GTK applications
wrapperFeatures = {
gtk = true;
};
};
# https://github.com/Alexays/Waybar/wiki/Configuration
# https://github.com/Alexays/Waybar/blob/master/resources/config
programs.waybar =
let
# It isn't possible to extend the default Waybar config in Home
# Manager; as soon as any setting is defined it overwrites the entire
# default configuration. To combat this, we parse the default config
# into Nix and merge it with our changes.
mkDefaultConfig = pkgs.stdenv.mkDerivation {
name = "waybarDefaultConfig";
src = "${pkgs.waybar}/etc/xdg/waybar";
@ -184,67 +193,13 @@
{ timeout = 600; command = lock; }
];
};
# https://hg.sr.ht/~scoopta/wofi
programs.wofi = {
enable = true;
settings = {
show = "drun";
allow_images = true;
gtk_dark = true;
insensitive = true;
prompt = ""; # hides 'drun' from the search bar
};
};
# https://sr.ht/~emersion/kanshi/
services.kanshi = {
enable = true;
profiles = {
# Output names ("criteria") from `swaymsg -t get_outputs`.
omega.outputs = [
{
criteria = "ASUSTek COMPUTER INC ROG XG27AQ M3LMQS370969";
mode = "2560x1440@144Hz";
position = "0,0";
adaptiveSync = false; # seems to flicker
}
{
criteria = "BNQ BenQ XL2411Z SCD06385SL0";
mode = "1920x1080@144Hz";
position = "2560,0";
}
];
zeta.outputs = [
{
criteria = "Chimei Innolux Corporation 0x14D2 Unknown";
mode = "1920x1080@60Hz";
}
];
};
};
# Gammestep automatically adjusts the screen's colour temperature. It's
# basically redshift for wayland.
# https://gitlab.com/chinstrap/gammastep
# https://nixos.wiki/wiki/Gammastep
services.gammastep = {
enable = true;
dawnTime = "07:00";
duskTime = "23:00";
temperature = {
day = 6500; # neutral
night = 4500;
};
};
home.sessionVariables = {
# The firefox-wayland package works with wayland without any further
# configuration, but tor-browser doesn't.
MOZ_ENABLE_WAYLAND = 1;
};
};
# Don't shut down the system when the power key is pressed
services.logind.extraConfig = ''
HandlePowerKey=ignore
'';
# Connect swaylock to PAM. If this isn't done, swaylock needs the suid flag
security.pam.services.swaylock.text = ''
auth include login
@ -264,24 +219,8 @@
};
};
# Audio
# https://nixos.wiki/wiki/PipeWire
services.pipewire = {
enable = true;
alsa = {
enable = true;
support32Bit = true;
};
jack.enable = true;
pulse.enable = true;
};
# The RealtimeKit system services allows user processes to gain realtime scheduling priority
security.rtkit.enable = true;
environment.systemPackages = with pkgs; [
brightnessctl
clipman # TODO
gnome3.adwaita-icon-theme # cursor TODO
grim # screenshot TODO
pavucontrol # PulseAudio Volume Control gui
@ -293,8 +232,9 @@
wtype # xdotool for wayland
];
# xdg portal allows applications secury access to resources outside their sandbox.
# In particular, this allows screen sharing on Wayland via PipeWire and file open/save dialogues in Firefox.
# xdg portal allows applications secure access to resources outside their
# sandbox. In particular, this allows screen sharing on Wayland via PipeWire
# and file open/save dialogues in Firefox.
# https://wiki.archlinux.org/title/XDG_Desktop_Portal
# https://mozilla.github.io/webrtc-landing/gum_test.html
xdg.portal = {
@ -302,6 +242,7 @@
wlr.enable = true;
};
# TODO
hardware.opengl = {
enable = true;
extraPackages = with pkgs; [ intel-media-driver ];

18
modules/desktop/wofi.nix Normal file
View file

@ -0,0 +1,18 @@
{ home-manager, ... }: {
# Rofi-inspired menu program for Wayland.
# Used to open programs and view the clipman clipboard history.
# https://hg.sr.ht/~scoopta/wofi
home-manager.users.caspervk = {
programs.wofi = {
enable = true;
settings = {
show = "drun";
allow_images = true; # show icons
gtk_dark = true;
insensitive = true;
prompt = ""; # hides 'drun' text from the search bar
};
};
};
}