feat(nix): extend wayland with sway setup

This commit is contained in:
steveej 2023-05-23 18:11:30 +02:00
parent 2da1181445
commit 6970b8c7d2
27 changed files with 867 additions and 516 deletions

View file

@ -1,5 +1,4 @@
{
inputs,
pkgs,
config,
# these come in via home-manager.extraSpecialArgs and are specific to each node
@ -18,13 +17,11 @@ in {
# ../profiles/gnome-desktop.nix
../profiles/sway-desktop.nix
../profiles/experimental-desktop.ni
# ../profiles/experimental-desktop.nix
../programs/redshift.nix
../programs/espanso.nix
../programs/gpg-agent.nix
../programs/radicale.nix
../programs/firefox.nix
../programs/chromium.nix
@ -33,6 +30,10 @@ in {
../programs/neovim.nix
../programs/pass.nix
../programs/vscode
# TODO: broken since nixos-23.05
# ../programs/radicale.nix
# ../programs/espanso.nix
];
home.sessionVariables.HM_CONFIG = "graphical-fullblown";
@ -47,7 +48,6 @@ in {
};
};
home.packages =
[]
++ (with pkgs; [
@ -79,7 +79,6 @@ in {
# Archive Managers
sshfs-fuse
xarchive
p7zip
zip
unzip
@ -92,16 +91,15 @@ in {
yubikey-manager-qt
yubikey-personalization
yubikey-personalization-gui
gnome.gnome-keyring
# gnome.seahorse
# gnome.gnome-keyring
gcr gnome.seahorse
# Language Support
hunspellDicts.en-us
hunspellDicts.de-de
# Messaging/Communication
signal-desktop
pkgsUnstable.session-desktop
# pidgin
hexchat
schildichat-desktop
@ -111,11 +109,13 @@ in {
# pkgsUnstable.jitsi-meet-electron
thunderbird
evolution # gnome4.glib_networking
kotatogram-desktop
zoom-us
# FIXME: depends on insecure openssl 1.1.1t
# kotatogram-desktop
thunderbird
gnome.cheese
pkgsMaster.discord
# gnome.cheese
pkgsUnstable.discord
# Virtualization
# virtmanager
@ -181,7 +181,8 @@ in {
# Document Processing and Management
mendeley
evince
(pkgsUnstable.logseq.override (_: {electron = pkgs.electron_20;}))
pkgsUnstable.logseq
# (pkgsUnstable.logseq.override (_: {electron = pkgs.electron_20;}))
# File Synchronzation
dropbox

View file

@ -12,17 +12,9 @@ in {
../profiles/wayland-desktop.nix
];
home.packages = with pkgs; [
home.packages = [
# experimental WMs
packages'.jay
packages'.magmawm
# swayidle
# swaylock
# # fonts
# noto-fonts
# font-awesome
# noto-fonts-emoji
];
}

View file

@ -13,6 +13,7 @@ in {
gnome-keyring.enable = false;
blueman-applet.enable = true;
flameshot.enable = true;
pasystray.enable = true;
};
# TODO: remove this comment once i'm sure everything works

View file

@ -2,38 +2,139 @@
pkgs,
config,
lib,
packages',
...
}: let
inherit (import ../lib.nix {}) mkSimpleTrayService;
lockCmd = "${pkgs.swaylock}/bin/swaylock -efF --color '#000000'";
displayOffCmd = "${pkgs.sway}/bin/swaymsg 'output * power off'";
displayOnCmd = "${pkgs.sway}/bin/swaymsg 'output * power on'";
swapOutputWorkspaces = ../../../scripts/sway-swapoutputworkspaces.sh;
in {
imports = [
../profiles/wayland-desktop.nix
../programs/waybar.nix
../programs/salut.nix
];
home.packages = with pkgs; [
swayidle
swaylock
services = {
blueman-applet.enable = true;
flameshot.enable = true;
};
home.packages = [
pkgs.swayidle
pkgs.swaylock
packages'.yofi
pkgs.fuzzel
# required by any bar that has a tray plugin
pkgs.libappindicator-gtk3
## themes
pkgs.gnome.adwaita-icon-theme
pkgs.hicolor-icon-theme
pkgs.gnome-icon-theme
## fonts
pkgs.dejavu_fonts # just a basic good fond
pkgs.font-awesome_5 # needed by i3status-rust
pkgs.nerdfonts
pkgs.font-awesome
pkgs.roboto
pkgs.ttf_bitstream_vera
# from the wiki
pkgs.noto-fonts
pkgs.noto-fonts-cjk
pkgs.noto-fonts-cjk-sans
pkgs.noto-fonts-cjk-serif
pkgs.noto-fonts-emoji
pkgs.noto-fonts-emoji-blob-bin
pkgs.noto-fonts-extra
pkgs.noto-fonts-lgc-plus
pkgs.liberation_ttf
pkgs.fira-code
pkgs.fira-code-symbols
pkgs.mplus-outline-fonts.githubRelease
pkgs.dina-font
pkgs.monoid
pkgs.hermit
# by colemickens
pkgs.gelasio # metric-compatible with Georgia
pkgs.powerline-symbols
pkgs.iosevka-comfy.comfy-fixed
# fonts
noto-fonts
font-awesome
noto-fonts-emoji
];
wayland.windowManager.sway = {
enable = true;
systemdIntegration = true;
xwayland = false;
config = let
modifier = "Mod4";
inherit (config.wayland.windowManager.sway.config) left right up down;
in {
inherit modifier;
bars = [];
input = {
"type:keyboard" = {
xkb_layout = "us";
xkb_variant = "altgr-intl";
xkb_options = "nodeadkeys";
};
"type:touchpad" = {
natural_scroll = "enabled";
};
};
keybindings = lib.mkOptionDefault {
"${modifier}+Ctrl+l" = "exec ${pkgs.swaylock}/bin/swaylock -fF";
"XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl play-pause";
# as of 2023-05-21 the `!!` arg parsing mode was broken for me on yofi
# "${modifier}+d" = "exec ${packages'.yofi}/bin/yofi binapps";
"${modifier}+d" = "exec ${pkgs.fuzzel}/bin/fuzzel";
# only 1-9 exist on the default config
"${modifier}+0" = "workspace number 0";
"${modifier}+Shift+0" = "move container to workspace number 0";
# move workspace to output
"${modifier}+Control+Shift+${left}" = "move workspace to output left";
"${modifier}+Control+Shift+${right}" = "move workspace to output right";
"${modifier}+Control+Shift+${up}" = "move workspace to output up";
"${modifier}+Control+Shift+${down}" = "move workspace to output down";
# move workspace to output with arrow keys
"${modifier}+Control+Shift+Left" = "move workspace to output left";
"${modifier}+Control+Shift+Right" = "move workspace to output right";
"${modifier}+Control+Shift+Up" = "move workspace to output up";
"${modifier}+Control+Shift+Down" = "move workspace to output down";
"${modifier}+Shift+e" = "exec swaymsg exit";
"${modifier}+q" = "kill";
"${modifier}+x" = "exec ${swapOutputWorkspaces}";
"${modifier}+Ctrl+l" = "exec ${lockCmd}";
"--locked XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl play-pause";
"XF86AudioPrev" = "exec ${pkgs.playerctl}/bin/playerctl previous";
"XF86AudioNext" = "exec ${pkgs.playerctl}/bin/playerctl next";
"XF86AudioRaiseVolume" = "exec ${pkgs.pulsemixer}/bin/pulsemixer --change-volume +5";
"XF86AudioLowerVolume" = "exec ${pkgs.pulsemixer}/bin/pulsemixer --change-volume -5";
"--locked XF86AudioMute" = "exec ${pkgs.pulsemixer}/bin/pulsemixer --toggle-mute";
# TODO: screenshot util, flameshot doesn't work in the packaged version
"Print" = "exec ${pkgs.flameshot}/bin/flameshot gui";
};
terminal = "alacritty";
@ -41,44 +142,33 @@ in {
# Launch Firefox on start
# {command = "firefox";}
# {command = "gnome-keyring --replace"}
{command = "systemctl --user restart waybar";}
];
fonts = {
names = [ "Noto Sans" "Font Awesome 5 Free" ];
style = "Heavy";
size = 10.0;
colors.focused = lib.mkOptionDefault {
childBorder = lib.mkForce "#ffa500";
};
#fonts = {
# names = [ "DejaVu Sans Mono" "FontAwesome5Free" ];
# style = "Bold Semi-Condensed";
# size = 11.0;
#};
colors.focused = {
childBorder = "#ffa500";
# border = "#ffa500";
# TODO: refer to the defaults for these
border = "#4c7899";
background = "#285577";
text = "#ffffff";
indicator = "#2e9ef4";
};
window = {
border = 4;
};
window.border = 4;
};
};
services.swayidle = {
enable = true;
timeouts = [
{ timeout = 60 * 5; command = "${pkgs.swaylock}/bin/swaylock -fF"; }
{ timeout = 10; command = "if ${pkgs.procps}/bin/pgrep -x swaylock; then ${displayOffCmd}; fi"; resumeCommand = displayOnCmd; }
{ timeout = 60 * 5; command = lockCmd; }
{ timeout = 60 * 6; command = displayOffCmd; resumeCommand = displayOnCmd; }
];
events = [
{ event = "before-sleep";
command = builtins.concatStringsSep "; " [
lockCmd
"${pkgs.playerctl}/bin/playerctl pause"
];
}
{ event = "after-resume"; command = displayOnCmd; }
{ event = "lock"; command = lockCmd; }
];
};
}

View file

@ -1,19 +1,34 @@
{
pkgs,
config,
lib,
repoFlake,
nodeFlake,
...
}: let
inherit (import ../lib.nix {}) mkSimpleTrayService;
nixpkgs-2211 = nodeFlake.inputs.nixpkgs-2211.legacyPackages.${pkgs.system};
nixpkgs-wayland' = repoFlake.inputs.nixpkgs-wayland.packages.${pkgs.system};
wayprompt = nixpkgs-wayland'.wayprompt;
in {
services.gpg-agent.pinentryFlavor = "gtk2";
fonts.fontconfig.enable = true;
# services.gpg-agent.pinentryFlavor = lib.mkForce null;
# services.gpg-agent.extraConfig = ''
# pinentry-program "${wayprompt}/bin/pinentry-wayprompt"
# '';
home.packages = with pkgs; [
wlr-randr
wayout
wl-clipboard
wmctrl
wayprompt
nixpkgs-wayland'.shotman
# identifies key input syms
wev
@ -25,6 +40,35 @@ in {
pasystray
qt5.qtwayland
qt6.qtwayland
# probably required by flameshot
# xdg-desktop-portal xdg-desktop-portal-wlr
# grim
(signal-desktop.overrideAttrs (old: {
preFixup = old.preFixup + ''
gappsWrapperArgs+=(
--add-flags "--enable-features=UseOzonePlatform"
--add-flags "--ozone-platform=wayland"
)
'';
}))
((pkgs.session-desktop.override (old: {
inherit (nixpkgs-2211) appimageTools;
}))
.overrideAttrs(old: {
nativeBuildInputs = old.nativeBuildInputs ++ [
pkgs.wrapGAppsHook
];
preFixup = (old.preFixup or "") + ''
gappsWrapperArgs+=(
--add-flags "--enable-features=UseOzonePlatform"
--add-flags "--ozone-platform=wayland"
)
'';
}))
];
home.sessionVariables = {

View file

@ -1,4 +1,8 @@
{lib, ...}: {
{lib, pkgs, ...}: {
home.packages = [
pkgs.gcr
];
programs.gpg.enable = true;
services.gpg-agent = {
enable = true;

View file

@ -14,6 +14,11 @@
inherit pname version;
hash = "sha256-Mukjzjumv9VL+A0maU0K/SliWrgeRjAeiEdN5a83G0I=";
};
propagatedBuildInputs = [
pkgs.libxcrypt-legacy
];
};
radicale-storage-decsync = pkgs.python3Packages.buildPythonPackage rec {
pname = "radicale_storage_decsync";
@ -24,7 +29,17 @@
hash = "sha256-X+0MT5o2PjsKxca5EDI+rYyQDmUtbRoELDr6e4YXKCg=";
};
buildInputs = [pkgs.radicale];
buildInputs = [
pkgs.radicale
pkgs.libxcrypt-legacy
pkgs.libxcrypt
];
nativeCheckInputs = [
pkgs.libxcrypt-legacy
pkgs.libxcrypt
];
propagatedBuildInputs = [libdecsync pkgs.python3Packages.setuptools];
};
radicale-decsync = pkgs.radicale.overrideAttrs (old: {

View file

@ -0,0 +1,17 @@
{
pkgs,
config,
lib,
packages',
...
}: {
home.packages = [
packages'.salut
];
home.file.".config/salut/config.ini" = {
enable = true;
text = ''
'';
};
}

View file

@ -1,196 +1,81 @@
{ pkgs, config, inputs, ... }:
{ pkgs, config, repoFlake, ... }:
let
rogScript = pkgs.writeShellScript "waybar-rog.sh" ''
set -euo pipefail
val="$(${pkgs.asusctl}/bin/asusctl profile -p)"
if [[ "''${val}" == *"Performance"* ]]; then
echo $'{"text": "rog prf"}';
elif [[ "''${val}" == *"Balanced"* ]]; then
echo $'{"text": "rog bal"}';
elif [[ "''${val}" == *"Quiet"* ]]; then
echo $'{"text": "rog qui"}';
fi
'';
pppScript = pkgs.writeShellScript "waybar-ppp.sh" ''
set -euo pipefail
val="$(${pkgs.power-profiles-daemon}/bin/powerprofilesctl get)"
if [[ "''${val}" == "performance" ]]; then
echo $'{"text": "ppp prf"}';
elif [[ "''${val}" == "balanced" ]]; then
echo $'{"text": "ppp bal"}';
elif [[ "''${val}" == "power-saver" ]]; then
echo $'{"text": "ppp pwr"}';
fi
'';
extraModules = if config.networking.hostName != "zeph" then { } else {
"custom/rog" = {
exec = "${rogScript}";
return-type = "json";
interval = 10;
};
"custom/ppp" = {
exec = "${pppScript}";
return-type = "json";
interval = 10;
};
};
# # jobpath = "/run/user/1000/srht/jobs";
# # jobs = {
# # "niche" = "niche";
# # "n-w" = "nixpkgs-wayland";
# # "f-f-n" = "flake-firefox-nightly";
# # };
# # suffix = pkgs.lib.mapAttrsToList (k: v: ''
# # status="$("${pkgs.jq}/bin/jq" -r '[.results[] | select(.tags=="${v}" and .status!="running" and .status!="cancelled")][0] | .status' "${jobpath}/data")"
# # echo "{\"text\":\"''${status}\", \"class\":\"srht-''${status}\"}" > "${jobpath}/${v}-json"
# # '') jobs;
# # jobsScript = pkgs.writeShellScriptBin "jobs.sh" (pkgs.lib.concatStrings (
# # [''
# # TOKEN=$(cat ${config.sops.secrets."srht-pat".path})
# # BUILD_HOST="https://builds.sr.ht"
# # "${pkgs.coreutils}/bin/mkdir" -p "${jobpath}"
# # "${pkgs.curl}/bin/curl" \
# # -H "Authorization:token ''${TOKEN}" \
# # -H "Content-Type: application/json" -X GET \
# # "''${BUILD_HOST}/api/jobs" > "${jobpath}/data"
# # ''] ++ suffix ));
# networktoggle = pkgs.writeShellScriptBin "networktoggle.sh" ''
# if ip link | grep wlan; then
# sudo ${pkgs.util-linux}/bin/rfkill toggle wlan
# sudo ${pkgs.systemd}/bin/networkctl reconfigure wlan0
# ${pkgs.libnotify}/bin/notify-send "toggled wlan0"
# else
# ${pkgs.libnotify}/bin/notify-send "no wlan to toggle"
# fi
# '';
in
{
config = {
# sops.secrets."srht-pat" = {
# owner = "cole";
# group = "cole";
# };
programs.waybar = {
enable = true;
package = repoFlake.inputs.nixpkgs-wayland.outputs.packages.${pkgs.stdenv.hostPlatform.system}.waybar;
# style = pkgs.lib.readFile ./waybar.css;
systemd.enable = true;
settings = {
mainBar = {
layer = "top";
position = "bottom";
height = 30;
output = ["*"];
# output = [
# "eDP-1"
# "DP-*"
# ];
home-manager.users.cole = { pkgs, ... }: {
# systemd.user.services."srht-jobs-status" = {
# Unit.Description = "check srht-jobs status";
# Service = {
# Type = "oneshot";
# ExecStart = "${jobsScript}/bin/jobs.sh";
# };
# };
# systemd.user.timers."srht-jobs-status" = {
# Unit.Description = "check srht jobs status";
# Timer = { OnBootSec = "1m"; OnUnitInactiveSec = "1m"; Unit = "srht-jobs-status.service"; };
# Install.WantedBy = [ "default.target" ];
# # {
# # wantedBy = [ "timers.target" ];
# # partOf = [ "srht-${repo}.service" ];
# # timerConfig.OnCalendar = "hourly";
# # }
# };
home.packages = [ pkgs.libappindicator-gtk3 ];
programs.waybar = {
enable = true;
package = inputs.nixpkgs-wayland.outputs.packages.${pkgs.stdenv.hostPlatform.system}.waybar;
style = pkgs.lib.readFile ./waybar.css;
systemd.enable = true;
settings = [{
# ipc = true;
layer = "top";
# position = "top";
modules-left = [
"sway/mode"
"sway/workspaces"
];
modules-center = [
"wlr/workspaces"
];
modules-right = [
# "keyboard-state"
# "idle_inhibitor"
"pulseaudio"
"backlight"
"tray"
]
++ (builtins.attrNames extraModules)
++ [
"cpu"
"memory"
"network"
"temperature"
"battery"
"clock"
"clock#date"
];
modules-left = [
"sway/workspaces"
"sway/mode"
# "wlr/taskbar"
];
modules = ({
"sway/workspaces" = {
all-outputs = true;
disable-scroll-wraparound = true;
#enable-bar-scroll = true;
};
"sway/mode" = { tooltip = false; };
"sway/workspaces" = {
disable-scroll = true;
all-outputs = false;
};
modules-center = [
"sway/window"
# "custom/hello-from-waybar"
];
# # TODO:
# keyboard-state = {
# "numlock" = true;
# "capslock" = true;
# "format" = "{name} {icon}";
# "format-icons" = {
# "locked" = "+";
# "unlocked" = "-";
# };
# };
"wlr/taskbar" = { };
temperature = {
format = "tmp {temperatureC}";
};
idle_inhibitor = {
format = "iil {icon}";
format-icons = {
activated = "[x]";
deactivated = "[ ]";
};
};
pulseaudio = {
format = "vol {volume}";
on-click-middle = "${pkgs.sway}/bin/swaymsg exec \"${pkgs.pavucontrol}/bin/pavucontrol\"";
};
network = {
format-wifi = "net {signalStrength}";
format-ethernet = "eth";
};
cpu.interval = 2;
cpu.format = "cpu {usage}";
memory.format = "mem {}";
backlight = {
format = "nit {percent}";
on-scroll-up = "${pkgs.brightnessctl}/bin/brightnessctl set 2%+";
on-scroll-down = "${pkgs.brightnessctl}/bin/brightnessctl set 2%-";
};
tray.spacing = 10;
# battery
clock = {
format = "{:%d %b %Y}";
};
"clock#date" = {
format = "{:%H:%M %p}";
};
battery = {
format = "bat {}";
states = {
warning = 25;
critical = 15;
};
};
} // extraModules);
}];
modules-right = [
"tray"
"cpu"
"memory"
"temperature"
"custom/fan"
"battery"
"pulseaudio"
"clock"
"clock#date"
];
tray.spacing = 10;
cpu.format = " {}%";
memory.format = " {}%";
"temperature" = {
hwmon-path = "/sys/class/hwmon/hwmon3/temp1_input";
format = " {temperatureC} °C";
};
"custom/fan" = {
format = " {} rpm ";
exec = "${pkgs.lm_sensors}/bin/sensors | ${pkgs.gawk}/bin/awk '/fan1:/ {print $2}'";
interval = 5;
};
battery.format = "🔋 {}%";
pulseaudio = {
format = "🔉 {volume}%";
# on-click-middle = ''${pkgs.sway}/bin/swaymsg exec "${pkgs.pavucontrol}/bin/pavucontrol"'';
};
"clock#date".format = "{:%d %b %Y}";
clock.format = "{:%H:%M %p}";
# "custom/hello-from-waybar" = {
# format = "hello {}";
# max-length = 40;
# interval = "once";
# exec = pkgs.writeShellScript "hello-from-waybar" ''
# echo "from within waybar"
# '';
# };
};
};
};

View file

@ -74,7 +74,7 @@ in {
# don't cd into directories when executed
unsetopt AUTO_CD
export NIX_PATH="${pkgs.path}"
export NIX_PATH="nixpkgs=${pkgs.path}"
# print lines without termination
setopt PROMPT_CR