Skip to content

Commit

Permalink
Nixify Hyprland config.
Browse files Browse the repository at this point in the history
  • Loading branch information
attilaolah committed Mar 4, 2024
1 parent e0a9d51 commit 1347f75
Show file tree
Hide file tree
Showing 25 changed files with 236 additions and 252 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ Other notable repos:
- [n3oney/nixus]
- [khaneliman/khanelinix]
- [stephenreynolds/nix-config]
- [3rfaan/arch-everforest]

[nixinator/nothing]: https://github.com/nixinator/nothing
[sjcobb2022/nixos-config]: https://github.com/sjcobb2022/nixos-config
[n3oney/nixus]: https://github.com/n3oney/nixus
[khaneliman/khanelinix]: https://github.com/khaneliman/khanelinix
[stephenreynolds/nix-config]: https://github.com/stephenreynolds/nix-config
[3rfaan/arch-everforest]: https://github.com/3rfaan/arch-everforest

See also [this comment][2], on how to use the config, or how to build it, even
for remote targets. Mind. Blown. 🤯
Expand Down
27 changes: 13 additions & 14 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,21 @@
nixpkgs,
nixos-unstable,
home-manager,
hyprland,
...
} @ inputs: {
nixosConfigurations = {
home = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
(import ./hosts/home/configuration.nix)
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.ao = import ./users/ao/home.nix;
}
];
specialArgs = {inherit inputs;};
};
nixosConfigurations.home = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
(import ./hosts/home/configuration.nix)
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.ao = import ./home-manager/home.nix;
}
];
specialArgs = {inherit inputs;};
};
};
}
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions users/ao/file.nix → home-manager/file.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
# ~/.config:
".config/fish/functions/fish_prompt.fish".source = ./src/_.config/fish/functions/fish_prompt.fish;
".config/foot/foot.ini".source = ./src/_.config/foot/foot.ini;
".config/hypr/hyprland.conf".source = ./src/_.config/hypr/hyprland.conf;
".config/hypr/hyprpaper.conf".source = ./src/_.config/hypr/hyprpaper.conf;
".config/nvim/init.lua".source = ./src/_.config/nvim/init.lua;
".config/wallpapers/alpeli-1020m.jpg".source = ./src/_.config/wallpapers/alpeli-1020m.jpg;
};
Expand Down
9 changes: 2 additions & 7 deletions users/ao/home.nix → home-manager/home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
./programs/fish.nix
./programs/git.nix
./programs/gpg.nix
./wayland/window_manager/hyprland.nix
./services/gpg_agent.nix
];

home = {
Expand All @@ -28,11 +30,4 @@
};

nixpkgs.config.allowUnfree = true;

services.gpg-agent = {
enable = true;
enableSshSupport = true;
defaultCacheTtl = 7200; # 2h
pinentryFlavor = "curses";
};
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions home-manager/services/gpg_agent.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
services.gpg-agent = {
enable = true;
enableSshSupport = true;
defaultCacheTtl = 7200; # 2h
pinentryFlavor = "curses";
};
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
130 changes: 130 additions & 0 deletions home-manager/wayland/window_manager/hyprland.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# ██╗ ██╗██╗ ██╗██████╗ ██████╗
# ██║ ██║╚██╗ ██╔╝██╔══██╗██╔══██╗
# ███████║ ╚████╔╝ ██████╔╝██████╔╝
# ██╔══██║ ╚██╔╝ ██╔═══╝ ██╔══██╗
# ██║ ██║ ██║ ██║ ██║ ██║
# ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝
{
config,
lib,
...
}: let
xkb = import ../../../hosts/home/services/xserver/xkb.nix {inherit lib;};
input = import ../../../hosts/home/hyprland/input.nix {config = xkb;};
monitors = import ../../../hosts/home/hyprland/monitors.nix {inherit lib;};
workspaces = [1 2 3 4 5 6 7 8];
in {
wayland.windowManager.hyprland = {
enable = true;
settings = {
inherit (input) input;
inherit (monitors) "$M1" "$M2" "$M3" "monitor" "workspace";

exec-once = [
monitors.exec-once
"waybar"
];

"$MENU" = "wofi --show run";
"$TERM" = "foot";
"$BROWSER" = "google-chrome-stable --enable-unsafe-webgpu";

general = {
allow_tearing = false;
border_size = 2;
gaps_in = 2;
gaps_out = 4;
layout = "dwindle";

"col.active_border" = "rgba(a7c080ff)";
"col.inactive_border" = "rgba(3d484dff)";
};

decoration = {
blur.enabled = false;
drop_shadow = true;
rounding = 2;
shadow_range = 8;
shadow_render_power = 3;

"col.shadow" = "rgba(1a1a1aee)";
};

animations = {
enabled = true;

bezier = "mybez, 0.05, 0.9, 0.1, 1.05";
animation = [
"windows, 1, 2, mybez"
"windowsOut, 1, 2, default, popin 80%"
"border, 1, 4, default"
"borderangle, 1, 4, default"
"fade, 1, 2, default"
"workspaces, 1, 4, default"
];
};

dwindle.preserve_split = true;

"$MOD" = "SUPER";

# Workspaces:
"$N1" = "ampersand";
"$N2" = "bracketleft";
"$N3" = "braceleft";
"$N4" = "braceright";
"$N5" = "parenleft";
"$N6" = "equal";
"$N7" = "asterisk";
"$N8" = "parenright";

bind =
[
"$MOD SHIFT, ESCAPE, exit,"
"$MOD, Return, exec, $TERM"
"$MOD, Space, togglefloating,"
"$MOD, Escape, killactive,"
"$MOD, A, exec, pavucontrol" # [a]udio
"$MOD, B, exec, $BROWSER" # [b]rowser
"$MOD, D, pseudo," # [d]windle
"$MOD, F, fullscreen," # [f]ullscrean
"$MOD, R, exec, $MENU" # [r]un
"$MOD, T, togglesplit," # [t]ile (dwindle)

# Move focus with MOD + arrow keys
"$MOD, left, movefocus, l"
"$MOD, right, movefocus, r"
"$MOD, up, movefocus, u"
"$MOD, down, movefocus, d"
"ALT, Tab, cyclenext, prev"
"ALT, Tab, bringactivetotop"
"ALT SHIFT, Tab, cyclenext, next"
"ALT SHIFT, Tab, bringactivetotop"

# Special workspace (scratchpad)
"$MOD, S, togglespecialworkspace, magic"
"$MOD SHIFT, S, movetoworkspace, special:magic"

# Scroll through existing workspaces with MOD + scroll
"$MOD, mouse_down, workspace, e+1"
"$MOD, mouse_up, workspace, e-1"
]
# Switch workspaces with MOD + num
++ (map (n: "$MOD, $N${toString n}, workspace, ${toString n}") workspaces)
# Move active window to a workspace with MOD + SHIFT + num
++ (map (n: "$MOD SHIFT, $N${toString n}, movetoworkspace, ${toString n}") workspaces);

bindm = [
# Move/resize windows with MOD + LMB/RMB and dragging
"$MOD, mouse:272, movewindow"
# TODO: Why does this not work any more?
"$MOD, mouse:273, resizewindow"
];

misc = {
disable_splash_rendering = true;
force_default_wallpaper = 0;
};
};
};
}
5 changes: 3 additions & 2 deletions hyprland/greet.conf → hosts/home/hyprland/greet.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ decoration {
}

misc {
background_color = 0x000000
disable_autoreload = true
disable_hyprland_logo = true
disable_splash_rendering = true
force_default_wallpaper = 0
background_color = 0x000000
mouse_move_enables_dpms = true
key_press_enables_dpms = true
mouse_move_enables_dpms = true
}
32 changes: 32 additions & 0 deletions hosts/home/hyprland/input.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{config, ...}: let
input = {
# Keyboard:
kb_layout = config.services.xserver.xkb.layout;
kb_variant = config.services.xserver.xkb.variant;
kb_options = config.services.xserver.xkb.options;
numlock_by_default = true;

# Mouse:
follow_mouse = 1;
touchpad.natural_scroll = false;
sensitivity = 0;
};
in {
inherit input;

# RAW Hyprland config, for hyprland.greet.conf.
hyprconf = with input; ''
input = {
# Keyboard:
kb_layout = ${kb_layout}
kb_variant = ${kb_variant}
kb_options = ${kb_options}
numlock_by_default = ${toString numlock_by_default}
# Mouse:
follow_mouse = ${toString follow_mouse}
touchpad:natural_scroll = ${toString touchpad.natural_scroll}
sensitivity = ${toString sensitivity}
}
'';
}
43 changes: 43 additions & 0 deletions hosts/home/hyprland/monitors.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{lib, ...}: let
# Monitor layout:
# ╔═══╗ ╔═══╗
# ║ L ║╔═══════╗║ D ║
# ║ E ║║ S A M ║║ E ║
# ║ N ║╚═══════╝║ L ║
# ╚═══╝ ╚═══╝
M1 = "Lenovo Group Limited P27h-20 V906V9HY";
M2 = "Samsung Electric Company U32J59x HNMW200264";
M3 = "Dell Inc. DELL P2720DC 81WTK01K1SFS";

monitor = [
"$M1, 2560x1440@60, 0x0, 1, transform, 1"
"$M2, 3840x2160@60, 1440x200, 1"
"$M3, 2560x1440@60, 5280x0, 1, transform, 3"
];

workspace = [
"1, monitor:$M1, default:true"
"2, monitor:$M2, default:true"
"3, monitor:$M3, default:true"
];

exec-once = "hyprctl dispatch focusmonitor $M2";
in {
"$M1" = "desc:${M1}";
"$M2" = "desc:${M2}";
"$M3" = "desc:${M3}";

inherit monitor workspace exec-once;

# RAW Hyprland config, for hyprland.greet.conf.
hyprconf = lib.concatStringsSep "\n" (
[
"$M1 = desc:${M1}"
"$M2 = desc:${M2}"
"$M3 = desc:${M3}"
]
++ (map (x: "monitor = ${x}") monitor)
++ (map (x: "workspace = ${x}") workspace)
++ ["exec-once = ${exec-once}"]
);
}
14 changes: 3 additions & 11 deletions hosts/home/services.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,13 @@
}: let
regreet = lib.getExe config.programs.regreet.package;
hyprland = inputs.hyprland.packages.${pkgs.system}.hyprland;
hyprland-keyboard = ''
input {
kb_layout = ${config.services.xserver.xkb.layout}
kb_variant = ${config.services.xserver.xkb.variant}
kb_options = ${config.services.xserver.xkb.options}
}
'';

# 1st Hyperland only runs "command" (regreet) and exits.
# ReGreet itself will then run a second session with the user's config.
hyprland-greet = "${hyprland}/bin/Hyprland --config ${pkgs.writeText "hyprland.greet.conf" ''
${hyprland-keyboard}
${(builtins.readFile ../../hyprland/input.conf)}
${(builtins.readFile ../../hyprland/monitors.conf)}
${(builtins.readFile ../../hyprland/greet.conf)}
${(builtins.readFile ./hyprland/greet.conf)}
${(import ./hyprland/input.nix {inherit config;}).hyprconf}
${(import ./hyprland/monitors.nix {inherit lib;}).hyprconf}
exec-once = ${regreet} -l debug; ${hyprland}/bin/hyprctl dispatch exit
''}";
in {
Expand Down
12 changes: 0 additions & 12 deletions hyprland/input.conf

This file was deleted.

19 changes: 0 additions & 19 deletions hyprland/monitors.conf

This file was deleted.

Loading

0 comments on commit 1347f75

Please sign in to comment.