Squash merge refactor into main

This commit is contained in:
danny 2025-08-09 22:22:19 +08:00
parent 529c9e5fa7
commit b82cd59f4f
35 changed files with 498 additions and 358 deletions

View file

@ -1,9 +1,13 @@
{ settings, ... }:
{
username,
email,
}:
{ ... }:
{
programs.git = {
enable = true;
userName = settings.personal.git.username;
userEmail = settings.personal.git.email;
userName = username;
userEmail = email;
extraConfig = {
safe.directory = [ "/etc/nixos" ];
init.defaultBranch = "main";

View file

@ -1,12 +1,10 @@
{
pkgs,
settings,
...
}:
let
cursorName = "catppuccin-macchiato-lavender-cursors";
themeName = "catppuccin-macchiato-lavender-compact";
cursorSize = settings.hyprland.xcursor-size;
in
{
gtk = {
@ -15,7 +13,6 @@ in
cursorTheme = {
name = cursorName;
package = pkgs.catppuccin-cursors.macchiatoLavender;
size = cursorSize;
};
theme = {

View file

@ -1,8 +1,9 @@
{
settings,
mainMod,
nvidia-offload-enabled,
pkgs,
rofiWall,
monitors ? [ ],
}:
with builtins;
let
@ -11,9 +12,7 @@ let
browser = "${prefix} ${firefox}";
terminal = "ghostty";
filemanager = "${terminal} -e yazi";
scripts = "~/.config/scripts";
freezeShot = "";
screenshotFolder = "--output-folder ~/Pictures/Screenshots";
clipboardOnly = "${screenshotFolder}";
@ -27,20 +26,9 @@ let
fi
'';
toggleRofi = pkgs.writeShellScriptBin "toggle" ''
GDK_PIXBUF_MODULE_FILE="${pkgs.librsvg}/lib/gdk-pixbuf-2.0/${pkgs.librsvg.version}/loaders.cache" # Make rofi load svg
if ${pkgs.busybox}/bin/pgrep rofi > /dev/null; then
${pkgs.busybox}/bin/pkill rofi
else
rofi "$@"
fi
'';
scrollStep =
let
monitorsNum = length settings.hyprland.monitors;
monitorsNum = length monitors;
in
toString (if (monitorsNum == 0) then 1 else monitorsNum);
in
@ -53,19 +41,20 @@ in
''${mainMod}, M, exec, ${toggleWlogout}/bin/toggle''
''${mainMod}, E, exec, ${filemanager}''
''${mainMod}, V, togglefloating, ''
''ALT, SPACE, exec, ${toggleRofi}/bin/toggle -config ~/.config/rofi/apps.rasi -show drun''
''ALT, SPACE, exec, rofi -config ~/.config/rofi/apps.rasi -show drun''
''${mainMod}, W, exec, ${rofiWall}''
''${mainMod}, P, pseudo, # dwindle''
''${mainMod}, S, togglesplit, # dwindle''
''CTRL ${mainMod} SHIFT, L, exec, hyprlock''
# Screenshot
''${mainMod} SHIFT, s, exec, hyprshot -m region ${clipboardOnly} ${freezeShot}''
''CTRL SHIFT, s, exec, hyprshot -m window ${clipboardOnly} ${freezeShot}''
''CTRL SHIFT ${mainMod}, s, exec, hyprshot -m output ${clipboardOnly} ${freezeShot}''
''CTRL ALT, s, exec, hyprshot -m active -m window ${clipboardOnly} ${freezeShot}''
''${mainMod} SHIFT, s, exec, hyprshot -m region ${clipboardOnly}''
''CTRL SHIFT, s, exec, hyprshot -m window ${clipboardOnly}''
''CTRL SHIFT ${mainMod}, s, exec, hyprshot -m output ${clipboardOnly}''
''CTRL ALT, s, exec, hyprshot -m active -m window ${clipboardOnly}''
''${mainMod}, PERIOD, exec, ${toggleRofi}/bin/toggle -modi emoji -show emoji''
''CTRL ${mainMod}, c, exec, ${toggleRofi}/bin/toggle -show calc -modi calc -no-show-match -no-sort''
''${mainMod}, PERIOD, exec, rofi -modi emoji -show emoji''
''CTRL ${mainMod}, c, exec, rofi -show calc -modi calc -no-show-match -no-sort''
''${mainMod}, X, exec, sleep 0.1 && swaync-client -t -sw''
''${mainMod} SHIFT, C, centerwindow''
'',F11, fullscreen''
@ -102,10 +91,6 @@ in
''${mainMod}, G, workspace, ${toString gamingWorkspace}''
''${mainMod} SHIFT, G, movetoworkspace, ${toString gamingWorkspace}''
# ==== Plugins ==== #
# Overview
# ''${mainMod}, o, hyprtasking:toggle, cursor''
# ''${mainMod}, TAB, hyprtasking:toggle, all''
]
++ (
# workspaces

View file

@ -1,16 +0,0 @@
{ mainMod }:
let
resizeStep = builtins.toString 20;
brightnessStep = builtins.toString 10;
volumeStep = builtins.toString 2;
in
[
'',XF86AudioRaiseVolume, exec, wpctl set-mute @DEFAULT_SINK@ 0 && wpctl set-volume @DEFAULT_SINK@ ${volumeStep}%+''
'',XF86AudioLowerVolume, exec, wpctl set-mute @DEFAULT_SINK@ 0 && wpctl set-volume @DEFAULT_SINK@ ${volumeStep}%-''
'',XF86MonBrightnessDown, exec, brightnessctl set ${brightnessStep}%-''
'',XF86MonBrightnessUp, exec, brightnessctl set ${brightnessStep}%+''
''${mainMod} CTRL, l, resizeactive, ${resizeStep} 0''
''${mainMod} CTRL, h, resizeactive, -${resizeStep} 0''
''${mainMod} CTRL, k, resizeactive, 0 -${resizeStep}''
''${mainMod} CTRL, j, resizeactive, 0 ${resizeStep}''
]

View file

@ -1,6 +0,0 @@
{ mainMod }:
[
# Move/resize windows with mainMod + LMB/RMB and dragging
''${mainMod}, mouse:272, movewindow''
''${mainMod}, mouse:273, resizewindow''
]

View file

@ -1,17 +0,0 @@
{
pkgs,
terminal,
xcursor-size,
...
}:
let
startupScript = pkgs.writeShellScriptBin "start" ''
# Fix nemo open in terminal
dconf write /org/cinnamon/desktop/applications/terminal/exec "''\'${terminal}''\'" &
dconf write /org/cinnamon/desktop/applications/terminal/exec-arg "''\'''\'" &
dconf write /org/gnome/desktop/interface/cursor-size ${builtins.toString xcursor-size} &
systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP QT_QPA_PLATFORMTHEME &
'';
in
''${startupScript}/bin/start''

View file

@ -9,7 +9,7 @@
follow_mouse = 1;
accel_profile = "flat";
kb_options = [ "caps:swapescape" ];
kb_options = [ "caps:escape" ];
touchpad = {
natural_scroll = true;

View file

@ -1,5 +0,0 @@
[
''desc:ASUSTek COMPUTER INC ASUS VG32VQ1B 0x00002271, 2560x1440@165, 0x0, 1''
''desc:Acer Technologies XV272U V3 1322131231233, 2560x1440@180, -1440x-600, 1, transform, 1''
''desc:LG Display 0x0665, preferred, 0x0, 1.25''
]

View file

@ -1,35 +0,0 @@
{
# hyprtasking = {
# layout = "grid";
# bg_color = "0xffebdbb2";
#
# gap_size = 20;
#
# gestures = {
# enabled = true;
# open_fingers = 3;
# open_distance = 300;
# open_positive = true;
# };
#
# linear = {
# height = 400;
# scroll_speed = 1.1;
# blur = 0;
# };
# };
hyprwinrap = {
class = "kitty-bg";
};
touch_gestures = {
sensitivity = 4.0;
workspace_swipe_fingers = 3;
workspace_swipe_edge = "d";
long_press_delay = 400;
resize_on_border_long_press = true;
edge_margin = 10;
emulate_touchpad_swipe = false;
};
}

View file

@ -1,7 +1,3 @@
{ lib, settings }:
let
inherit (lib) optionalString;
in
{
windowrule = [
"pseudo, class:fcitx"
@ -42,38 +38,21 @@ in
"float, class: ^(org.pulseaudio.pavucontrol)$"
"pin, class: ^(org.pulseaudio.pavucontrol)$"
"animation slide top 20%, class: ^(org.pulseaudio.pavucontrol)$"
(optionalString (
settings.personal.hostname == "dn-pre7780"
) "move 1680 59, class: ^(org.pulseaudio.pavucontrol)$")
(optionalString (
settings.personal.hostname == "dn-pre7780"
) "size 868 561, class: ^(org.pulseaudio.pavucontrol)$")
# Local Send (File Sharing)
"float, class: ^(localsend_app)$"
"pin, class: ^(localsend_app)$"
"animation slide right 20%, class: ^(localsend_app)$"
(optionalString (
settings.personal.hostname == "dn-pre7780"
) "size 523 1372, class: ^(localsend_app)$")
(optionalString (
settings.personal.hostname == "dn-pre7780"
) "move 2024 56, class: ^(localsend_app)$")
# Airplay
"pseudo, class: ^(GStreamer)$"
"pin, class: ^(GStreamer)$"
"float, class: ^(GStreamer)$"
"opacity 1.0, class: ^(GStreamer)$"
(optionalString (settings.personal.hostname == "dn-pre7780") "size 487 1055, class: ^(GStreamer)$")
"animation slide right 20%, class: ^(GStreamer)$"
# Bluetooth
"float, class: ^(blueberry.py)$"
"pin, class: ^(blueberry.py)$"
(optionalString (
settings.personal.hostname == "dn-pre7780"
) "move 1943 59, class: ^(blueberry.py)$")
(optionalString (
settings.personal.hostname == "dn-pre7780"
) "size 605 763, class: ^(blueberry.py)$")
"animation slide top 20%, class: ^(blueberry.py)$"
# Steam
@ -90,8 +69,11 @@ in
# VLC
"workspace: 3, initialClass: ^(vlc), floating: 0"
# vesktop
"workspace: 4 silent, initialClass: ^(vesktop), floating: 0"
# discord
"workspace: 4 silent, initialClass: ^(discord), floating: 0"
# Davinci resolve
"center 1, initialClass: ^(resolve), floating: 1"
];
layerrule = [

View file

@ -1,14 +1,20 @@
{ monitors }:
let
monitorNum = builtins.length monitors;
inherit (builtins)
length
genList
toString
elemAt
;
monitorNum = length monitors;
workspaceNum = 10;
workspaceList = builtins.genList (
workspaceList = genList (
index:
let
currentNum = index - (monitorNum * (index / monitorNum));
default = if index < monitorNum then "true" else "false";
in
"${builtins.toString (index + 1)}, monitor:${builtins.elemAt monitors currentNum}, default:${default}"
"${toString (index + 1)}, monitor:${elemAt monitors currentNum}, default:${default}"
) workspaceNum;
in
if (monitorNum > 0) then workspaceList else [ ]

View file

@ -1,83 +1,81 @@
{
monitors ? [ ],
}:
{
pkgs,
lib,
inputs,
config,
system,
username,
osConfig,
settings,
...
}:
let
terminal = "ghostty";
startScript = import ./hypr/exec.nix {
inherit
pkgs
terminal
;
xcursor-size = settings.hyprland.xcursor-size;
};
mainMod = "SUPER";
window = import ./hypr/window.nix;
windowrule = import ./hypr/windowrule.nix { inherit lib settings; };
input = import ./hypr/input.nix;
plugins = import ./hypr/plugin.nix;
cursorName = "catppuccin-macchiato-lavender-cursors";
getCurrentSong = pkgs.writeShellScriptBin "getSong" ''
execOnceScript = pkgs.writeShellScript "hyprlandExecOnce" ''
# Fix nemo open in terminal
dconf write /org/cinnamon/desktop/applications/terminal/exec "''\'${terminal}''\'" &
dconf write /org/cinnamon/desktop/applications/terminal/exec-arg "''\'''\'" &
systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP QT_QPA_PLATFORMTHEME &
'';
mainMod = "SUPER";
getCurrentSong = pkgs.writeShellScript "getSong" ''
song_info=$(playerctl metadata --format '{{title}} 󰎆 {{artist}}')
echo "$song_info"
'';
wallpapers = [
(pkgs.fetchurl {
url = "https://files.net.dn/dennis-yu-fVadSuPPE8M-unsplash.jpg";
hash = "sha256-YCusefLnTntOZAh2fIoWuJbm1+iE+RNeWTbn22UDjSU=";
})
(pkgs.fetchurl {
url = "https://files.net.dn/karsten-winegeart-LZRZJam4Avg-unsplash.jpg";
hash = "sha256-NpJhRJRiFCFmdDP/8FDmzIBellSdJ1Y6Pz63QJzkPMk=";
})
(pkgs.fetchurl {
url = "https://files.net.dn/nick-design-q3s4a7FZgjY-unsplash.jpg";
hash = "sha256-kJajqRuf+ZMTaORKKK4A+8MNzGd2SHjMcRYnq9T8LmA=";
})
(pkgs.fetchurl {
url = "https://files.net.dn/oleg-demakov-zEIApnww3fU-unsplash.jpg";
hash = "sha256-79JRnxJdCZOh2u8+5LcUDGjzwE1mMM2ZHrKLn36wd40=";
})
"$HOME/.config/wallpapers/wall.png"
];
mkWall = pkgs.writeShellScriptBin "setWall" ''
url="$1"
filepath="/tmp/wall_cache/$(echo -n "$url" | base64 | tr -d '\n')"
if [[ ! -f "$filepath" ]]; then
curl -sL "$url" -o "$filepath"
fi
${config.services.swww.package}/bin/swww img "$filepath" \
--transition-fps 45 \
--transition-duration 1 \
--transition-type random
'';
rofiWall = pkgs.writeShellScript "rofiWall" ''
url=$(rofi -i -dmenu -config ~/.config/rofi/config.rasi -p "URL")
${mkWall}/bin/setWall "$url"
'';
# Change Wallpaper
wallRand = pkgs.writeShellScriptBin "wallRand" (
with builtins;
let
pathString = concatStringsSep " " (map (w: "\"" + w + "\"") wallpapers);
in
''
wallpapers=(
${pathString}
)
wallRand = pkgs.writeShellScript "wallRand" ''
mapfile -t wallpapers < <(find /tmp/wall_cache -type f)
count="''${#wallpapers[@]}"
random_index=$(( RANDOM % count ))
selected="''${wallpapers[$random_index]}"
count="''${#wallpapers[@]}"
if [ ! -f "$selected" ]; then
echo "File not exist: $selected"
exit 1
fi
random_index=$(( RANDOM % count ))
selected="''${wallpapers[$random_index]}"
${pkgs.hyprland}/bin/hyprctl hyprpaper wallpaper ",$selected"
''
);
if [ ! -f "$selected" ]; then
echo "File not exist: $selected"
exit 1
fi
${config.services.swww.package}/bin/swww img $selected --transition-fps 45 --transition-duration 1 --transition-type random
'';
in
{
# For wallpapers
systemd.user.tmpfiles.rules = [
"d /tmp/wall_cache 700 ${username} -"
];
home.packages = with pkgs; [
mpvpaper # Video Wallpaper
hyprcursor
libnotify
mkWall
];
wayland.windowManager.hyprland = {
@ -102,30 +100,72 @@ in
debug = {
disable_logs = true;
};
bind = import ./hypr/bind.nix {
inherit settings;
inherit mainMod;
inherit pkgs;
inherit
mainMod
pkgs
monitors
rofiWall
;
nvidia-offload-enabled = osConfig.hardware.nvidia.prime.offload.enableOffloadCmd;
};
bindm = import ./hypr/bindm.nix { inherit mainMod; };
binde = import ./hypr/binde.nix { inherit mainMod; };
monitor = import ./hypr/monitor.nix;
plugin = plugins;
exec-once = [ ''${startScript}'' ];
bindm = [
# Move/resize windows with mainMod + LMB/RMB and dragging
''${mainMod}, mouse:272, movewindow''
''${mainMod}, mouse:273, resizewindow''
];
binde =
let
resizeStep = builtins.toString 20;
brightnessStep = builtins.toString 10;
volumeStep = builtins.toString 2;
in
[
'',XF86AudioRaiseVolume, exec, wpctl set-mute @DEFAULT_SINK@ 0 && wpctl set-volume @DEFAULT_SINK@ ${volumeStep}%+''
'',XF86AudioLowerVolume, exec, wpctl set-mute @DEFAULT_SINK@ 0 && wpctl set-volume @DEFAULT_SINK@ ${volumeStep}%-''
'',XF86MonBrightnessDown, exec, brightnessctl set ${brightnessStep}%-''
'',XF86MonBrightnessUp, exec, brightnessctl set ${brightnessStep}%+''
''${mainMod} CTRL, l, resizeactive, ${resizeStep} 0''
''${mainMod} CTRL, h, resizeactive, -${resizeStep} 0''
''${mainMod} CTRL, k, resizeactive, 0 -${resizeStep}''
''${mainMod} CTRL, j, resizeactive, 0 ${resizeStep}''
];
monitor = [
", prefered, 0x0, 1"
];
plugin = {
hyprwinrap = {
class = "kitty-bg";
};
touch_gestures = {
sensitivity = 4.0;
workspace_swipe_fingers = 3;
workspace_swipe_edge = "d";
long_press_delay = 400;
resize_on_border_long_press = true;
edge_margin = 10;
emulate_touchpad_swipe = false;
};
};
exec-once = [ "${execOnceScript}" ];
env = [
''HYPRCURSOR_THEME, ${cursorName}''
''HYPRCURSOR_SIZE, ${builtins.toString settings.hyprland.cursor-size}''
''XCURSOR_THEME, ${cursorName}''
''XCURSOR_SIZE, ${builtins.toString settings.hyprland.xcursor-size}''
''XDG_CURRENT_DESKTOP, Hyprland''
''XDG_SESSION_DESKTOP, Hyprland''
];
workspace = import ./hypr/workspace.nix { monitors = settings.hyprland.monitors; };
workspace = (import ./hypr/workspace.nix { inherit monitors; });
}
// window
// windowrule
// input;
// (import ./hypr/window.nix)
// (import ./hypr/windowrule.nix)
// (import ./hypr/input.nix);
};
# === gamemode === #
@ -135,11 +175,17 @@ in
};
};
# === Swww === #
services.swww = {
enable = true;
package = inputs.swww.packages.${system}.swww;
};
# === hyprpaper === #
services.hyprpaper = {
enable = true;
enable = false;
settings = {
preload = wallpapers;
# preload = wallpapers;
wallpaper = [ ", ~/.config/wallpapers/wall.png" ];
splash = false;
ipc = "on";
@ -161,11 +207,7 @@ in
let
font = "CaskaydiaCove Nerd Font";
font2 = "SF Pro Display Bold";
mainMonitor =
if ((builtins.length settings.hyprland.monitors) > 0) then
builtins.elemAt settings.hyprland.monitors 0
else
"";
mainMonitor = if ((builtins.length monitors) > 0) then builtins.elemAt monitors 0 else "";
in
{
background = {
@ -226,7 +268,7 @@ in
# Current Song
{
monitor = "${mainMonitor}";
text = ''cmd[update:1000] echo "$(${getCurrentSong}/bin/getSong)"'';
text = ''cmd[update:1000] echo "$(${getCurrentSong})"'';
color = "rgba(235, 219, 178, .75)";
font_size = 16;
font_family = "${font}, ${font2}";
@ -358,6 +400,7 @@ in
terminal
osConfig
wallRand
rofiWall
pkgs
lib
;

View file

@ -1,7 +1,6 @@
{
lib,
pkgs,
settings,
inputs,
...
}:
@ -307,14 +306,6 @@
formatting = {
command = { "nixfmt" },
},
-- options = {
-- nixos = {
-- expr = '(builtins.getFlake ("git+file://" + toString ./.)).nixosConfigurations.${settings.personal.hostname}.options',
-- },
-- home_manager = {
-- expr = '(builtins.getFlake ("git+file://" + toString ./.)).homeConfigurations."${settings.personal.username}@${settings.personal.hostname}".options',
-- }
-- }
}
}
}

View file

@ -52,7 +52,8 @@ in
obsidian
# Discord
vesktop
# vesktop
discord
# Dev stuff
(python3.withPackages (python-pkgs: [

View file

@ -1,6 +1,6 @@
{ pkgs, settings, ... }:
{ osConfig, pkgs, ... }:
let
shellAlias = import ./shellAlias.nix { hostname = settings.personal.hostname; };
shellAlias = import ./shellAlias.nix { hostname = osConfig.networking.hostName; };
in
{
home.packages = with pkgs; [