Initial nixos config

This commit is contained in:
Aleksandr Lebedev 2024-11-07 12:35:29 +01:00
commit ebe17adca7
17 changed files with 2044 additions and 0 deletions

View file

@ -0,0 +1,61 @@
{ pkgs, lib, ... }:
let
suspendScript = pkgs.writeShellScript "suspend-script" ''
# check if any player has status "Playing"
${lib.getExe pkgs.playerctl} -a status | ${lib.getExe pkgs.ripgrep} Playing -q
# only suspend if nothing is playing
if [ $? == 1 ]; then
loginctl lock-session
${pkgs.systemd}/bin/systemctl suspend
fi
'';
in
{
services.hypridle = {
enable = true;
settings = {
general = {
lock_cmd="pidof hyprlock || hyprlock";
before_sleep_cmd = "loginctl lock-session"; # lock before suspend.
after_sleep_cmd = "hyprctl dispatch dpms on"; # to avoid having to press a key twice to turn on the display.
ignore_dbus_inhibit = false;
};
listener = [
#{
# on-resume="brightnessctl -r"; # monitor backlight restore.
# on-timeout="brightnessctl -s set 10"; # set monitor backlight to minimum, avoid 0 on OLED monitor.
# timeout=240;
#}
#{
# on-resume="brightnessctl -rd rgb:kbd_backlight";
# on-timeout="brightnessctl -sd rgb:kbd_backlight set 0";
# timeout=300;
#}
{
on-timeout="notify-send \"You're idle. Locking in 30 seconds.\"";
timeout=830;
}
#{
# on-timeout="loginctl lock-session";
# timeout=360;
#}
{
on-timeout = suspendScript.outPath;
timeout = 900;
}
#{
# on-resume="hyprctl dispatch dpms on"; # screen on when activity is detected after timeout has fired.
# on-timeout="hyprctl dispatch dpms off"; # screen off when timeout has passed
# timeout=420;
#}
];
};
};
}

199
nixos/hyprland/hyprland.nix Normal file
View file

@ -0,0 +1,199 @@
{ pkgs, lib, ... }:
let
toggle_monitors = ./toggle_monitors.sh;
wallpaper-image = ./wallpaper.jpg;
in
{
imports = [
./waybar.nix
./hyprlock.nix
./hypridle.nix
];
wayland.windowManager.hyprland = {
enable = true;
xwayland.enable = true;
settings = {
monitor = [
"DP-1,2560x1440@75,1600x0,1.6"
"DP-3,2560x1440@75,0x0,1.6"
];
xwayland = {
force_zero_scaling = true;
};
exec-once = [
"waybar &"
"nm-applet &"
"swaync &"
"solaar -w hide &"
"hypridle &"
"${pkgs.polkit-kde-agent}/libexec/polkit-kde-authentication-agent-1 &" #https://nixos.wiki/wiki/Polkit
"clipse -listen &"
"swww-daemon &"
"${pkgs.swww}/bin/swww img ${wallpaper-image} &"
];
exec = [
"${pkgs.swww}/bin/swww img ${wallpaper-image} &"
];
"$mod" = "SUPER";
"$mainMod" = "$mod";
"$terminal" = "${pkgs.kitty}/bin/kitty";
"$fileManager" = "dolphin";
"$browser" = "firefox";
"$menu" = "wofi --show drun";
"$clipboardManager" = "$terminal --class clipse -e 'clipse'";
"$makeRegionScreenshot" = "grim -g \"$(slurp -w 0)\" - | satty --early-exit --copy-command 'wl-copy' --filename '-' --initial-tool brush";
bind = [
"$mod, T, exec, $terminal"
"$mod, Q, killactive,"
"$mod, M, exit,"
"$mod, B, exec, $browser"
"$mod SHIFT, V, togglefloating,"
"$mod, C, exec, $fileManager"
"$mod, F, fullscreen,"
"$mod, R, exec, $menu"
"$mod, V, exec, $clipboardManager"
"$mod SHIFT, I, exec, source ${toggle_monitors}"
"$mod SHIFT, O, exec, hyprctl dispatch dpms on"
# Move focus with mainMod + arrow keys
"$mod, H, movefocus, l"
"$mod, L, movefocus, r"
"$mod, K, movefocus, u"
"$mod, J, movefocus, d"
# Switch workspaces with mainMod + [0-9]
"$mainMod, 1, workspace, 1"
"$mainMod, 2, workspace, 2"
"$mainMod, 3, workspace, 3"
"$mainMod, 4, workspace, 4"
"$mainMod, 5, workspace, 5"
"$mainMod, 6, workspace, 6"
"$mainMod, 7, workspace, 7"
"$mainMod, 8, workspace, 8"
"$mainMod, 9, workspace, 9"
"$mainMod, 0, workspace, 10"
# Move active window to a workspace with mainMod + SHIFT + [0-9]
"$mainMod SHIFT, 1, movetoworkspace, 1"
"$mainMod SHIFT, 2, movetoworkspace, 2"
"$mainMod SHIFT, 3, movetoworkspace, 3"
"$mainMod SHIFT, 4, movetoworkspace, 4"
"$mainMod SHIFT, 5, movetoworkspace, 5"
"$mainMod SHIFT, 6, movetoworkspace, 6"
"$mainMod SHIFT, 7, movetoworkspace, 7"
"$mainMod SHIFT, 8, movetoworkspace, 8"
"$mainMod SHIFT, 9, movetoworkspace, 9"
"$mainMod SHIFT, 0, movetoworkspace, 10"
# Swap Windows
"$mainMod SHIFT, H, swapwindow, l"
"$mainMod SHIFT, L, swapwindow, r"
"$mainMod SHIFT, K, swapwindow, u"
"$mainMod SHIFT, J, swapwindow, d"
#Resize Windows
"$mainMod CTRL, H, resizeactive, -50 0"
"$mainMod CTRL, L, resizeactive, 50 0"
"$mainMod CTRL, K, resizeactive, 0 -50"
"$mainMod CTRL, J, resizeactive, 0 50"
"$mainMod, P, exec, $makeRegionScreenshot"
"$mainMod ALT, L, exec, hyprlock"
];
bindm = [
"$mod, mouse:272, movewindow"
"$mod, mouse:273, resizewindow"
];
input = {
kb_layout = "us, ru";
kb_options = "grp:caps_toggle";
};
env = [
"LIBVA_DRIVER_NAME,nvidia"
"XDG_SESSION_TYPE,wayland"
"GBM_BACKEND,nvidia-drm"
"__GLX_VENDOR_LIBRARY_NAME,nvidia"
"NVD_BACKEND,direct"
"XCURSOR_SIZE,24"
"HYPRCURSOR_SIZE,24"
"__GL_GSYNC_ALLOWED,1"
"QT_QPA_PLATFORM,wayland"
#"QT_QPA_PLATFORMTHEME,kde"
#"QT_STYLE_OVERRIDE,Breeze"
#"GDK_SCALE,1.6"
#"QT_SCALE_FACTOR,1.6"
];
cursor = {
no_hardware_cursors = true;
};
general = {
gaps_in = 5;
gaps_out = 20;
border_size = 2;
#"col.active_border" = "rgba(33ccffee) rgba(00ff99ee) 45deg";
#"col.inactive_border" = "rgba(595959aa)";
resize_on_border = false;
allow_tearing = false;
layout = "dwindle";
};
windowrulev2 = [
# Ignore maximize requests from apps. You'll probably like this.
"suppressevent maximize, class:.*"
# Fix some dragging issues with XWayland
"nofocus,class:^$,title:^$,xwayland:1,floating:1,fullscreen:0,pinned:0"
# Fix for issues with steam
"stayfocused, title:^()$,class:^(steam)$"
"minsize 1 1, title:^()$,class:^(steam)$"
#for clipboard manager
"float,class:(clipse)"
"size 622 652,class:(clipse)" # set the size of the window as necessary
];
decoration = {
rounding = 10;
active_opacity = 0.9;
inactive_opacity = 0.7;
drop_shadow = true;
shadow_range = 4;
shadow_render_power = 3;
#"col.shadow" = "rgba(1a1a1aee)";
blur = {
enabled = true;
size = 3;
passes = 1;
vibrancy = 0.1696;
};
};
animations = {
enabled = true;
bezier = "myBezier, 0.05, 0.9, 0.1, 1.05";
animation = [
"windows, 1, 7, myBezier"
"windowsOut, 1, 7, default, popin 80%"
"border, 1, 10, default"
"borderangle, 1, 8, default"
"fade, 1, 7, default"
"workspaces, 1, 6, default"
];
};
};
};
}

View file

@ -0,0 +1,58 @@
{ pkgs, lib, ... }:
{
programs.hyprlock = {
enable = true;
settings = {
background = {
monitor = {
#path = /home/me/someImage.png # supports png, jpg, webp (no animations, though)
color = "rgba(25, 20, 20, 1.0)";
# all these options are taken from hyprland, see https://wiki.hyprland.org/Configuring/Variables/#blur for explanations
blur_passes = 0; # 0 disables blurring
blur_size = 7;
noise = 0.0117;
contrast = 0.8916;
brightness = 0.8172;
vibrancy = 0.1696;
vibrancy_darkness = 0.0;
};
};
input-field = {
monitor = {
size = "200, 50";
outline_thickness = 3;
dots_size = 0.33; # Scale of input-field height, 0.2 - 0.8
dots_spacing = 0.15; # Scale of dots' absolute size, -1.0 - 1.0
dots_center = false;
dots_rounding = -1; # -1 default circle, -2 follow input-field rounding
dots_fade_time = 200; # Milliseconds until a dot fully fades in
dots_text_format = "";# Text character used for the input indicator. Leave empty for a rectangle that will be rounded via dots_rounding (default).
outer_color = "rgb(151515)";
inner_color = "rgb(200, 200, 200)";
font_color = "rgb(10, 10, 10)";
font_family = "Noto Sans"; # Font used for placeholder_text, fail_text and dots_text_format.
fade_on_empty = false;
fade_timeout = 1000; # Milliseconds before fade_on_empty is triggered.
placeholder_text = "<i>Input Password...</i>"; # Text rendered in the input box when it's empty.
hide_input = false;
rounding = -1; # -1 means complete rounding (circle/oval)
check_color = "rgb(204, 136, 34)";
fail_color = "rgb(204, 34, 34)"; # if authentication failed, changes outer_color and fail message color
fail_text = "<i>$FAIL <b>($ATTEMPTS)</b></i>"; # can be set to empty
fail_timeout = 2000; # milliseconds before fail_text and fail_color disappears
fail_transition = 300; # transition time in ms between normal outer_color and fail_color
capslock_color = -1;
numlock_color = -1;
bothlock_color = -1; # when both locks are active. -1 means don't change outer color (same for above)
invert_numlock = false; # change color if numlock is off
swap_font_color = false; # see below
position = "0, -20";
halign = "center";
valign = "center";
};
};
};
};
}

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkMenu" id="menu">
<child>
<object class="GtkMenuItem" id="suspend">
<property name="label">⏾ Sleep</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="hibernate">
<property name="label">󱦟 Hibernate</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="shutdown">
<property name="label">󰐥 Shutdown</property>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="delimiter1"/>
</child>
<child>
<object class="GtkMenuItem" id="reboot">
<property name="label"> Reboot</property>
</object>
</child>
</object>
</interface>

View file

@ -0,0 +1,12 @@
#!/bin/bash
# Получаем информацию о подключенных мониторах
monitors_on=$(hyprctl monitors | grep "dpmsStatus: 1" | wc -l)
echo $monitors_on
if [ $monitors_on -gt 0 ]; then
# Если мониторы включены, выключаем их
hyprctl dispatch dpms off
else
hyprctl dispatch dpms on
fi

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 MiB

167
nixos/hyprland/waybar.nix Normal file
View file

@ -0,0 +1,167 @@
{ pkgs, lib, ... }:
{
programs.waybar = {
enable = true;
#systemd.enable = true;
#window#waybar {
# background: transparent;
#border-bottom: none;
#}
#${builtins.readFile "${pkgs.waybar}/etc/xdg/waybar/style.css"}
style = ''
${builtins.readFile ./waybarstyle.css}
* {
font-size: 15px;
}
'';
settings = [{
height = 20;
layer = "top";
position = "top";
tray = { spacing = 3; };
modules-center = [
#"hyprland/window"
"clock"
];
modules-left = [ "hyprland/workspaces" ];
modules-right = [
"pulseaudio"
"network"
#"cpu"
#"memory"
#"temperature"
"hyprland/language"
] #++ (if config.hostId == "yoga" then [ "battery" ] else [ ])
++ [
"tray"
"custom/notification"
#"custom/disablehypridle"
"custom/power"
];
battery = {
format = "{capacity}% {icon}";
format-alt = "{time} {icon}";
format-charging = "{capacity}% ";
format-icons = [ "" "" "" "" "" ];
format-plugged = "{capacity}% ";
states = {
critical = 15;
warning = 30;
};
};
clock = {
format-alt = "{:%Y-%m-%d}";
tooltip-format = "{:%Y-%m-%d | %H:%M}";
};
cpu = {
format = "{usage}% ";
tooltip = false;
};
"hyprland/language" = {
format = " {}";
};
memory = { format = "{}% "; };
network = {
interval = 1;
format-alt = "{ifname}: {ipaddr}/{cidr}";
format-disconnected = "Disconnected ";
format-ethernet = "{ifname}: {ipaddr}/{cidr} up: {bandwidthUpBits} down: {bandwidthDownBits}";
format-linked = "{ifname} (No IP) ";
#format-wifi = "{signalStrength}% ";
format-wifi = "{signalStrength}% ";
tooltip-format = "{essid} ({signalStrength}%) ";
};
pulseaudio = {
format = "{volume}% {icon} {format_source}";
format-bluetooth = "{volume}% {icon} {format_source}";
format-bluetooth-muted = " {icon} {format_source}";
format-icons = {
car = "";
default = [ "" "" "" ];
handsfree = "";
headphones = "";
headset = "";
phone = "";
portable = "";
};
format-muted = " {format_source}";
format-source = "{volume}% ";
format-source-muted = "";
on-click = "pavucontrol";
};
"hyprland/submap" = { format = ''<span style="italic">{}</span>''; };
temperature = {
critical-threshold = 80;
format = "{temperatureC}°C {icon}";
format-icons = [ "" "" "" ];
};
"hyprland/workspaces" = {
disable-scroll = true;
all-outputs = true;
warp-on-scroll = true;
format = "{name}{icon}";
format-icons = {
urgent = "";
active = "";
default = "";
};
#persistent-workspaces = {
# "*" = 3;
#};
};
"custom/power" = {
format = " ";
tooltip = false;
menu = "on-click";
menu-file = ./power_menu.xml;
menu-actions = {
shutdown = "shutdown -h now";
reboot = "reboot";
suspend = "systemctl suspend";
hibernate = "systemctl hibernate";
};
};
"custom/notification" = {
tooltip = false;
format = "{icon}";
format-icons = {
notification = " <span foreground='red'><small><sup></sup></small></span>";
none = " ";
dnd-notification = " <span foreground='red'><small><sup></sup></small></span>";
dnd-none = " ";
};
return-type = "json";
exec-if = "which swaync-client";
exec = "swaync-client -swb";
on-click = "sleep 0.1 && swaync-client -t -sw";
on-click-right = "sleep 0.1 && swaync-client -d -sw";
escape = true;
};
"custom/disablehypridle" = {
exec = ''
if pgrep -x "hypridle" > /dev/null; then
echo "{\"text\": \" \", \"tooltip\": \"Hypridle is running\", \"class\": \"active\"}";
else
echo "{\"text\": \" \", \"tooltip\": \"Hypridle is not running\", \"class\": \"inactive\"}";
fi
'';
return-type = "json";
on-click = ''
if pgrep -x "hypridle" > /dev/null; then
pkill hypridle
else
hypridle &
fi
'';
};
}];
};
}

View file

@ -0,0 +1,92 @@
* {
border: none;
font-family: Font Awesome, Roboto, Arial, sans-serif;
font-size: 13px;
color: #B9826A;/*#ffffff;*/
border-radius: 20px;
}
window {
/*font-weight: bold;*/
}
window#waybar {
background: rgba(0, 0, 0, 0);
}
/*-----module groups----*/
.modules-right {
background-color: rgba(0,43,51,0.85);
margin: 2px 10px 0 0;
}
.modules-center {
background-color: rgba(0,43,51,0.85);
margin: 2px 0 0 0;
}
.modules-left {
margin: 2px 0 0 5px;
background-color: rgba(0,119,179,0.6);
}
/*-----modules indv----*/
#workspaces button {
padding: 1px 5px;
background-color: transparent;
}
#workspaces button:hover {
box-shadow: inherit;
background-color: rgba(0,153,153,1);
}
#workspaces button.focused {
background-color: rgba(0,43,51,0.85);
}
#clock,
#battery,
#cpu,
#memory,
#temperature,
#network,
#pulseaudio,
#custom-media,
#tray,
#mode,
#custom-power,
#custom-menu,
#idle_inhibitor {
padding: 0 10px;
}
#mode {
color: #cc3436;
font-weight: bold;
}
#custom-power {
background-color: rgba(0,119,179,0.6);
border-radius: 100px;
margin: 5px 5px;
padding: 1px 1px 1px 6px;
}
/*-----Indicators----*/
#idle_inhibitor.activated {
color: #2dcc36;
}
#pulseaudio.muted {
color: #cc3436;
}
#battery.charging {
color: #2dcc36;
}
#battery.warning:not(.charging) {
color: #e6e600;
}
#battery.critical:not(.charging) {
color: #cc3436;
}
#temperature.critical {
color: #cc3436;
}
/*-----Colors----*/
/*
*rgba(0,85,102,1),#005566 --> Indigo(dye)
*rgba(0,43,51,1),#002B33 --> Dark Green
*rgba(0,153,153,1),#009999 --> Persian Green
*
*/