System/home-manager/linux/programs/hyprland.nix

311 lines
10 KiB
Nix
Raw Normal View History

2022-06-23 02:57:41 -04:00
{ config, lib, pkgs, inputs, ... }:
let nathan = config.nathan;
in with lib; {
config = mkIf nathan.programs.swaywm.enable (let
2023-04-20 16:22:21 -04:00
swaylock-package =
inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.swaylock-effects;
swaylock-command = ''
2023-04-20 16:22:21 -04:00
${swaylock-package}/bin/swaylock --screenshots --grace 30 --indicator --clock --timestr "%-I:%M:%S %p" --datestr "%A %Y-%M-%d" --effect-blur 20x3'';
2023-06-14 05:17:00 -04:00
fuzzel-command = ''
2023-06-16 20:27:37 -04:00
fuzzel -f "Iosevka Sans Quasi" -b "181818dd" -S "b9b9b9ff" -s "252525dd" -t "777777ff" -B 5 -r 5 -C "70b433dd"'';
2023-06-16 23:05:53 -04:00
notif-package =
inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.swaynotificationcenter;
in {
home.packages = with pkgs; [
# Locking and display management
wdisplays
2023-04-20 16:22:21 -04:00
swaylock-package
swayidle
# Clipboard
2023-06-16 20:20:58 -04:00
wl-clipboard
cliphist
# Notifications
2023-06-16 23:05:53 -04:00
notif-package
# Terminal
alacritty
# glib for sound stuff
glib
# Glpaper for the background
(glpaper.overrideAttrs (old: {
src = fetchFromSourcehut {
owner = "~scoopta";
repo = "glpaper";
vc = "hg";
2023-04-20 19:02:12 -04:00
rev = "14c158c495451bd9dbdc31a8dfc97388db5e7279";
hash = "sha256-jYOUmyXwTffzwUmYEY1SQx2ClZiRiMZLanveE9zWOLI=";
};
}))
# Screenshots
2023-06-16 21:29:47 -04:00
(inputs.hyprland-contrib.packages.${pkgs.system}.grimblast.override {
hyprland = config.wayland.windowManager.hyprland.package;
})
# fuzzel for launcher
fuzzel
# for image viewing
2022-10-29 20:06:49 -04:00
inputs.self.packages.${pkgs.system}.swayimg
2022-11-05 02:26:59 -04:00
# For private browsing
tor-browser-bundle-bin
2022-11-05 23:52:30 -04:00
# For non-emacs pdf reading
evince
2022-12-10 20:04:33 -05:00
# Productivity
libreoffice-fresh
2023-04-19 19:59:41 -04:00
## Sway addons
font-awesome
2023-06-14 05:32:23 -04:00
inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.hyprpaper
2023-06-16 18:59:16 -04:00
swayosd
2023-04-30 22:41:24 -04:00
# For fancy x11 scaling
2023-05-01 18:32:24 -04:00
sommelier
2023-04-30 23:36:49 -04:00
# Polkit
2023-06-13 23:21:21 -04:00
libsForQt5.polkit-kde-agent
2023-06-14 01:22:25 -04:00
polkit_gnome
];
#########################
2023-06-13 23:21:21 -04:00
## Hyprland
#########################
# Enable and configure hyperland
wayland.windowManager.hyprland = {
enable = true;
xwayland = {
enable = true;
2023-06-16 20:19:21 -04:00
hidpi = false;
2023-06-13 23:21:21 -04:00
};
recommendedEnvironment = true;
systemdIntegration = false;
2023-06-16 22:51:47 -04:00
extraConfig = builtins.readFile ../../../configs/hyprland.conf;
2023-06-13 23:21:21 -04:00
};
# systemd session target
# Specified manually so we can work around an issue with the loading
systemd.user.targets.hyprland-session = {
Unit = {
Description = "Hyprland compositor session";
Documentation = [ "man:systemd.special(7)" ];
BindsTo = [ "graphical-session.target" ];
Wants = [ "graphical-session-pre.target" ];
After = [ "graphical-session-pre.target" ];
};
};
#########################
2023-06-16 18:47:59 -04:00
## Hyprland Addons
2023-04-19 19:59:41 -04:00
#########################
2023-04-30 23:36:49 -04:00
# Setup polkit as a service
systemd.user.services.polkit-gnome = {
Unit = {
Description = "Polkit gnome authentication agent";
After = [ "graphical-session.target" ];
};
Service = {
Type = "simple";
ExecStart =
"${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1";
Restart = "on-failure";
};
Install = { WantedBy = [ "graphical-session.target" ]; };
2023-06-16 18:59:16 -04:00
};
# Setup swayosd as a service
systemd.user.services.swayosd = {
Unit = {
Description = "Swayosd";
After = [ "graphical-session.target" ];
};
Service = {
Type = "simple";
ExecStart = "${pkgs.swayosd}/bin/swayosd";
Restart = "on-failure";
};
Install = { WantedBy = [ "graphical-session.target" ]; };
2023-04-30 23:36:49 -04:00
};
2023-04-19 19:59:41 -04:00
#########################
2023-06-16 23:05:53 -04:00
## SwayNotificationCenter (notifications)
#########################
2023-06-16 23:05:53 -04:00
systemd.user.services.swaync = {
2023-04-19 18:45:52 -04:00
Unit = {
2023-06-16 23:05:53 -04:00
Description = "SwayNotificationCenter";
2023-04-19 18:45:52 -04:00
After = [ "graphical-session.target" ];
};
Service = {
Type = "simple";
2023-06-16 23:05:53 -04:00
ExecStart = "${notif-package}/bin/swaync";
Restart = "on-failure";
2023-04-19 18:45:52 -04:00
};
Install = { WantedBy = [ "graphical-session.target" ]; };
};
#########################
## Swayidle
#########################
services.swayidle = {
enable = true;
timeouts = [
# Lock the screen after 5 minutes of inactivity
{
timeout = 300;
command = builtins.replaceStrings [ "%" ] [ "%%" ] swaylock-command;
}
# Turn off the displays after 10 minutes of inactivity
{
timeout = 600;
command = ''swaymsg "output * dpms off"'';
resumeCommand = ''swaymsg "output * dpms on"'';
}
];
};
2023-06-14 01:22:25 -04:00
systemd.user.services.swayidle = {
Install = { WantedBy = [ "hyprland-session.target" ]; };
};
#########################
## Waybar
#########################
2023-06-16 23:05:53 -04:00
# https://github.com/DN-debug/waybar-examples/tree/main/waybar-examples/sway
programs.waybar = {
enable = true;
2023-06-14 05:17:00 -04:00
package =
inputs.nixpkgs-unstable.legacyPackages."${pkgs.system}".waybar.overrideAttrs
(old: { mesonFlags = old.mesonFlags ++ [ "-Dexperimental=true" ]; });
systemd = { enable = false; };
settings = {
mainBar = {
layer = "top";
2023-06-14 05:17:00 -04:00
position = "top";
height = 30;
spacing = 4;
margin-top = 5;
margin-bottom = 0;
# modules-left = [ "wlr/workspaces" "hyprland/submap" ];
# modules-center = [ "hyprland/window" ];
# modules-right = [ "mpd" "clock" "tray" ];
modules-center = [
"custom/launcher"
"wlr/workspaces"
"mpd"
# "hyprland/window"
"idle_inhibitor"
"pulseaudio"
"network"
"cpu"
"memory"
# "temperature"
"tray"
"clock"
# "custom/power"
];
"custom/launcher" = {
format = " ";
on-click = fuzzel-command;
on-click-right = "killall fuzzel";
};
"idle_inhibitor" = {
format = "{icon}";
format-icons = {
activated = "";
deactivated = "";
};
};
pulseaudio = {
scroll-step = 1;
format = "{volume}% {icon}";
format-bluetooth = "{volume}% {icon}";
format-bluetooth-muted = "{icon} {format_source}";
format-muted = "{format_source}";
format-source = "";
format-source-muted = "";
format-icons = {
headphone = "";
hands-free = "";
headset = "";
phone = "";
portable = "";
car = "";
default = [ "" "" "" ];
};
on-click = "pavucontrol";
};
network = {
# // "interface": "wlp2*", // (Optional) To force the use of this interface
format-wifi = "{essid} ({signalStrength}%) ";
format-ethernet = "Connected ";
tooltip-format = "{ifname} via {gwaddr} ";
format-linked = "{ifname} (No IP) ";
format-disconnected = "Disconnected ";
format-alt = "{ifname}: {ipaddr}/{cidr}";
on-click-right = "bash ~/.config/rofi/wifi_menu/rofi_wifi_menu";
};
cpu = {
format = "{usage}% ";
tooltip = false;
};
memory = { format = "{}% ({used}GB/{total}GB) "; };
"tray" = {
icon-size = 20;
spacing = 10;
};
"clock" = { format = "{:%I:%M%p %Y-%m-%d}"; };
"mpd" = {
format =
"{stateIcon} {consumeIcon}{randomIcon}{repeatIcon}{singleIcon}{artist} - {album} - {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S})";
format-disconnected = "Disconnected ";
format-stopped =
"{consumeIcon}{randomIcon}{repeatIcon}{singleIcon}Stopped ";
consume-icons = { on = "🍴"; };
random-icons = { on = "🔀"; };
repeat-icons = { on = "🔁"; };
state-icons = {
paused = "";
playing = "";
2022-07-03 00:33:57 -04:00
};
};
};
2022-07-02 21:32:06 -04:00
};
2023-06-16 22:51:47 -04:00
style = builtins.readFile ../../../configs/waybar.css;
};
# Override the service to run during graphical-session-pre.target
systemd.user.services.waybar = {
Unit = {
Description =
"Highly customizable Wayland bar for Sway and Wlroots based compositors.";
Documentation = "https://github.com/Alexays/Waybar/wiki";
Before = [ "tray.target" ];
};
2022-07-02 21:32:06 -04:00
Service = {
ExecStart = "${config.programs.waybar.package}/bin/waybar";
ExecReload = "${pkgs.coreutils}/bin/kill -SIGUSR2 $MAINPID";
2023-06-13 23:21:21 -04:00
ExecStartPost = "${pkgs.coreutils}/bin/sleep 1";
Restart = "on-failure";
KillMode = "mixed";
2022-06-23 02:57:41 -04:00
};
Install = { WantedBy = [ "graphical-session-pre.target" ]; };
};
#########################
## EasyEffects
#########################
services.easyeffects.enable = true;
#########################
## Create tray target to fix some things
#########################
systemd.user.targets.tray = {
Unit = {
Description = "Home Manager System Tray";
Requires = [ "graphical-session-pre.target" "waybar.service" ];
After = [ "waybar.service" ];
2022-09-18 20:25:20 -04:00
};
};
#########################
## Default applications
#########################
xdg.mimeApps.defaultApplications = {
# Make all supported images open in swayimg
"image/jpeg" = [ "swayimg.desktop" ];
"image/png" = [ "swayimg.desktop" ];
"image/gif" = [ "swayimg.desktop" ];
"image/svg+xml" = [ "swayimg.desktop" ];
"image/webp" = [ "swayimg.desktop" ];
"image/avif" = [ "swayimg.desktop" ];
"image/tiff" = [ "swayimg.desktop" ];
"image/bmp" = [ "swayimg.desktop" ];
2022-11-05 23:52:30 -04:00
"application/pdf" = [ "org.gnome.Evince.desktop" ];
2022-11-14 16:43:58 -05:00
"text/html" = [ "firefox.desktop" ];
};
});
2021-12-20 13:37:26 -05:00
}