From 3b8a896dde231c2f14174dae07036dbcf453ade8 Mon Sep 17 00:00:00 2001 From: DACHXY Date: Wed, 25 Dec 2024 17:15:51 +0800 Subject: [PATCH 1/4] add fish shell alias --- home/config/hypr/bind.conf | 4 ++++ home/user/shell.nix | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/home/config/hypr/bind.conf b/home/config/hypr/bind.conf index 52c6d64..96890c3 100755 --- a/home/config/hypr/bind.conf +++ b/home/config/hypr/bind.conf @@ -32,6 +32,10 @@ bind = $mainMod, l, movefocus, r bind = $mainMod, k, movefocus, u bind = $mainMod, j, movefocus, d +# Workspace Scroll +bind = $mainMod, mouse_down, workspace, e-1 +bind = $mainMod, mouse_up, workspace, e+1 + bind = $mainMod, 1, workspace, 1 bind = $mainMod, 2, workspace, 2 bind = $mainMod, 3, workspace, 3 diff --git a/home/user/shell.nix b/home/user/shell.nix index ed0f3aa..1f6deb0 100644 --- a/home/user/shell.nix +++ b/home/user/shell.nix @@ -1,4 +1,15 @@ { pkgs, ... }: +let + shellAlias = { + ls = "exa"; + cat = "bat"; + rebuild = "sudo nixos-rebuild switch --flake /etc/nixos"; + fullClean = "nix-collect-garbage --delete-old && sudo nix-collect-garbage -d && sudo /run/current-system/bin/switch-to-configuration boot"; + setWindows = "sudo bootctl set-oneshot auto-windows"; + goWin = "sudo bootctl set-oneshot auto-windows && reboot"; + goBios = "sudo bootctl set-onshot auto-reboot-to-firmware-setup && reboot"; + }; +in { programs = { # nushell = { @@ -7,6 +18,7 @@ # envFile.source = ../config/nushell/env.nu; # }; + fish = { enable = true; interactiveShellInit = '' @@ -14,8 +26,8 @@ ''; plugins = [ { name = "grc"; src = pkgs.fishPlugins.grc.src; } - # Other plugins can be located in config file ]; + shellAliases = shellAlias; }; carapace = { From 71becb872ee99ea699bf2e6555f6bd6488c80f03 Mon Sep 17 00:00:00 2001 From: DACHXY Date: Thu, 26 Dec 2024 01:14:15 +0800 Subject: [PATCH 2/4] add wayland for electron apps --- home/config/electron/electron-flags.conf | 3 + home/config/firefox/autohide_toolbox.css | 105 +++++++++++++++++++++++ home/config/{ => firefox}/nightTab.json | 0 home/config/hypr/bind.conf | 2 +- home/config/hypr/monitor.conf | 2 +- home/config/hypr/window.conf | 4 + home/user/config.nix | 1 + home/user/environment.nix | 1 + home/user/gtk.nix | 8 +- home/user/packages.nix | 1 - home/user/programs.nix | 33 +++++++ 11 files changed, 153 insertions(+), 7 deletions(-) create mode 100644 home/config/electron/electron-flags.conf create mode 100644 home/config/firefox/autohide_toolbox.css rename home/config/{ => firefox}/nightTab.json (100%) diff --git a/home/config/electron/electron-flags.conf b/home/config/electron/electron-flags.conf new file mode 100644 index 0000000..e8bbd0b --- /dev/null +++ b/home/config/electron/electron-flags.conf @@ -0,0 +1,3 @@ +--enable-features=UseOzonePlatform +--enable-features=WaylandWindowDecorations +--ozone-platform-hint=auto diff --git a/home/config/firefox/autohide_toolbox.css b/home/config/firefox/autohide_toolbox.css new file mode 100644 index 0000000..8239229 --- /dev/null +++ b/home/config/firefox/autohide_toolbox.css @@ -0,0 +1,105 @@ +/* Source file https://github.com/MrOtherGuy/firefox-csshacks/tree/master/chrome/autohide_toolbox.css made available under Mozilla Public License v. 2.0 +See the above repository for updates as well as full license text. */ + +/* Hide the whole toolbar area unless urlbar is focused or cursor is over the toolbar + * Dimensions on non-Win10 OS probably needs to be adjusted. + */ + +:root{ + --uc-autohide-toolbox-delay: 200ms; /* Wait 0.1s before hiding toolbars */ + --uc-toolbox-rotation: 82deg; /* This may need to be lower on mac - like 75 or so */ +} + +:root[sizemode="maximized"]{ + --uc-toolbox-rotation: 88.5deg; +} + +@media (-moz-platform: windows){ + :root:not([lwtheme]) #navigator-toolbox{ background-color: -moz-dialog !important; } +} + +:root[sizemode="fullscreen"], +:root[sizemode="fullscreen"] #navigator-toolbox{ margin-top: 0 !important; } + +#navigator-toolbox{ + --browser-area-z-index-toolbox: 3; + position: fixed !important; + background-color: var(--lwt-accent-color,black) !important; + transition: transform 82ms linear, opacity 82ms linear !important; + transition-delay: var(--uc-autohide-toolbox-delay) !important; + transform-origin: top; + transform: rotateX(var(--uc-toolbox-rotation)); + opacity: 0; + line-height: 0; + z-index: 1; + pointer-events: none; +} +:root[sessionrestored] #urlbar[popover]{ + pointer-events: none; + opacity: 0; + transition: transform 82ms linear var(--uc-autohide-toolbox-delay), opacity 0ms calc(var(--uc-autohide-toolbox-delay) + 82ms); + transform-origin: 0px calc(0px - var(--tab-min-height) - var(--tab-block-margin) * 2); + transform: rotateX(89.9deg); +} +#mainPopupSet:has(> [panelopen]:not(#ask-chat-shortcuts,#tab-preview-panel)) ~ toolbox #urlbar[popover], +#navigator-toolbox:is(:hover,:focus-within) #urlbar[popover], +#urlbar-container > #urlbar[popover]:is([focused],[open]){ + pointer-events: auto; + opacity: 1; + transition-delay: 33ms; + transform: rotateX(0deg); +} +#mainPopupSet:has(> [panelopen]:not(#ask-chat-shortcuts,#tab-preview-panel)) ~ toolbox, +#navigator-toolbox:has(#urlbar:is([open],[focus-within])), +#navigator-toolbox:hover, +#navigator-toolbox:focus-within{ + transition-delay: 33ms !important; + transform: rotateX(0); + opacity: 1; +} +/* This makes things like OS menubar/taskbar show the toolbox when hovered in maximized windows. + * Unfortunately it also means that other OS native surfaces (such as context menu on macos) + * and other always-on-top applications will trigger toolbox to show up. */ +@media (-moz-bool-pref: "userchrome.autohide-toolbox.unhide-by-native-ui.enabled"){ + :root[sizemode="maximized"]:not(:hover){ + #navigator-toolbox:not(:-moz-window-inactive), + #urlbar[popover]:not(:-moz-window-inactive){ + transition-delay: 33ms !important; + transform: rotateX(0); + opacity: 1; + } + } +} + +#navigator-toolbox > *{ line-height: normal; pointer-events: auto } + +#navigator-toolbox, +#navigator-toolbox > *{ + width: 100vw; + -moz-appearance: none !important; +} + +/* These two exist for oneliner compatibility */ +#nav-bar{ width: var(--uc-navigationbar-width,100vw) } +#TabsToolbar{ width: calc(100vw - var(--uc-navigationbar-width,0px)) } + +/* Don't apply transform before window has been fully created */ +:root:not([sessionrestored]) #navigator-toolbox{ transform:none !important } + +:root[customizing] #navigator-toolbox{ + position: relative !important; + transform: none !important; + opacity: 1 !important; +} + +#navigator-toolbox[inFullscreen] > #PersonalToolbar, +#PersonalToolbar[collapsed="true"]{ display: none } + +/* Uncomment this if tabs toolbar is hidden with hide_tabs_toolbar.css */ + /*#titlebar{ margin-bottom: -9px }*/ + +/* Uncomment the following for compatibility with tabs_on_bottom.css - this isn't well tested though */ +/* +#navigator-toolbox{ flex-direction: column; display: flex; } +#titlebar{ order: 2 } +*/ \ No newline at end of file diff --git a/home/config/nightTab.json b/home/config/firefox/nightTab.json similarity index 100% rename from home/config/nightTab.json rename to home/config/firefox/nightTab.json diff --git a/home/config/hypr/bind.conf b/home/config/hypr/bind.conf index 96890c3..bd39e8f 100755 --- a/home/config/hypr/bind.conf +++ b/home/config/hypr/bind.conf @@ -25,7 +25,7 @@ bind = ALT, TAB, cyclenext bind = ALT, TAB, bringactivetotop bind = $mainMod, F, exec, firefox -bind = $mainMod, C, exec, code +bind = $mainMod, C, exec, NIXOS_OZONE_WL=1 code bind = $mainMod, h, movefocus, l bind = $mainMod, l, movefocus, r diff --git a/home/config/hypr/monitor.conf b/home/config/hypr/monitor.conf index aa6c110..a13d5e4 100755 --- a/home/config/hypr/monitor.conf +++ b/home/config/hypr/monitor.conf @@ -1,3 +1,3 @@ monitor=desc:ASUSTek COMPUTER INC ASUS VG32VQ1B 0x00002271,2560x1440@165, 0x0, 1 -monitor=desc:Acer Technologies XV272U V3 7422007E54222, 2560x1440@144, -1440x-540, auto, transform, 1 +monitor=desc:Acer Technologies XV272U V3 7422007E54222, 2560x1440@144, -1440x-540, 1, transform, 1 diff --git a/home/config/hypr/window.conf b/home/config/hypr/window.conf index 6086f74..7cd4f8b 100755 --- a/home/config/hypr/window.conf +++ b/home/config/hypr/window.conf @@ -1,3 +1,7 @@ +xwayland { + force_zero_scaling = true +} + general { gaps_in = 5 gaps_out = 10 diff --git a/home/user/config.nix b/home/user/config.nix index c290b5b..3faa3ed 100644 --- a/home/user/config.nix +++ b/home/user/config.nix @@ -37,5 +37,6 @@ in recursive = true; source = "${configDir}/fcitx5"; }; + ".config/electron-flags.conf".source = "${configDir}/electron/electron-flags.conf"; }; } diff --git a/home/user/environment.nix b/home/user/environment.nix index 8a74f9a..547af59 100644 --- a/home/user/environment.nix +++ b/home/user/environment.nix @@ -29,6 +29,7 @@ XDG_DATA_HOME = "\${HOME}/.local/share"; GTK_IM_MODULE = ""; XDG_DATA_DIRS = "\${XDG_DATA_DIRS}:/usr/share:/var/lib/flatpak/exports/share:\${HOME}/.local/share/flatpak/exports/share"; + ELECTRON_OZONE_PLATFORM_HINT = "auto"; # GPU LIBVA_DRIVER_NAME = "nvidia"; diff --git a/home/user/gtk.nix b/home/user/gtk.nix index 98092bb..e2e0eb8 100644 --- a/home/user/gtk.nix +++ b/home/user/gtk.nix @@ -3,15 +3,15 @@ enable = true; cursorTheme = { - name = "Catppuccin-Macchiato-Blue"; - package = pkgs.catppuccin-cursors.macchiatoBlue; + name = "Catppuccin-Macchiato-Lavender"; + package = pkgs.catppuccin-cursors.macchiatoLavender; }; theme = { - name = "Catppuccin-Macchiato-Compact-Blue-dark"; + name = "Catppuccin-Macchiato-Compact-Lavender-dark"; package = pkgs.catppuccin-gtk.override { size = "compact"; - accents = [ "blue" ]; + accents = [ "lavender" ]; variant = "macchiato"; }; }; diff --git a/home/user/packages.nix b/home/user/packages.nix index eeeacae..1eff68a 100644 --- a/home/user/packages.nix +++ b/home/user/packages.nix @@ -2,7 +2,6 @@ { home.packages = [ - pkgs.vscode pkgs.vesktop # discord pkgs.firefox diff --git a/home/user/programs.nix b/home/user/programs.nix index 5eba43e..f89a948 100644 --- a/home/user/programs.nix +++ b/home/user/programs.nix @@ -8,5 +8,38 @@ extraLuaPackages = ps: [ ps.magick ]; extraPackages = [ pkgs.imagemagick ]; }; + + vscode = { + enable = true; + package = pkgs.vscode.fhs; + }; + + firefox.profiles.danny.settings = { + # about:config + "toolkit.legacyUserProfileCustomizations.stylesheets" = true; + "extensions.activeThemeID" = "firefox-compact-dark@mozilla.org"; + "font.language.group" = "zh-TW"; + "font.name.sans-serif.ja" = "Noto Sans CJK JP"; + "font.name.sans-serif.zh-TW" = "Noto Sans CJK TC"; + "font.name.serif.ja" = "Noto Serif CJK JP"; + "font.name.serif.zh-TW" = "Noto Serif CJK TC"; + "font.name.monospace.ja" = "Noto Sans Mono CJK JP"; + "font.name.monospace.x-western" = "CaskaydiaCove Nerd Font Mono"; + "font.name.monospace.zh-TW" = "Noto Sans Mono CJK TC"; + }; + + # firefox = { + # enable = true; + # languagePacks = [ + # "en-US" + # "zh-TW" + # "ja" + # ]; + # + # policies = { + # DontCheckDefaultBrowser = true; + # DisplayBookmarksToolbar = "never"; + # }; + # }; }; } From aad529ecbc5f93ce87a9117a6306e817d5278e88 Mon Sep 17 00:00:00 2001 From: DACHXY Date: Thu, 26 Dec 2024 12:46:23 +0800 Subject: [PATCH 3/4] replace rofi with rofi-wayland --- flake.lock | 21 +++++++++++++++++++ flake.nix | 38 +++++++++++++++++++--------------- system/modules/dn-ca.nix | 30 +++++++++++++-------------- system/modules/environment.nix | 25 +++++++++++++--------- system/modules/hyprland.nix | 3 +-- system/modules/programs.nix | 13 ++++++------ 6 files changed, 80 insertions(+), 50 deletions(-) diff --git a/flake.lock b/flake.lock index 5bdba72..2b8655f 100644 --- a/flake.lock +++ b/flake.lock @@ -21,6 +21,26 @@ "type": "github" } }, + "nix-index-database": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1734838217, + "narHash": "sha256-zvMLS8BGn+kMG7tLLT3PJ67/S9yqZ9B7V8hKBa9cRRY=", + "owner": "nix-community", + "repo": "nix-index-database", + "rev": "d583b2d142f0428313df099f4a2dcf2a0496aa78", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-index-database", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1733808091, @@ -56,6 +76,7 @@ "root": { "inputs": { "home-manager": "home-manager", + "nix-index-database": "nix-index-database", "nixpkgs": "nixpkgs", "nixpkgs-unstable": "nixpkgs-unstable" } diff --git a/flake.nix b/flake.nix index f072719..240ec63 100644 --- a/flake.nix +++ b/flake.nix @@ -6,35 +6,39 @@ nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable"; home-manager.url = "github:nix-community/home-manager/release-24.11"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; + nix-index-database.url = "github:nix-community/nix-index-database"; + nix-index-database.inputs.nixpkgs.follows = "nixpkgs"; }; outputs = - { self, nixpkgs-unstable, nixpkgs, ... }@inputs: + { self, nixpkgs-unstable, nixpkgs, nix-index-database, ... }@inputs: let system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; pkgsUnstable = nixpkgs-unstable.legacyPackages.${system}; nixvim.url = "github:azuwis/lazyvim-nixvim"; - in { + in + { formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style; nixosConfigurations.dn-nix = nixpkgs.lib.nixosSystem { modules = - [ - ./system/configuration.nix - ]; + [ + nix-index-database.nixosModules.nix-index + ./system/configuration.nix + ]; specialArgs = { inherit inputs; inherit pkgsUnstable; }; }; - - # homeConfigurations = { - # danny = home-manager.lib.homeManagerConfiguration { - # inherit pkgs; - # modules = [ ./home ]; - # extraSpecialArgs = { - # inherit pkgs-unstable; - # inherit inputs; - # }; - # }; - # }; - # programs.home-manager.enable = true; + + # homeConfigurations = { + # danny = home-manager.lib.homeManagerConfiguration { + # inherit pkgs; + # modules = [ ./home ]; + # extraSpecialArgs = { + # inherit pkgs-unstable; + # inherit inputs; + # }; + # }; + # }; + # programs.home-manager.enable = true; }; } diff --git a/system/modules/dn-ca.nix b/system/modules/dn-ca.nix index 5b38212..bf4e5ed 100644 --- a/system/modules/dn-ca.nix +++ b/system/modules/dn-ca.nix @@ -1,19 +1,19 @@ { ... }: { - security.pki.certificates = [ - '' ------BEGIN CERTIFICATE----- -MIIBhzCCAS2gAwIBAgIQUwzjgrU4LTTmE7FTvaCHlzAKBggqhkjOPQQDAjAiMQsw -CQYDVQQKEwJETjETMBEGA1UEAxMKRE4gUm9vdCBDQTAeFw0yNDExMTAwMjE5MzRa -Fw0zNDExMDgwMjE5MzRaMCIxCzAJBgNVBAoTAkROMRMwEQYDVQQDEwpETiBSb290 -IENBMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEhjokYiCE96DzqXb0pXgV7/DW -ns8BTBq67KGeLaH77Ywv15PzR1ydwaJ1NvvwNbyZh5TwpkMtXIEG7Cr44w/Ip6NF -MEMwDgYDVR0PAQH/BAQDAgEGMBIGA1UdEwEB/wQIMAYBAf8CAQEwHQYDVR0OBBYE -FBgyUYt4st+TkVu4WWEfOhuVjbzqMAoGCCqGSM49BAMCA0gAMEUCIGUdeDfQJ+m0 -tdlSDJgnIXbJyU0u4cSvi8faJa7OtVovAiEAxvEteXU7f4+5U1yyk0NxJ7jg8B6P -K5hP1e2clgjFv/k= ------END CERTIFICATE----- - '' - ]; + security.pki.certificates = [ + '' + -----BEGIN CERTIFICATE----- + MIIBhzCCAS2gAwIBAgIQUwzjgrU4LTTmE7FTvaCHlzAKBggqhkjOPQQDAjAiMQsw + CQYDVQQKEwJETjETMBEGA1UEAxMKRE4gUm9vdCBDQTAeFw0yNDExMTAwMjE5MzRa + Fw0zNDExMDgwMjE5MzRaMCIxCzAJBgNVBAoTAkROMRMwEQYDVQQDEwpETiBSb290 + IENBMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEhjokYiCE96DzqXb0pXgV7/DW + ns8BTBq67KGeLaH77Ywv15PzR1ydwaJ1NvvwNbyZh5TwpkMtXIEG7Cr44w/Ip6NF + MEMwDgYDVR0PAQH/BAQDAgEGMBIGA1UdEwEB/wQIMAYBAf8CAQEwHQYDVR0OBBYE + FBgyUYt4st+TkVu4WWEfOhuVjbzqMAoGCCqGSM49BAMCA0gAMEUCIGUdeDfQJ+m0 + tdlSDJgnIXbJyU0u4cSvi8faJa7OtVovAiEAxvEteXU7f4+5U1yyk0NxJ7jg8B6P + K5hP1e2clgjFv/k= + -----END CERTIFICATE----- + '' + ]; } diff --git a/system/modules/environment.nix b/system/modules/environment.nix index c508230..9f9e4e1 100644 --- a/system/modules/environment.nix +++ b/system/modules/environment.nix @@ -1,14 +1,19 @@ { pkgs, ... }: let - offload = pkgs.writeShellScriptBin "offload" '' - #!/bin/bash - export __NV_PRIME_RENDER_OFFLOAD=1 - export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0 - export __GLX_VENDOR_LIBRARY_NAME=nvidia - export __VK_LAYER_NV_optimus=NVIDIA_only - exec "$@" - ''; -in { - environment.systemPackages = [ offload ]; + offload = pkgs.writeShellScriptBin "offload" '' + #!/bin/bash + export __NV_PRIME_RENDER_OFFLOAD=1 + export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0 + export __GLX_VENDOR_LIBRARY_NAME=nvidia + export __VK_LAYER_NV_optimus=NVIDIA_only + exec "$@" + ''; +in +{ + environment.systemPackages = [ offload ]; + environment.variables = { + NIXOS_OZONE_WL = "1"; + ELECTRON_OZONE_PLATFORM_HINT = "auto"; + }; } diff --git a/system/modules/hyprland.nix b/system/modules/hyprland.nix index 10f2276..54c16f7 100644 --- a/system/modules/hyprland.nix +++ b/system/modules/hyprland.nix @@ -21,8 +21,7 @@ swaylock-effects wlogout wl-clipboard - wofi - rofi + rofi-wayland-unwrapped waybar ]; } diff --git a/system/modules/programs.nix b/system/modules/programs.nix index 9abf7ca..11b3d0a 100644 --- a/system/modules/programs.nix +++ b/system/modules/programs.nix @@ -85,12 +85,13 @@ zsh.enable = true; mtr.enable = true; fish.enable = true; - nix-index = { - enable = true; - enableFishIntegration = true; - enableBashIntegration = false; - enableZshIntegration = false; - }; + + # nix-index = { + # enable = true; + # enableFishIntegration = true; + # enableBashIntegration = false; + # enableZshIntegration = false; + # }; # Set fish as default shell but not login shell bash = { From 0e57460b6a37d82ad73bebec0a80e554ad3774fa Mon Sep 17 00:00:00 2001 From: DACHXY Date: Thu, 26 Dec 2024 13:49:47 +0800 Subject: [PATCH 4/4] vesktop desktop entry modification --- home/user/gtk.nix | 8 ++------ home/user/packages.nix | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/home/user/gtk.nix b/home/user/gtk.nix index e2e0eb8..d53c349 100644 --- a/home/user/gtk.nix +++ b/home/user/gtk.nix @@ -22,15 +22,11 @@ }; gtk3.extraConfig = { - Settings = '' - gtk-application-prefer-dark-theme = 1; - ''; + gtk-application-prefer-dark-theme = 1; }; gtk4.extraConfig = { - Settings = '' - gtk-application-prefer-dark-theme = 1; - ''; + gtk-application-prefer-dark-theme = 1; }; }; diff --git a/home/user/packages.nix b/home/user/packages.nix index 1eff68a..83adc99 100644 --- a/home/user/packages.nix +++ b/home/user/packages.nix @@ -1,8 +1,18 @@ -{ pkgs, ... }: +{ pkgs, lib, ... }: +let + vesktop = pkgs.vesktop.overrideAttrs (oldAttrs: { + desktopItems = lib.optional pkgs.stdenv.hostPlatform.isLinux ( + (lib.head oldAttrs.desktopItems).override { + name = "discord"; + desktopName = "Discord"; + } + ); + }); +in { home.packages = [ - pkgs.vesktop # discord + vesktop # discord pkgs.firefox # Dev stuff