commit 61a1651cf0fa0b9e50226405c160f2d3a44705fe Author: alex Date: Sun Apr 20 11:16:39 2025 +0800 init diff --git a/README.md b/README.md new file mode 100644 index 0000000..530cc8c --- /dev/null +++ b/README.md @@ -0,0 +1,95 @@ +### 目录结构 + +``` +├── home # home manager 配置信息 +│ ├── core.nix # 核心的通用配置,由其他配置引入 +│ ├── desktop.nix # 桌面环境配置 +│ ├── server.nix # 服务器配置 +├── modules # 通用模块,不同机器可以根据的需要引入 +│ ├── home # home manager 通用模块 +│ │ └── - +│ └── nixos # nixos 通用模块 +├── overlays # 安装包的修改配置 +│ └── - +├── pkgs +│ └── - +├── profiles # 不同机器的配置文件 +│ ├── apollo # 主服务器配置 +│ ├── gaea # 主用机配置 +│ └── luna # 虚拟机配置 +├── secrets +│ └── _public_keys_ +├── flake.lock +├── flake.nix # nix flake 入口 +├── nixos-install.sh # nixos 全新安装脚本 +└── flake.lock +``` + +### 如何安装? + +0. 准备一个 64 位的 nixos [minimal iso image](https://channels.nixos.org/nixos-22.11/latest-nixos-minimal-x86_64-linux.iso) 烧录好,然后进入 live 系统。 +1. 分区 + +使用 fdisk 或 parted 工具进行分区。现在假设两个分区为:`/dev/sda1` `/dev/sda2`。 + +2. 格式化分区 + +```bash + mkfs.fat -F 32 /dev/sda1 # boot / EFI 分区 + mkfs.ext4 /dev/sda2 # 系统分区 +``` + +3. 挂载 + +```bash + mount /dev/sda2 /mnt/nix + mkdir -p /mnt/boot + mount /dev/sda1 /mnt/boot +``` + +4. 生成一个基本的配置 + +```bash + nixos-generate-config --root /mnt +``` + +5. 克隆仓库到本地 + +```bash +nix-shell -p git +git clone https://github.com/synebula/.nix.git /mnt/.nix +cd /mnt/.nix/ +nix develop --extra-experimental-features "nix-command flakes" +``` + +6. 将 /mnt/etc/nixos 中的 `hardware-configuration.nix` 拷贝到 `/mnt/.nix/profiles//hardware-configuration.nix`, 其中``指需要的 profile。 + +```bash +cp /mnt/etc/nixos/hardware-configuration.nix /mnt/.nix/profiles//hardware-configuration.nix +``` +7. 用户名修改: 编辑 `/mnt/.nix/flake.nix` 修改 **username** 变量。 + +8. 使用 `mkpasswd {PASSWORD} -m sha-512` 命令生成的密码哈希串替换掉 `/mnt/.nix/modules/nixos/user-group.nix` 中的 `users.users..hashedPassword` 值替换掉。 + + +9. 安装 + +```bash +nixos-install --option substituters "https://mirrors.ustc.edu.cn/nix-channels/store https://cache.nixos.org" --no-root-passwd --flake .# + +# 或者 + +./nixos-install +``` + +10. 重启 + +```bash +reboot +``` + +### 日常更新系统脚本 + +``` bash +./nixos-switch +``` \ No newline at end of file diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..8c8ee6e --- /dev/null +++ b/flake.nix @@ -0,0 +1,98 @@ +# Configuration file init by: nix flake init -t github:misterio77/nix-starter-config#standard +{ + outputs = { self, nixpkgs, nixpkgs-unstable, home-manager, home-manager-unstable, ... }@inputs: + let + inherit (self) outputs; + inherit (nixpkgs) lib; + username = "alex"; + useremail = "reizero@live.com"; + hostname = "luna"; + sysversion = "24.11"; + libs = import ./libs { inherit nixpkgs; }; + in + rec { + # Your custom packages + # Acessible through 'nix build', 'nix shell', etc + packages = libs.forAllSystems (system: + let pkgs = nixpkgs.packages.${system}; + in import ./pkgs { inherit pkgs; } + ); + + # Your custom packages and modifications, exported as overlays + overlays = import ./overlays { inherit inputs; }; + + # NixOS configuration entrypoint + # Available through 'nixos-rebuild --flake .#your-hostname' + nixosConfigurations = + with builtins; lib.genAttrs (attrNames (readDir ./profiles)) + (profile: + lib.nixosSystem + { + specialArgs = { + inherit self inputs outputs username useremail sysversion; + hostname = profile; + }; + modules = [ + ./profiles/${profile} + ]; + } + ); + + # Standalone home-manager configuration entrypoint + # Available through 'home-manager --flake .#your-username@your-hostname' + # Or run 'nix build .#homeConfigurations..activationPackage' in none-nixos distro first + homeConfigurations = { + # FIXME replace with your username@hostname + "${username}" = home-manager-unstable.lib.homeManagerConfiguration { + pkgs = nixpkgs-unstable.packages.x86_64-linux; # Home-manager requires 'pkgs' instance + extraSpecialArgs = { + inherit inputs outputs username useremail sysversion; + hyprland = inputs.hyprland; + }; + modules = [ + # > Our main home-manager configuration file < + ./home/desktop.nix + + # Ony non-nixos use home-manager standalone, use this config fixing issues. + { + targets.genericLinux.enable = true; + } + ]; + }; + }; + }; + + inputs = { + # Nixpkgs + nixpkgs.url = "github:nixos/nixpkgs/nixos-${sysversion}"; + # You can access packages and modules from different nixpkgs revs + # at the same time. Here's an working example: + nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; + # Also see the 'unstable-packages' overlay at 'overlays/default.nix'. + + # The Nix User Repository + # nur.url = github:nix-community/NUR; + + # Home manager + home-manager = { + url = "github:nix-community/home-manager/release-${sysversion}"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + # Home manager + home-manager-unstable = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs-unstable"; + }; + + hyprland.url = "github:hyprwm/Hyprland"; + + # TODO: Add any other flake you might need + # hardware.url = "github:nixos/nixos-hardware"; + + # Shameless plug: looking for a way to nixify your themes and make + # everything match nicely? Try nix-colors! + # nix-colors.url = "github:misterio77/nix-colors"; + }; + +} diff --git a/home/core.nix b/home/core.nix new file mode 100644 index 0000000..6d1897e --- /dev/null +++ b/home/core.nix @@ -0,0 +1,110 @@ +# This is your home-manager configuration file +# Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix) + +{ inputs, outputs, lib, config, pkgs, username, useremail, sysversion, ... }: { + + home = { + inherit username; + homeDirectory = "/home/${username}"; + + # Add stuff for your user as you see fit: + packages = with pkgs; [ + nixpkgs-fmt + ]; + }; + + # Enable home-manager and git + programs = { + # home-manager.enable = true; + # git.enable = true; + + git = { + enable = true; + + userName = username; + userEmail = useremail; + + includes = [ + { + # use diffrent email & name for work + path = "~/work/.gitconfig"; + condition = "gitdir:~/work/"; + } + ]; + + extraConfig = { + init.defaultBranch = "master"; + push.autoSetupRemote = true; + pull.rebase = true; + + # replace https with ssh + # url = { + # "ssh://git@github.com/" = { + # insteadOf = "https://github.com/"; + # }; + # "ssh://git@gitlab.com/" = { + # insteadOf = "https://gitlab.com/"; + # }; + # "ssh://git@bitbucket.com/" = { + # insteadOf = "https://bitbucket.com/"; + # }; + # }; + }; + + }; + + bash = { + enable = true; + enableCompletion = true; + bashrcExtra = ""; + shellAliases = { }; + }; + + vim = { + enable = true; + plugins = with pkgs.vimPlugins; [ vim-airline ]; + settings = { ignorecase = true; }; + extraConfig = '' + set mouse=a + set expandtab + set tabstop=2 + set softtabstop=2 + set shiftwidth=2 + ''; + }; + }; + + + nixpkgs = { + # You can add overlays here + overlays = [ + # Add overlays your own flake exports (from overlays and pkgs dir): + outputs.overlays.additions + outputs.overlays.modifications + outputs.overlays.unstable-packages + + # You can also add overlays exported from other flakes: + # neovim-nightly-overlay.overlays.default + + # Or define it inline, for example: + # (final: prev: { + # hi = final.hello.overrideAttrs (oldAttrs: { + # patches = [ ./change-hello-to-hi.patch ]; + # }); + # }) + ]; + # Configure your nixpkgs instance + config = { + # Disable if you don't want unfree packages + allowUnfree = true; + # Workaround for https://github.com/nix-community/home-manager/issues/2942 + allowUnfreePredicate = (_: true); + }; + }; + + # Nicely reload system units when changing configs + systemd.user.startServices = "sd-switch"; + + # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion + home.stateVersion = sysversion; +} diff --git a/home/desktop.nix b/home/desktop.nix new file mode 100644 index 0000000..60db685 --- /dev/null +++ b/home/desktop.nix @@ -0,0 +1,88 @@ +# This is your home-manager configuration file +# Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix) + +{ inputs, outputs, lib, config, pkgs, username, useremail, hyprland, ... }: +{ + # You can import other home-manager modules here + imports = [ + # If you want to use modules your own flake exports (from modules/home-manager): + # outputs.homeManagerModules.example + + # Or modules exported from other flakes (such as nix-colors): + # inputs.nix-colors.homeManagerModules.default + + # You can also split up your configuration and import pieces of it here: + # ./nvim.nix + ./core.nix + ../modules/home/hyprland + ../modules/home/vscode + ../modules/home/v2ray + ../modules/home/xdg.nix + ../modules/home/theme.nix + ]; + + home = { + # Add stuff for your user as you see fit: + packages = with pkgs; [ + bc # GNU software calculator + vlc + imv + motrix + microsoft-edge + telegram-desktop + # firefox + # chromium + + zip + unzip + lsof + pciutils # lspci etc. + steam-run + frp + obsidian + wpsoffice-cn + xorg.xhost + + dbeaver + postman + # jdk + nodejs + yarn + flutter + oraclejdk + jetbrains.idea-community + # nur.repos.linyinfeng.wemeet + ]; + + sessionVariables = { + JAVA_HOME = "${pkgs.oraclejdk}"; + XIM = "fcitx"; + XIM_PROGRAM = "fcitx"; + XMODIFIERS = "@im=fcitx"; + }; + }; + + programs = { + bash = { + initExtra = '' + export XIM="fcitx" + export XIM_PROGRAM="fcitx" + export XMODIFIERS="@im=fcitx" + ''; + }; + }; + + + i18n.inputMethod = { + enabled = "fcitx5"; + fcitx5.addons = with pkgs; [ + fcitx5-chinese-addons + ]; + }; + + # Enable home-manager and git + programs = { + home-manager.enable = true; + # git.enable = true; + }; +} diff --git a/home/server.nix b/home/server.nix new file mode 100644 index 0000000..e422615 --- /dev/null +++ b/home/server.nix @@ -0,0 +1,26 @@ +# This is your home-manager configuration file +# Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix) + +{ inputs, outputs, lib, config, pkgs, username, useremail, hyprland, ... }: { + # You can import other home-manager modules here + imports = [ + # If you want to use modules your own flake exports (from modules/home-manager): + # outputs.homeManagerModules.example + + # Or modules exported from other flakes (such as nix-colors): + # inputs.nix-colors.homeManagerModules.default + + # You can also split up your configuration and import pieces of it here: + # ./nvim.nix + ./core.nix + ]; + + home = { + # Add stuff for your user as you see fit: + packages = with pkgs; [ + ]; + }; + + # Enable home-manager and git + programs = { }; +} diff --git a/libs/default.nix b/libs/default.nix new file mode 100644 index 0000000..20d2d38 --- /dev/null +++ b/libs/default.nix @@ -0,0 +1,13 @@ +{ nixpkgs }: + +with nixpkgs.lib; { + # Add your library functions here + # + forAllSystems = genAttrs [ + "aarch64-linux" + "i686-linux" + "x86_64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; +} diff --git a/modules/home/hyprland/conf/hypr/animations.conf b/modules/home/hyprland/conf/hypr/animations.conf new file mode 100644 index 0000000..6246d41 --- /dev/null +++ b/modules/home/hyprland/conf/hypr/animations.conf @@ -0,0 +1,23 @@ + +# ▄▀█ █▄░█ █ █▀▄▀█ ▄▀█ ▀█▀ █ █▀█ █▄░█ +# █▀█ █░▀█ █ █░▀░█ █▀█ ░█░ █ █▄█ █░▀█ + + +# Some default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more + +animations { + enabled = yes + bezier = wind, 0.05, 0.9, 0.1, 1.05 + bezier = winIn, 0.1, 1.1, 0.1, 1.1 + bezier = winOut, 0.3, -0.3, 0, 1 + bezier = liner, 1, 1, 1, 1 + animation = windows, 1, 6, wind, slide + animation = windowsIn, 1, 6, winIn, slide + animation = windowsOut, 1, 5, winOut, slide + animation = windowsMove, 1, 5, wind, slide + animation = border, 1, 1, liner + animation = borderangle, 1, 30, liner, loop + animation = fade, 1, 10, default + animation = workspaces, 1, 5, wind +} + diff --git a/modules/home/hyprland/conf/hypr/hyprland.conf b/modules/home/hyprland/conf/hypr/hyprland.conf new file mode 100644 index 0000000..adc84ab --- /dev/null +++ b/modules/home/hyprland/conf/hypr/hyprland.conf @@ -0,0 +1,116 @@ +###################################################################################### +#AUTOGENERATED HYPR CONFIG. +#PLEASE USE THE CONFIG PROVIDED IN THE GIT REPO /examples/hypr.conf AND EDIT IT, +#OR EDIT THIS ONE ACCORDING TO THE WIKI INSTRUCTIONS. +######################################################################################## + +# Please note not all available settings / options are set here. +# For a full list, see the wiki +# autogenerated = 1 # remove this line to remove the warning + + + +# █▀▄▀█ █▀█ █▄░█ █ ▀█▀ █▀█ █▀█ +# █░▀░█ █▄█ █░▀█ █ ░█░ █▄█ █▀▄ + +# See https://wiki.hyprland.org/Configuring/Monitors/ + +# monitor = DP-1, 2560x1080@144, 0x0, 1 +monitor = ,preferred,auto,auto + + + +# █░░ ▄▀█ █░█ █▄░█ █▀▀ █░█ +# █▄▄ █▀█ █▄█ █░▀█ █▄▄ █▀█ + +# See https://wiki.hyprland.org/Configuring/Keywords/ for more +# Execute your favorite apps at launch + +exec-once = dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP # for XDPH +exec-once = systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP # for XDPH +exec-once = /usr/lib/polkit-kde-authentication-agent-1 # authentication dialogue for GUI apps +exec-once = waybar # launch the system panel +exec-once = blueman-applet # systray app for BT +exec-once = nm-applet --indicator # systray app for Network/Wifi +exec-once = dunst # start notification demon +exec-once = wl-paste --type text --watch cliphist store # clipboard store text data +exec-once = wl-paste --type image --watch cliphist store # clipboard store image data +exec-once = fcitx5 +exec-once = ~/.config/swww/swwwallpaper.sh # start wallpaper daemon +exec-once = ~/.config/hypr/scripts/resetxdgportal.sh # reset XDPH for screenshare +#exec-once = swayidle -w timeout 900 'hyprctl dispatch dpms off' resume 'hyprctl dispatch dpms on' # turn off monitor after 15 mins + + + +# █ █▄░█ █▀█ █░█ ▀█▀ +# █ █░▀█ █▀▀ █▄█ ░█░ + +# For all categories, see https://wiki.hyprland.org/Configuring/Variables/ + +input { + kb_layout = us + kb_variant = + kb_model = + kb_options = + kb_rules = + follow_mouse = 1 + + touchpad { + natural_scroll = no + } + + sensitivity = 0 # -1.0 - 1.0, 0 means no modification. + force_no_accel = 1 + numlock_by_default = true +} + +# Example per-device config +# See https://wiki.hyprland.org/Configuring/Keywords/#executing for more + +device:epic mouse V1 { + sensitivity = -0.5 +} + +# See https://wiki.hyprland.org/Configuring/Variables/ for more + +gestures { + workspace_swipe = true + workspace_swipe_fingers = 3 +} + + + +# █░░ ▄▀█ █▄█ █▀█ █░█ ▀█▀ █▀ +# █▄▄ █▀█ ░█░ █▄█ █▄█ ░█░ ▄█ + +# See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more + +dwindle { + pseudotile = yes # master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below + preserve_split = yes # you probably want this +} + +# See https://wiki.hyprland.org/Configuring/Master-Layout/ for more + +master { + new_is_master = true +} + + + + +# █▀ █▀█ █░█ █▀█ █▀▀ █▀▀ +# ▄█ █▄█ █▄█ █▀▄ █▄▄ ██▄ + +# Source a file (multi-file configs) +# source = ~/.config/hypr/myColors.conf + +source = ~/.config/hypr/animations.conf +source = ~/.config/hypr/keybindings.conf +source = ~/.config/hypr/windowrules.conf +source = ~/.config/hypr/theme.conf +source = ~/.config/hypr/monitors.conf # initially empty, to be configured by user and remains static +source = ~/.config/hypr/userprefs.conf # initially empty, to be configured by user and remains static + +# Note: as userprefs.conf is sourced at the end, settings configured in this file will override the defaults + diff --git a/modules/home/hyprland/conf/hypr/keybindings.conf b/modules/home/hyprland/conf/hypr/keybindings.conf new file mode 100644 index 0000000..eaa337e --- /dev/null +++ b/modules/home/hyprland/conf/hypr/keybindings.conf @@ -0,0 +1,141 @@ +# █▄▀ █▀▀ █▄█ █▄▄ █ █▄░█ █▀▄ █ █▄░█ █▀▀ █▀ +# █░█ ██▄ ░█░ █▄█ █ █░▀█ █▄▀ █ █░▀█ █▄█ ▄█ + + +# See https://wiki.hyprland.org/Configuring/Keywords/ for more +# Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more + +################################################ +# Main modifier +################################################ +$mainMod = SUPER # windows key + +################################################ +# Main actions +################################################ +bind = $mainMod, Q, exec, ~/.config/hypr/scripts/dontkillsteam.sh # killactive, # kill the window on focus +bind = $mainMod, delete, exit, # kill hyperland session +bind = $mainMod, esc, exit, # kill hyperland session +bind = $mainMod, F, togglefloating, # toggle the window on focus to float +bind = $mainMod, L, exec, swaylock # lock screen +bind = $mainMod, P, pseudo, # dwindle +bind = $mainMod, S, togglesplit, # split screen +bind = ALT, return, fullscreen, # toggle the window on focus to fullscreen + +# Application shortcuts +bind = $mainMod, grave, exec, kitty # ~ open terminal +bind = $mainMod, E, exec, dolphin # open file manager +bind = $mainMod, V, exec, code # open vscode + +################################################ +# Control actions +################################################ +# Rofi is toggled on/off if you repeat the key presses +bind = $mainMod, SPACE, exec, pkill rofi || ~/.config/hypr/scripts/rofilaunch.sh d # launch desktop applications +bind = $mainMod, tab, exec, pkill rofi || ~/.config/hypr/scripts/rofilaunch.sh w # switch between desktop applications +bind = $mainMod, R, exec, pkill rofi || ~/.config/hypr/scripts/rofilaunch.sh f # browse system files + +# Audio control +# bind = , F10, exec, ~/.config/hypr/scripts/volumecontrol.sh -o m # toggle audio mute +# binde = , F11, exec, ~/.config/hypr/scripts/volumecontrol.sh -o d # decrease volume +# binde = , F12, exec, ~/.config/hypr/scripts/volumecontrol.sh -o i # increase volume +bind = , XF86AudioMute, exec, ~/.config/hypr/scripts/volumecontrol.sh -o m # toggle audio mute +bind = , XF86AudioMicMute, exec, ~/.config/hypr/scripts/volumecontrol.sh -i m # toggle microphone mute +binde = , XF86AudioLowerVolume, exec, ~/.config/hypr/scripts/volumecontrol.sh -o d # decrease volume +binde = , XF86AudioRaiseVolume, exec, ~/.config/hypr/scripts/volumecontrol.sh -o i # increase volume +bind = , XF86AudioPlay, exec, playerctl play-pause +bind = , XF86AudioPause, exec, playerctl play-pause +bind = , XF86AudioNext, exec, playerctl next +bind = , XF86AudioPrev, exec, playerctl previous + +# Brightness control +binde = , XF86MonBrightnessUp, exec, ~/.config/hypr/scripts/brightnesscontrol.sh i # increase brightness +binde = , XF86MonBrightnessDown, exec, ~/.config/hypr/scripts/brightnesscontrol.sh d # decrease brightness + +# Screenshot/screencapture +bind = $mainMod, P, exec, ~/.config/hypr/scripts/screenshot.sh s # screenshot snip +bind = $mainMod ALT, P, exec, ~/.config/hypr/scripts/screenshot.sh p # print current screen +bind = $CONTROL SHIFT, P, pass, ^(com\.obsproject\.Studio)$ # start/stop obs screen recording + + +################################################ +# Exec custom scripts +################################################ +bind = $mainMod, backspace, exec, ~/.config/hypr/scripts/logoutlaunch.sh 1 # logout menu +bind = $mainMod, G, exec, ~/.config/hypr/scripts/gamemode.sh # disable hypr effects for gamemode + + + +################################################ +# Window actions +################################################ +# Move focus with mainMod + arrow keys +bind = $mainMod, left, movefocus, l +bind = $mainMod, right, movefocus, r +bind = $mainMod, up, movefocus, u +bind = $mainMod, down, movefocus, d +bind = ALT, Tab, movefocus, d + +# Resize windows +binde = $mainMod CONTROL, right, resizeactive, 10 0 +binde = $mainMod CONTROL, left, resizeactive, -10 0 +binde = $mainMod CONTROL, up, resizeactive, 0 -10 +binde = $mainMod CONTROL, down, resizeactive, 0 10 + +# Move Window with mainMod + SHIFT + arrow keys +bind = $mainMod SHIFT, left, movewindow, l +bind = $mainMod SHIFT, right, movewindow, r +bind = $mainMod SHIFT, up, movewindow, u +bind = $mainMod SHIFT, down, movewindow, d + +# Move/resize windows with mainMod + LMB/RMB and dragging +bindm = $mainMod, mouse:272, movewindow +bindm = $mainMod, mouse:273, resizewindow + + +################################################ +# Workspace actions +################################################ +# Switch workspaces with mainMod + [0-9] +bind = $mainMod, 1, workspace, 1 +bind = $mainMod, 2, workspace, 2 +bind = $mainMod, 3, workspace, 3 +bind = $mainMod, 4, workspace, 4 +bind = $mainMod, 5, workspace, 5 +bind = $mainMod, 6, workspace, 6 +bind = $mainMod, 7, workspace, 7 +bind = $mainMod, 8, workspace, 8 +bind = $mainMod, 9, workspace, 9 +bind = $mainMod, 0, workspace, 10 + +# Move active window to a workspace with mainMod + SHIFT + [0-9] +bind = $mainMod SHIFT, 1, movetoworkspace, 1 +bind = $mainMod SHIFT, 2, movetoworkspace, 2 +bind = $mainMod SHIFT, 3, movetoworkspace, 3 +bind = $mainMod SHIFT, 4, movetoworkspace, 4 +bind = $mainMod SHIFT, 5, movetoworkspace, 5 +bind = $mainMod SHIFT, 6, movetoworkspace, 6 +bind = $mainMod SHIFT, 7, movetoworkspace, 7 +bind = $mainMod SHIFT, 8, movetoworkspace, 8 +bind = $mainMod SHIFT, 9, movetoworkspace, 9 +bind = $mainMod SHIFT, 0, movetoworkspace, 10 + +# Move window to workspace Super + Alt + [0-9] +bind = $mainMod ALT, 1, movetoworkspacesilent, 1 +bind = $mainMod ALT, 2, movetoworkspacesilent, 2 +bind = $mainMod ALT, 3, movetoworkspacesilent, 3 +bind = $mainMod ALT, 4, movetoworkspacesilent, 4 +bind = $mainMod ALT, 5, movetoworkspacesilent, 5 +bind = $mainMod ALT, 6, movetoworkspacesilent, 6 +bind = $mainMod ALT, 7, movetoworkspacesilent, 7 +bind = $mainMod ALT, 8, movetoworkspacesilent, 8 +bind = $mainMod ALT, 9, movetoworkspacesilent, 9 +bind = $mainMod ALT, 0, movetoworkspacesilent, 10 + +# Special workspaces (scratchpad) +bind = $mainMod ALT, S, movetoworkspacesilent, special +bind = $mainMod CONTROL, S, togglespecialworkspace, + +# Scroll through existing workspaces with mainMod + scroll +bind = $mainMod, mouse_down, workspace, e+1 +bind = $mainMod, mouse_up, workspace, e-1 \ No newline at end of file diff --git a/modules/home/hyprland/conf/hypr/monitors.conf b/modules/home/hyprland/conf/hypr/monitors.conf new file mode 100644 index 0000000..2ca27a4 --- /dev/null +++ b/modules/home/hyprland/conf/hypr/monitors.conf @@ -0,0 +1,24 @@ + +# █▀▄▀█ █▀█ █▄░█ █ ▀█▀ █▀█ █▀█ █▀ +# █░▀░█ █▄█ █░▀█ █ ░█░ █▄█ █▀▄ ▄█ + +# See https://wiki.hyprland.org/Configuring/Monitors/ + +# monitor = name, resolution, offset, scale, extra-args +# monitor = ,preferred,auto,auto +monitor = DP-3,1920x1080@60,0x0,1,transform,1 +monitor = HDMI-A-1,1920x1080@60,1080x0,1, +monitor = HDMI-A-3,1920x1080@60,3000x0,1, + +workspace = 5,monitor:DP-3 +workspace = 6,monitor:DP-3 +workspace = 7,monitor:DP-3 + +workspace = 1,monitor:HDMI-A-1 +workspace = 2,monitor:HDMI-A-1 +workspace = 3,monitor:HDMI-A-1 +workspace = 4,monitor:HDMI-A-1 + +workspace = 8,monitor:HDMI-A-3 +workspace = 9,monitor:HDMI-A-3 +workspace = 10,monitor:HDMI-A-3 \ No newline at end of file diff --git a/modules/home/hyprland/conf/hypr/nvidia.conf b/modules/home/hyprland/conf/hypr/nvidia.conf new file mode 100644 index 0000000..d25c019 --- /dev/null +++ b/modules/home/hyprland/conf/hypr/nvidia.conf @@ -0,0 +1,11 @@ + +# █▄░█ █░█ █ █▀▄ █ ▄▀█ +# █░▀█ ▀▄▀ █ █▄▀ █ █▀█ + +#env = GBM_BACKEND,nvidia-drm +env = LIBVA_DRIVER_NAME,nvidia +env = __GLX_VENDOR_LIBRARY_NAME,nvidia +env = __GL_VRR_ALLOWED,1 +env = WLR_NO_HARDWARE_CURSORS,1 +env = WLR_DRM_NO_ATOMIC,1 + diff --git a/modules/home/hyprland/conf/hypr/scripts/brightnesscontrol.sh b/modules/home/hyprland/conf/hypr/scripts/brightnesscontrol.sh new file mode 100755 index 0000000..8001a90 --- /dev/null +++ b/modules/home/hyprland/conf/hypr/scripts/brightnesscontrol.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +ncolor="-h string:bgcolor:#343d46 -h string:fgcolor:#c0c5ce -h string:frcolor:#c0c5ce" + +function send_notification { + brightness=`brightnessctl info | grep -oP "(?<=\()\d+(?=%)" | cat` + brightinfo=$(brightnessctl info | awk -F"'" '/Device/ {print $2}') + + angle="$(((($brightness + 2) / 5) * 5))" + ico="~/.config/dunst/icons/vol/vol-${angle}.svg" + bar=$(seq -s "." $(($brightness / 15)) | sed 's/[0-9]//g') + + if [ $brightness -ne 0 ]; then + dunstify $ncolor "brightctl" -i $ico -a "$brightness$bar" "Device: $brightinfo" -r 91190 -t 800 + + else + dunstify -i $ico "Brightness: ${brightness}%" -a "$brightinfo" -u low -r 91190 -t 800 + fi + +} + +function get_brightness { + brightnessctl -m | grep -o '[0-9]\+%' | head -c-2 +} + +case $1 in +i) + # increase the backlight by 5% + brightnessctl set +5% + send_notification + ;; +d) + if [[ $(get_brightness) -lt 5 ]]; then + # avoid 0% brightness + brightnessctl set 1% + else + # decrease the backlight by 5% + brightnessctl set 5%- + fi + send_notification + ;; +esac diff --git a/modules/home/hyprland/conf/hypr/scripts/cliphist.sh b/modules/home/hyprland/conf/hypr/scripts/cliphist.sh new file mode 100755 index 0000000..3f5208d --- /dev/null +++ b/modules/home/hyprland/conf/hypr/scripts/cliphist.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env sh + +theme_file="$HOME/.config/hypr/themes/theme.conf" +roconf="~/.config/rofi/clipboard.rasi" + + +# set position + +case $2 in + 1) # top left + pos="window {location: north west; anchor: north west; x-offset: 20px; y-offset: 20px;}" + ;; + 2) # top right + pos="window {location: north east; anchor: north east; x-offset: -20px; y-offset: 20px;}" + ;; + 3) # bottom left + pos="window {location: south east; anchor: south east; x-offset: -20px; y-offset: -20px;}" + ;; + 4) # bottom right + pos="window {location: south west; anchor: south west; x-offset: 20px; y-offset: -20px;}" + ;; +esac + + +# read hypr theme border + +hypr_border=`awk -F '=' '{if($1~" rounding ") print $2}' $theme_file | sed 's/ //g'` +hypr_width=`awk -F '=' '{if($1~" border_size ") print $2}' $theme_file | sed 's/ //g'` +wind_border=$(( hypr_border * 3/2 )) +elem_border=`[ $hypr_border -eq 0 ] && echo "5" || echo $hypr_border` +r_override="window {border: ${hypr_width}px; border-radius: ${wind_border}px;} entry {border-radius: ${elem_border}px;} element {border-radius: ${elem_border}px;}" + + +# read hypr font size + +#fnt_size=`awk '{if($6=="monospace-font-name") print $NF}' $theme_file | sed "s/'//g"` +fnt_override=`gsettings get org.gnome.desktop.interface monospace-font-name | awk '{gsub(/'\''/,""); print $NF}'` +fnt_override="configuration {font: \"JetBrainsMono Nerd Font ${fnt_override}\";}" + + +# clipboard action + +case $1 in + c) cliphist list | rofi -dmenu -theme-str "entry { placeholder: \"Copy...\";} ${pos} ${r_override}" -theme-str "${fnt_override}" -config $roconf | cliphist decode | wl-copy + ;; + d) cliphist list | rofi -dmenu -theme-str "entry { placeholder: \"Delete...\";} ${pos} ${r_override}" -theme-str "${fnt_override}" -config $roconf | cliphist delete + ;; + w) if [ `echo -e "Yes\nNo" | rofi -dmenu -theme-str "entry { placeholder: \"Clear Clipboard History?\";} ${pos} ${r_override}" -theme-str "${fnt_override}" -config $roconf` == "Yes" ] ; then + cliphist wipe + fi + ;; + *) echo -e "cliphist.sh [action] [position]\nwhere action," + echo "c : cliphist list and copy selected" + echo "d : cliphist list and delete selected" + echo "w : cliphist wipe database" + echo "where position," + echo "1 : top left" + echo "2 : top right" + echo "3 : bottom right" + echo "4 : bottom left" + exit 1 + ;; +esac + diff --git a/modules/home/hyprland/conf/hypr/scripts/dontkillsteam.sh b/modules/home/hyprland/conf/hypr/scripts/dontkillsteam.sh new file mode 100755 index 0000000..d162ddc --- /dev/null +++ b/modules/home/hyprland/conf/hypr/scripts/dontkillsteam.sh @@ -0,0 +1,5 @@ +if [[ $(hyprctl activewindow -j | jq -r ".class") == "Steam" ]]; then + xdotool windowunmap $(xdotool getactivewindow) +else + hyprctl dispatch killactive "" +fi diff --git a/modules/home/hyprland/conf/hypr/scripts/gamemode.sh b/modules/home/hyprland/conf/hypr/scripts/gamemode.sh new file mode 100755 index 0000000..ad0bd89 --- /dev/null +++ b/modules/home/hyprland/conf/hypr/scripts/gamemode.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env sh +HYPRGAMEMODE=$(hyprctl getoption animations:enabled | sed -n '2p' | awk '{print $2}') +if [ $HYPRGAMEMODE = 1 ] ; then + hyprctl --batch "\ + keyword animations:enabled 0;\ + keyword decoration:drop_shadow 0;\ + keyword decoration:blur:enabled 0;\ + keyword general:gaps_in 0;\ + keyword general:gaps_out 0;\ + keyword general:border_size 1;\ + keyword decoration:rounding 0" + exit +fi +hyprctl reload diff --git a/modules/home/hyprland/conf/hypr/scripts/logoutlaunch.sh b/modules/home/hyprland/conf/hypr/scripts/logoutlaunch.sh new file mode 100755 index 0000000..a596e89 --- /dev/null +++ b/modules/home/hyprland/conf/hypr/scripts/logoutlaunch.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env sh + +# detect monitor y res +res=`cat /sys/class/drm/*/modes | head -1 | cut -d 'x' -f 2` + +# scale config layout and style +case $1 in + 1) wlColms=6 + export mgn=$(( res * 10 / 100 )) + export hvr=$(( res * 5 / 100 )) ;; + 2) wlColms=2 + export mgn=$(( res * 8 / 100 )) + export mgn2=$(( res * 65 / 100 )) + export hvr=$(( res * 3 / 100 )) + export hvr2=$(( res * 60 / 100 )) ;; + *) echo "Error: invalid parameter passed..." + exit 1 ;; +esac + +# scale font size +export fntSize=$(( res * 2 / 100 )) + +# detect gtk system theme +export gtkThm="Catppuccin-Latte" #`gsettings get org.gnome.desktop.interface gtk-theme | sed "s/'//g"` +export csMode=`gsettings get org.gnome.desktop.interface color-scheme | sed "s/'//g" | awk -F '-' '{print $2}'` +export BtnCol=`[ "$csMode" == "dark" ] && ( echo "black" ) || ( echo "white" )` +export BtnBkg=`[ "$csMode" == "dark" ] && ( echo "color" ) || ( echo "bg" )` +export WindBg=`[ "$csMode" == "dark" ] && ( echo "rgba(0,0,0,0.5)" ) || ( echo "rgba(255,255,255,0.6)" )` +export wbarTheme="$HOME/.config/waybar/themes/${gtkThm}.css" + +# eval hypr border radius +hyprTheme="$HOME/.config/hypr/themes/${gtkThm}.conf" +hypr_border=`awk -F '=' '{if($1~" rounding ") print $2}' $hyprTheme | sed 's/ //g'` +export active_rad=$(( hypr_border * 5 )) +export button_rad=$(( hypr_border * 8 )) + +# set file variables +wLayout="$HOME/.config/wlogout/layout_$1" +wlTmplt="$HOME/.config/wlogout/style_$1.css" + +# eval config files +wlStyle=`envsubst < $wlTmplt` + +# eval padding +y_pad=$(( res * 20 / 100 )) + +# launch wlogout +wlogout -b $wlColms -c 0 -r 0 -T $y_pad -B $y_pad --layout $wLayout --css <(echo "$wlStyle") --protocol layer-shell + diff --git a/modules/home/hyprland/conf/hypr/scripts/modeswitch.sh b/modules/home/hyprland/conf/hypr/scripts/modeswitch.sh new file mode 100755 index 0000000..86898ae --- /dev/null +++ b/modules/home/hyprland/conf/hypr/scripts/modeswitch.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env sh + +## main script ## +CFGDIR="$HOME/.config" +X_MODE=$1 + +## check mode ## +if [ "$X_MODE" == "dark" ] || [ "$X_MODE" == "light" ] ; then + S_MODE="$X_MODE" + +elif [ "$X_MODE" == "switch" ] ; then + X_MODE=`readlink $CFGDIR/swww/wall.set | awk -F "." '{print $NF}'` + + if [ "$X_MODE" == "dark" ] ; then + S_MODE="light" + flatpak --user override --env=GTK_THEME=Catppuccin-Latte + + elif [ "$X_MODE" == "light" ] ; then + S_MODE="dark" + flatpak --user override --env=GTK_THEME=Catppuccin-Mocha + + else + echo "ERROR: unable to fetch wallpaper mode." + fi + +else + echo "ERROR: unknown mode, use 'dark', 'light' or 'switch'." + exit 1 +fi + +### hyprland ### +ln -fs $CFGDIR/hypr/${S_MODE}.conf $CFGDIR/hypr/theme.conf +hyprctl reload + +### swwwallpaper ### +x=`echo $S_MODE | cut -c 1` +$CFGDIR/swww/swwwallpaper.sh -$x + +### qt5ct ### +ln -fs $CFGDIR/qt5ct/colors/${S_MODE}.conf $CFGDIR/qt5ct/colors/theme.conf + +### rofi ### +ln -fs $CFGDIR/rofi/${S_MODE}.rasi $CFGDIR/rofi/theme.rasi + +### kitty ### +ln -fs $CFGDIR/kitty/${S_MODE}.conf $CFGDIR/kitty/theme.conf +killall -SIGUSR1 kitty + +### waybar ### +ln -fs $CFGDIR/waybar/${S_MODE}.css $CFGDIR/waybar/style.css +sleep 1 +killall -SIGUSR2 waybar diff --git a/modules/home/hyprland/conf/hypr/scripts/resetxdgportal.sh b/modules/home/hyprland/conf/hypr/scripts/resetxdgportal.sh new file mode 100755 index 0000000..32983ec --- /dev/null +++ b/modules/home/hyprland/conf/hypr/scripts/resetxdgportal.sh @@ -0,0 +1,12 @@ +#!/bin/bash +sleep 1 +killall xdg-desktop-portal-hyprland +killall xdg-desktop-portal-gnome +killall xdg-desktop-portal-kde +killall xdg-desktop-portal-lxqt +killall xdg-desktop-portal-wlr +killall xdg-desktop-portal +sleep 1 +/usr/lib/xdg-desktop-portal-hyprland & +sleep 2 +/usr/lib/xdg-desktop-portal & diff --git a/modules/home/hyprland/conf/hypr/scripts/rofilaunch.sh b/modules/home/hyprland/conf/hypr/scripts/rofilaunch.sh new file mode 100755 index 0000000..2441e36 --- /dev/null +++ b/modules/home/hyprland/conf/hypr/scripts/rofilaunch.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env sh + +theme_file="$HOME/.config/hypr/themes/theme.conf" +rofi_conf="~/.config/rofi/config.rasi" + + +# rofi action + +case $1 in + d) r_mode="drun" ;; + w) r_mode="window" ;; + f) r_mode="filebrowser" ;; + h) echo -e "rofilaunch.sh [action]\nwhere action," + echo "d : drun mode" + echo "w : window mode" + echo "f : filebrowser mode," + exit 0 ;; + *) r_mode="drun" ;; +esac + + +# read hypr theme border + +hypr_border=`awk -F '=' '{if($1~" rounding ") print $2}' $theme_file | sed 's/ //g'` +hypr_width=`awk -F '=' '{if($1~" border_size ") print $2}' $theme_file | sed 's/ //g'` +wind_border=$(( hypr_border * 3 )) +elem_border=`[ $hypr_border -eq 0 ] && echo "10" || echo $(( hypr_border * 2 ))` +r_override="window {border: ${hypr_width}px; border-radius: ${wind_border}px;} element {border-radius: ${elem_border}px;}" + + +# read hypr font size + +#fnt_size=`awk '{if($6=="font-name") print $NF}' $theme_file | sed "s/'//g"` +fnt_override=`gsettings get org.gnome.desktop.interface font-name | awk '{gsub(/'\''/,""); print $NF}'` +fnt_override="configuration {font: \"JetBrainsMono Nerd Font ${fnt_override}\";}" + + +# read hypr theme icon + +icon_override=`gsettings get org.gnome.desktop.interface icon-theme | sed "s/'//g"` +icon_override="configuration {icon-theme: \"${icon_override}\";}" + + +# launch rofi + +rofi -show $r_mode -theme-str "${fnt_override}" -theme-str "${r_override}" -theme-str "${icon_override}" -config "${rofi_conf}" + + diff --git a/modules/home/hyprland/conf/hypr/scripts/rofiselect.sh b/modules/home/hyprland/conf/hypr/scripts/rofiselect.sh new file mode 100755 index 0000000..8e43c3c --- /dev/null +++ b/modules/home/hyprland/conf/hypr/scripts/rofiselect.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env sh + +## set variables ## +BaseDir=`dirname $(realpath $0)` +ThemeSet="$HOME/.config/hypr/themes/theme.conf" +RofiConf="$HOME/.config/rofi/themeselect.rasi" +RofiStyle="$HOME/.config/rofi/styles" +Rofilaunch="$HOME/.config/rofi/config.rasi" + +## show and apply theme ## +hypr_border=`awk -F '=' '{if($1~" rounding ") print $2}' $ThemeSet | sed 's/ //g'` +elem_border=$(( hypr_border * 5 )) +icon_border=$(( elem_border - 5 )) +r_override="element {border-radius: ${elem_border}px;} element-icon {border-radius: ${icon_border}px;}" + +RofiSel=$( ls $RofiStyle/style_*.rasi | awk -F '/' '{print $NF}' | cut -d '.' -f 1 | while read rstyle +do + echo -en "$rstyle\x00icon\x1f$RofiStyle/${rstyle}.png\n" +done | rofi -dmenu -theme-str "${r_override}" -config $RofiConf) + +if [ ! -z $RofiSel ] ; then + cp $RofiStyle/$RofiSel.rasi $Rofilaunch +fi + diff --git a/modules/home/hyprland/conf/hypr/scripts/screenshot.sh b/modules/home/hyprland/conf/hypr/scripts/screenshot.sh new file mode 100755 index 0000000..bdcd4fa --- /dev/null +++ b/modules/home/hyprland/conf/hypr/scripts/screenshot.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env sh + +if [ -z "$XDG_PICTURES_DIR" ] ; then + XDG_PICTURES_DIR="$HOME/Pictures" +fi + +save_dir="${2:-$XDG_PICTURES_DIR}" +save_file=$(date +'%y%m%d_%Hh%Mm%Ss_screenshot.png') +ncolor="-h string:bgcolor:#343d46 -h string:fgcolor:#c0c5ce -h string:frcolor:#c0c5ce" + +if [ ! -d "$save_dir" ] ; then + mkdir -p $save_dir +fi + +case $1 in +p) grim $save_dir/$save_file ;; +s) grim -g "$(slurp)" - | swappy -f - ;; +*) echo "...valid options are..." + echo "p : print screen to $save_dir" + echo "s : snip current screen to $save_dir" + exit 1 ;; +esac + +if [ -f "$save_dir/$save_file" ] ; then + dunstify $ncolor "theme" -a "saved in $save_dir" -i "$save_dir/$save_file" -r 91190 -t 2200 +fi diff --git a/modules/home/hyprland/conf/hypr/scripts/systemupdate.sh b/modules/home/hyprland/conf/hypr/scripts/systemupdate.sh new file mode 100755 index 0000000..22e4784 --- /dev/null +++ b/modules/home/hyprland/conf/hypr/scripts/systemupdate.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +# Check release +if [ ! -f /etc/arch-release ] ; then + exit 0 +fi + +# Check for updates +aur=$(yay -Qua | wc -l) +ofc=$(pacman -Qu | wc -l) + +# Calculate total available updates +upd=$(( ofc + aur )) +echo "$upd" + +# Show tooltip +if [ $upd -eq 0 ] ; then + echo " Packages are up to date" +else + echo "󱓽 Official $ofc 󱓾 AUR $aur" +fi + +# Trigger upgrade +if [ "$1" == "up" ] ; then + kitty --title systemupdate sh -c 'yay -Syu' +fi + diff --git a/modules/home/hyprland/conf/hypr/scripts/themeselect.sh b/modules/home/hyprland/conf/hypr/scripts/themeselect.sh new file mode 100755 index 0000000..6384166 --- /dev/null +++ b/modules/home/hyprland/conf/hypr/scripts/themeselect.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env sh + +## set variables ## +BaseDir=`dirname $(realpath $0)` +ThemeCtl="$HOME/.config/swww/wall.ctl" +ThumbDir="$HOME/.config/swww/Themes-Ctl" +RofiConf="$HOME/.config/rofi/themeselect.rasi" +ThemeSet="$HOME/.config/hypr/themes/theme.conf" + + +## show and apply theme ## +if [ -z "$1" ] ; then + + hypr_border=`awk -F '=' '{if($1~" rounding ") print $2}' $ThemeSet | sed 's/ //g'` + elem_border=$(( hypr_border * 5 )) + icon_border=$(( elem_border - 5 )) + r_override="element {border-radius: ${elem_border}px;} element-icon {border-radius: ${icon_border}px;}" + + ThemeSel=$(cat $ThemeCtl | while read line + do + thm=`echo $line | cut -d '|' -f 2` + wal=`echo $line | cut -d '|' -f 3` + echo -en "$thm\x00icon\x1f$ThumbDir/${thm}.png\n" + done | rofi -dmenu -theme-str "${r_override}" -config $RofiConf) + + if [ ! -z $ThemeSel ] ; then + ${BaseDir}/themeswitch.sh -s $ThemeSel + fi + +## regenerate thumbnails ## +elif [ "$1" == "T" ] ; then + + echo "refreshing thumbnails..." + cat $ThemeCtl | while read line + do + thm=`echo $line | cut -d '|' -f 2` + wal=`echo $line | cut -d '|' -f 3` + wal=`eval echo $wal` + + echo "croping image from wallpaper $ThumbDir/${thm}.png..." + convert $wal -thumbnail 500x500^ -gravity center -extent 500x500 $ThumbDir/${thm}.png + #convert $wal -gravity Center -crop 1080x1080+0+0 $ThumbDir/${thm}.png + #echo "applying rounded corner mask and generating $ThumbDir/${thm}.png..." + #convert -size 1080x1080 xc:none -draw "roundrectangle 0,0,1080,1080,80,80" $ThumbDir/roundedmask.png + #convert $ThumbDir/${thm}_tmp.png -matte $ThumbDir/roundedmask.png -compose DstIn -composite $ThumbDir/${thm}.png + done + +fi + diff --git a/modules/home/hyprland/conf/hypr/scripts/themeswitch.sh b/modules/home/hyprland/conf/hypr/scripts/themeswitch.sh new file mode 100755 index 0000000..b67c898 --- /dev/null +++ b/modules/home/hyprland/conf/hypr/scripts/themeswitch.sh @@ -0,0 +1,125 @@ +#!/usr/bin/env sh + +# set variables +BaseDir=`dirname $(realpath $0)` +ConfDir="$HOME/.config" +ThemeCtl="$ConfDir/swww/wall.ctl" + + +# evaluate options +while getopts "npst" option ; do + case $option in + + n ) # set next theme + ThemeSet=`head -1 $ThemeCtl | cut -d '|' -f 2` #default value + flg=0 + while read line + do + if [ $flg -eq 1 ] ; then + ThemeSet=`echo $line | cut -d '|' -f 2` + break + elif [ `echo $line | cut -d '|' -f 1` -eq 1 ] ; then + flg=1 + fi + done < $ThemeCtl + export xtrans="center" ;; + + p ) # set previous theme + ThemeSet=`tail -1 $ThemeCtl | cut -d '|' -f 2` #default value + flg=0 + while read line + do + if [ $flg -eq 1 ] ; then + ThemeSet=`echo $line | cut -d '|' -f 2` + break + elif [ `echo $line | cut -d '|' -f 1` -eq 1 ] ; then + flg=1 + fi + done < <( tac $ThemeCtl ) + export xtrans="outer" ;; + + s ) # set selected theme + shift $((OPTIND -1)) + ThemeSet=$1 ;; + + t ) # display tooltip + echo "" + echo "󰆊 Next/Previous Theme" + exit 0 ;; + + * ) # invalid option + echo "n : set next theme" + echo "p : set previous theme" + echo "s : set theme from parameter" + echo "t : display tooltip" + exit 1 ;; + esac +done + + +# update theme control +if [ `cat $ThemeCtl | awk -F '|' -v thm=$ThemeSet '{if($2==thm) print$2}' | wc -w` -ne 1 ] ; then + echo "Unknown theme selected: $ThemeSet" + echo "Available themes are:" + cat $ThemeCtl | cut -d '|' -f 2 + exit 1 +else + echo "Selected theme: $ThemeSet" + sed -i "s/^1/0/g" $ThemeCtl + awk -F '|' -v thm=$ThemeSet '{OFS=FS} {if($2==thm) $1=1; print$0}' $ThemeCtl > $BaseDir/tmp && mv $BaseDir/tmp $ThemeCtl +fi + + +# swwwallpaper +getWall=`grep '^1|' $ThemeCtl | cut -d '|' -f 3` +getWall=`eval echo $getWall` +ln -fs $getWall $ConfDir/swww/wall.set +$ConfDir/swww/swwwallpaper.sh + +if [ $? -ne 0 ] ; then + echo "ERROR: Unable to set wallpaper" + exit 1 +fi + + +# vs code +sed -i "/workbench.colorTheme/c\ \"workbench.colorTheme\": \"${ThemeSet}\"," $ConfDir/Code/User/settings.json + + +# kitty +ln -fs $ConfDir/kitty/themes/${ThemeSet}.conf $ConfDir/kitty/themes/theme.conf +killall -SIGUSR1 kitty + + +# qt5ct +sed -i "/^color_scheme_path=/c\color_scheme_path=$ConfDir/qt5ct/colors/${ThemeSet}.conf" $ConfDir/qt5ct/qt5ct.conf +IconSet=`awk -F "'" '$0 ~ /gsettings set org.gnome.desktop.interface icon-theme/{print $2}' $ConfDir/hypr/themes/${ThemeSet}.conf` +sed -i "/^icon_theme=/c\icon_theme=${IconSet}" $ConfDir/qt5ct/qt5ct.conf + + +# flatpak GTK +flatpak --user override --env=GTK_THEME="${ThemeSet}" +flatpak --user override --env=ICON_THEME="${IconSet}" + + +# rofi +ln -fs $ConfDir/rofi/themes/${ThemeSet}.rasi $ConfDir/rofi/themes/theme.rasi + + +# hyprland +ln -fs $ConfDir/hypr/themes/${ThemeSet}.conf $ConfDir/hypr/themes/theme.conf +hyprctl reload + + +# refresh thumbnails +$BaseDir/themeselect.sh T & + + +# send notification +ncolor="-h string:bgcolor:#343d46 -h string:fgcolor:#c0c5ce -h string:frcolor:#c0c5ce" +dunstify $ncolor "theme" -a " ${ThemeSet}" -i "~/.config/dunst/icons/paint.svg" -r 91190 -t 2200 + + +# waybar +$ConfDir/waybar/wbarconfgen.sh + diff --git a/modules/home/hyprland/conf/hypr/scripts/volumecontrol.sh b/modules/home/hyprland/conf/hypr/scripts/volumecontrol.sh new file mode 100755 index 0000000..39ee5c9 --- /dev/null +++ b/modules/home/hyprland/conf/hypr/scripts/volumecontrol.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env sh + + +# define functions + +function print_error +{ +cat << "EOF" + ./volumecontrol.sh -[device] + ...valid device are... + i -- [i]nput decive + o -- [o]utput device + ...valid actions are... + i -- ncrease volume [+5] + d -- ecrease volume [-5] + m -- ute [x] +EOF +exit 1 +} + +function notify_vol +{ + vol=`pamixer $srce --get-volume | cat` + angle="$(( (($vol+2)/5) * 5 ))" + ico="${icodir}/vol-${angle}.svg" + bar=$(seq -s "." $(($vol / 15)) | sed 's/[0-9]//g') + dunstify $ncolor "volctl" -a "$vol$bar" "$nsink" -i $ico -r 91190 -t 800 +} + +function notify_mute +{ + mute=`pamixer $srce --get-mute | cat` + if [ "$mute" == "true" ] ; then + dunstify $ncolor "volctl" -a "muted" "$nsink" -i ${icodir}/muted-${dvce}.svg -r 91190 -t 800 + else + dunstify $ncolor "volctl" -a "unmuted" "$nsink" -i ${icodir}/unmuted-${dvce}.svg -r 91190 -t 800 + fi +} + + +# set device source + +while getopts io SetSrc +do + case $SetSrc in + i) nsink=$(pamixer --list-sources | grep "_input." | head -1 | awk -F '" "' '{print $NF}' | sed 's/"//') + srce="--default-source" + dvce="mic" ;; + o) nsink=$(pamixer --get-default-sink | grep "_output." | awk -F '" "' '{print $NF}' | sed 's/"//') + srce="" + dvce="speaker" ;; + esac +done + +if [ $OPTIND -eq 1 ] ; then + print_error +fi + + +# set device action + +shift $((OPTIND -1)) +step="${2:-5}" +icodir="~/.config/dunst/icons/vol" +ncolor="-h string:bgcolor:#343d46 -h string:fgcolor:#c0c5ce -h string:frcolor:#c0c5ce" + +case $1 in + i) pamixer $srce -i ${step} + notify_vol ;; + d) pamixer $srce -d ${step} + notify_vol ;; + m) pamixer $srce -t + notify_mute ;; + *) print_error ;; +esac + diff --git a/modules/home/hyprland/conf/hypr/theme.conf b/modules/home/hyprland/conf/hypr/theme.conf new file mode 100644 index 0000000..be94373 --- /dev/null +++ b/modules/home/hyprland/conf/hypr/theme.conf @@ -0,0 +1,44 @@ +exec = hyprctl setcursor Bibata-Modern-Ice 20 +exec = gsettings set org.gnome.desktop.interface cursor-theme 'Bibata-Modern-Ice' +exec = gsettings set org.gnome.desktop.interface cursor-size 20 + +exec = kvantummanager --set Catppuccin-Latte +exec = gsettings set org.gnome.desktop.interface icon-theme 'Tela-circle-grey' +exec = gsettings set org.gnome.desktop.interface gtk-theme 'Catppuccin-Latte' +exec = gsettings set org.gnome.desktop.interface color-scheme 'prefer-light' + +exec = gsettings set org.gnome.desktop.interface font-name 'Cantarell 10' +exec = gsettings set org.gnome.desktop.interface document-font-name 'Cantarell 10' +exec = gsettings set org.gnome.desktop.interface monospace-font-name 'CaskaydiaCove Nerd Font Mono 9' +exec = gsettings set org.gnome.desktop.interface font-antialiasing 'rgba' +exec = gsettings set org.gnome.desktop.interface font-hinting 'full' + +env = XCURSOR_THEME,Bibata-Modern-Ice +env = XCURSOR_SIZE,20 + +general { + gaps_in = 3 + gaps_out = 8 + border_size = 2 + col.active_border = rgba(dc8a78ff) rgba(8839efff) 45deg + col.inactive_border = rgba(7287fdcc) rgba(179299cc) 45deg + layout = dwindle + resize_on_border = true +} + +decoration { + rounding = 10 + multisample_edges = true + drop_shadow = false + + blur { + enabled = yes + size = 6 + passes = 3 + new_optimizations = on + ignore_opacity = on + xray = false + } +} + +blurls = waybar diff --git a/modules/home/hyprland/conf/hypr/userprefs.conf b/modules/home/hyprland/conf/hypr/userprefs.conf new file mode 100644 index 0000000..37e7de9 --- /dev/null +++ b/modules/home/hyprland/conf/hypr/userprefs.conf @@ -0,0 +1,19 @@ + +# █▀▀ █▄░█ █░█ +# ██▄ █░▀█ ▀▄▀ + +# Some default env vars. + +#env = MANGOHUD,1 +#env = MANGOHUD_DLSYM,1 + + +# █▀▄▀█ █ █▀ █▀▀ +# █░▀░█ █ ▄█ █▄▄ + +# See https://wiki.hyprland.org/Configuring/Variables/ for more + +misc { + vrr = 0 +} + diff --git a/modules/home/hyprland/conf/hypr/windowrules.conf b/modules/home/hyprland/conf/hypr/windowrules.conf new file mode 100644 index 0000000..91ad92f --- /dev/null +++ b/modules/home/hyprland/conf/hypr/windowrules.conf @@ -0,0 +1,53 @@ + +# █░█░█ █ █▄░█ █▀▄ █▀█ █░█░█   █▀█ █░█ █░░ █▀▀ █▀ +# ▀▄▀▄▀ █ █░▀█ █▄▀ █▄█ ▀▄▀▄▀   █▀▄ █▄█ █▄▄ ██▄ ▄█ + + +# Example windowrule v1 +# windowrule = float, ^(kitty)$ +# Example windowrule v2 +# windowrulev2 = float,class:^(kitty)$,title:^(kitty)$ +# See https://wiki.hyprland.org/Configuring/Window-Rules/ for more + + +windowrulev2 = opacity 0.90 0.90,class:^(firefox)$ +windowrulev2 = opacity 0.80 0.80,class:^(Steam)$ +windowrulev2 = opacity 0.80 0.80,class:^(steam)$ +windowrulev2 = opacity 0.80 0.80,class:^(steamwebhelper)$ +windowrulev2 = opacity 0.80 0.80,class:^(Spotify)$ +windowrulev2 = opacity 0.80 0.80,class:^(Code)$ +windowrulev2 = opacity 0.80 0.80,class:^(code-url-handler)$ +windowrulev2 = opacity 0.80 0.80,class:^(kitty)$ +windowrulev2 = opacity 0.80 0.80,class:^(org.kde.dolphin)$ +windowrulev2 = opacity 0.80 0.80,class:^(org.kde.ark)$ +windowrulev2 = opacity 0.80 0.80,class:^(nwg-look)$ +windowrulev2 = opacity 0.80 0.80,class:^(qt5ct)$ + +windowrulev2 = opacity 0.90 0.90,class:^(com.github.rafostar.Clapper)$ #Clapper-Gtk +windowrulev2 = opacity 0.80 0.80,class:^(com.github.tchx84.Flatseal)$ #Flatseal-Gtk +windowrulev2 = opacity 0.80 0.80,class:^(hu.kramo.Cartridges)$ #Cartridges-Gtk +windowrulev2 = opacity 0.80 0.80,class:^(com.obsproject.Studio)$ #Obs-Qt +windowrulev2 = opacity 0.80 0.80,class:^(gnome-boxes)$ #Boxes-Gtk +windowrulev2 = opacity 0.80 0.80,class:^(discord)$ #Discord-Electron +windowrulev2 = opacity 0.80 0.80,class:^(WebCord)$ #WebCord-Electron +windowrulev2 = opacity 0.80 0.80,class:^(app.drey.Warp)$ #Warp-Gtk +windowrulev2 = opacity 0.80 0.80,class:^(net.davidotek.pupgui2)$ #ProtonUp-Qt +windowrulev2 = opacity 0.80 0.80,class:^(yad)$ #Protontricks-Gtk + +windowrulev2 = opacity 0.80 0.70,class:^(pavucontrol)$ +windowrulev2 = opacity 0.80 0.70,class:^(blueman-manager)$ +windowrulev2 = opacity 0.80 0.70,class:^(nm-applet)$ +windowrulev2 = opacity 0.80 0.70,class:^(nm-connection-editor)$ +windowrulev2 = opacity 0.80 0.70,class:^(org.kde.polkit-kde-authentication-agent-1)$ + +windowrulev2 = float,class:^(org.kde.ark)$ +windowrulev2 = float,class:^(com.github.rafostar.Clapper)$ #Clapper-Gtk +windowrulev2 = float,class:^(app.drey.Warp)$ #Warp-Gtk +windowrulev2 = float,class:^(net.davidotek.pupgui2)$ #ProtonUp-Qt +windowrulev2 = float,class:^(yad)$ #Protontricks-Gtk +windowrulev2 = float,class:^(pavucontrol)$ +windowrulev2 = float,class:^(blueman-manager)$ +windowrulev2 = float,class:^(nm-applet)$ +windowrulev2 = float,class:^(nm-connection-editor)$ +windowrulev2 = float,class:^(org.kde.polkit-kde-authentication-agent-1)$ + diff --git a/modules/home/hyprland/conf/kitty/kitty.conf b/modules/home/hyprland/conf/kitty/kitty.conf new file mode 100644 index 0000000..3ebaa2d --- /dev/null +++ b/modules/home/hyprland/conf/kitty/kitty.conf @@ -0,0 +1,80 @@ +# vim:ft=kitty + +## name: Catppuccin Latte 🐑 +## author: Pocco81 (https://github.com/Pocco81) +## license: MIT +## upstream: https://github.com/catppuccin/kitty/blob/main/latte.conf +## blurb: Soothing pastel theme for the high-spirited! + + + +# The basic colors +foreground #4C4F69 +background #EFF1F5 +selection_foreground #EFF1F5 +selection_background #DC8A78 + +# Cursor colors +cursor #DC8A78 +cursor_text_color #EFF1F5 + +# URL underline color when hovering with mouse +url_color #7287FD + +# Kitty window border colors +active_border_color #8839EF +inactive_border_color #7C7F93 +bell_border_color #E64553 + +# OS Window titlebar colors +wayland_titlebar_color system +macos_titlebar_color system + +# Tab bar colors +active_tab_foreground #EFF1F5 +active_tab_background #8839EF +inactive_tab_foreground #4C4F69 +inactive_tab_background #9CA0B0 +tab_bar_background #BCC0CC + +# Colors for marks (marked text in the terminal) +mark1_foreground #EFF1F5 +mark1_background #1E66F5 +mark2_foreground #EFF1F5 +mark2_background #8839EF +mark3_foreground #EFF1F5 +mark3_background #209FB5 + +# The 16 terminal colors + +# black +color0 #4C4F69 +color8 #6C6F85 + +# red +color1 #D20F39 +color9 #D20F39 + +# green +color2 #40A02B +color10 #40A02B + +# yellow +color3 #DF8E1D +color11 #DF8E1D + +# blue +color4 #1E66F5 +color12 #1E66F5 + +# magenta +color5 #EA76CB +color13 #EA76CB + +# cyan +color6 #179299 +color14 #179299 + +# white +color7 #ACB0BE +color15 #ACB0BE diff --git a/modules/home/hyprland/conf/rofi/config.rasi b/modules/home/hyprland/conf/rofi/config.rasi new file mode 100644 index 0000000..7144378 --- /dev/null +++ b/modules/home/hyprland/conf/rofi/config.rasi @@ -0,0 +1,125 @@ +/* MACOS SPOTLIGHT LIKE THEME FOR ROFI */ + +/* 基本配置项 */ +configuration { + show-icons: true; + icon-theme: "Papirus"; + drun-display-format: "{icon} {name}"; + display-drun: ""; +} + +/* 全局变量和样式设置 */ +* { + font: "Montserrat 12"; + + bg0: #ffffff; + bg1: #e0e0e0; + bg2: #0860f2e6; + bg3: rgba(0, 0, 0, 0.015); + + fg0: #242424; + fg1: #ffffff; + fg2: #24242480; + + background-color: @bg0; + text-color: @fg0; + + margin: 0; + padding: 0; + spacing: 0; +} + +/* 主窗口样式 */ +window { + background-color: @bg0; + location: center; + width: 640; + border-radius: 8; + border: 1px; + border-color: @bg1; +} + +/* 搜索输入栏样式 */ +inputbar { + font: "Montserrat 20"; + padding: 12px 12px 12px 12px; + spacing: 12px; + children: [ icon-search, entry]; +} + +/* 搜索图标样式 */ +icon-search { + expand: false; + filename: "search"; + size: 28px; +} + +/* 元素垂直对齐设置 */ +icon-search, +element-icon, +element-text { + vertical-align: 0.5; +} + +/* 搜索输入框样式 */ +entry { + font: inherit; + vertical-align: 0.5; + text-align: center; + padding: 5px; + spacing: 10px; + placeholder: "Search"; + placeholder-color: @fg2; +} + +/* 消息区域样式 */ +message { + border: 2px 0 0; + border-color: @bg1; + background-color: @bg1; +} + +/* 文本框样式 */ +textbox { + padding: 8px 24px; +} + +/* 列表视图样式 */ +listview { + lines: 10; + columns: 1; + fixed-height: false; + border: 1px 0 0; + border-color: @bg1; +} + +/* 列表项基本样式 */ +element { + padding: 8px 16px; + spacing: 16px; + border: 0; + border-radius: 4; + background-color: transparent; + children: [ element-icon, element-text]; +} + + +element normal.normal { + background-color: @bg3; +} + +element alternate.normal { + background-color: @bg3; +} + +/* 选中状态的列表项样式 */ +element selected.active, +element selected.normal { + text-color: @fg1; + background-color: @bg2; +} + +/* 列表项图标样式 */ +element-icon { + size: 1.5em; +} diff --git a/modules/home/hyprland/conf/waybar/config.jsonc b/modules/home/hyprland/conf/waybar/config.jsonc new file mode 100644 index 0000000..92625a5 --- /dev/null +++ b/modules/home/hyprland/conf/waybar/config.jsonc @@ -0,0 +1,244 @@ +// --// waybar config generated by wbarconfgen.sh //-- // + +{ + // sourced from header module // + + "layer": "top", + "position": "top", + "mod": "dock", + "height": 31, + "exclusive": true, + "passthrough": false, + "gtk-layer-shell": true, + + // positions generated based on config.ctl // + + "modules-left": [ + "custom/padd", + "custom/l_end", + "custom/power", + "custom/cliphist", + "custom/wbar", + "custom/mode", + "custom/r_end", + "custom/l_end", + "wlr/taskbar", + "custom/r_end", + "custom/l_end", + "wlr/workspaces", + "hyprland/window", + "custom/r_end", + "custom/padd" + ], + "modules-center": [ + "custom/padd", + "custom/l_end", + "clock", + "custom/r_end", + "custom/padd" + ], + "modules-right": [ + "custom/padd", + "custom/l_end", + "tray", + "custom/r_end", + "custom/l_end", + "cpu", + "memory", + "custom/r_end", + "custom/l_end", + "network", + "bluetooth", + "pulseaudio", + "pulseaudio#microphone", + "custom/r_end", + "custom/padd" + ], + + // sourced from modules based on config.ctl // + + "custom/power": { + "format": "{}", + "exec": "echo ; echo  logout", + "on-click": "~/.config/hypr/scripts/logoutlaunch.sh 2", + "interval": 86400, // once every day + "tooltip": true + }, + + "custom/cliphist": { + "format": "{}", + "exec": "echo ; echo 󰅇 clipboard history", + "on-click": "sleep 0.1 && ~/.config/hypr/scripts/cliphist.sh c 1", + //"on-click-right": "sleep 0.1 && ~/.config/hypr/scripts/cliphist.sh d", + "on-click-middle": "sleep 0.1 && ~/.config/hypr/scripts/cliphist.sh w 1", + "interval": 86400, // once every day + "tooltip": true + }, + + "custom/mode": { + "format": "{}", + "exec": "echo ; echo 󰟡 switch mode", + "on-click": "~/.config/hypr/scripts/themeswitch.sh -n", + "on-click-right": "~/.config/hypr/scripts/themeswitch.sh -p", + "on-click-middle": "sleep 0.1 && ~/.config/hypr/scripts/themeselect.sh", + "interval": 86400, // once every day + "tooltip": true + }, + + + "wlr/taskbar": { + "format": "{icon}", + "icon-size": 18, + "icon-theme": "papirus-icon-theme", + "spacing": 0, + "tooltip-format": "{title}", + "on-click": "activate", + "on-click-middle": "close", + "ignore-list": ["Alacritty"], + "app_ids-mapping": { + "firefoxdeveloperedition": "firefox-developer-edition" + } + }, + + "wlr/workspaces": { + "disable-scroll": true, + "all-outputs": true, + "on-click": "activate", + "persistent_workspaces": { + "1": [], + "2": [], + "3": [], + "4": [], + "5": [], + "6": [], + "7": [], + "8": [], + "9": [], + "10": [] + } + }, + + "clock": { + "format": "{:%Y/%m/%d %H:%M}", + "format-alt": "{:%I:%M%p 周%u}", + "tooltip-format": "{calendar}", + "locale": "zh_CN.UTF-8" + }, + + "tray": { + "icon-size": 18, + "spacing": 5 + }, + + "cpu": { + "interval": 10, + "format": "󰍛 {usage}%", + "format-alt": "{icon0}{icon1}{icon2}{icon3}", + "format-icons": ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"] + }, + + "memory": { + "interval": 30, + "format": "󰾆 {percentage}%", + "format-alt": "󰾅 {used}GB", + "max-length": 10, + "tooltip": true, + "tooltip-format": " {used:0.1f}GB/{total:0.1f}GB" + }, + + "network": { + // "interface": "wlp2*", // (Optional) To force the use of this interface + "format-wifi": "󰤨 {essid}", + "format-ethernet": "󱘖 Wired", + "tooltip-format": "󱘖 {ipaddr}  {bandwidthUpBytes}  {bandwidthDownBytes}", + "format-linked": "󱘖 {ifname} (No IP)", + "format-disconnected": " Disconnected", + "format-alt": "󰤨 {signalStrength}%", + "interval": 5 + }, + + "bluetooth": { + "format": "", + "format-disabled": "", // an empty format will hide the module + "format-connected": " {num_connections}", + "tooltip-format": " {device_alias}", + "tooltip-format-connected": "{device_enumerate}", + "tooltip-format-enumerate-connected": " {device_alias}" + }, + + "pulseaudio": { + "format": "{icon} {volume}", + "format-muted": "婢", + "on-click": "pavucontrol -t 3", + "on-click-middle": "~/.config/hypr/scripts/volumecontrol.sh -o m", + "on-scroll-up": "~/.config/hypr/scripts/volumecontrol.sh -o i", + "on-scroll-down": "~/.config/hypr/scripts/volumecontrol.sh -o d", + "tooltip-format": "{icon} {desc} // {volume}%", + "scroll-step": 5, + "format-icons": { + "headphone": "", + "hands-free": "", + "headset": "", + "phone": "", + "portable": "", + "car": "", + "default": ["", "", ""] + } + }, + + "pulseaudio#microphone": { + "format": "{format_source}", + "format-source": "", + "format-source-muted": "", + "on-click": "pavucontrol -t 4", + "on-click-middle": "~/.config/hypr/scripts/volumecontrol.sh -i m", + "on-scroll-up": "~/.config/hypr/scripts/volumecontrol.sh -i i", + "on-scroll-down": "~/.config/hypr/scripts/volumecontrol.sh -i d", + "tooltip-format": "{format_source} {source_desc} // {source_volume}%", + "scroll-step": 5 + }, + + // modules for padding // + + "custom/l_end": { + "format": " ", + "interval": "once", + "tooltip": false + }, + + "custom/r_end": { + "format": " ", + "interval": "once", + "tooltip": false + }, + + "custom/sl_end": { + "format": " ", + "interval": "once", + "tooltip": false + }, + + "custom/sr_end": { + "format": " ", + "interval": "once", + "tooltip": false + }, + + "custom/rl_end": { + "format": " ", + "interval": "once", + "tooltip": false + }, + + "custom/rr_end": { + "format": " ", + "interval": "once", + "tooltip": false + }, + + "custom/padd": { + "format": " ", + "interval": "once", + "tooltip": false + } +} diff --git a/modules/home/hyprland/conf/waybar/style.css b/modules/home/hyprland/conf/waybar/style.css new file mode 100644 index 0000000..4392c3c --- /dev/null +++ b/modules/home/hyprland/conf/waybar/style.css @@ -0,0 +1,174 @@ +@define-color bar-bg rgba(0, 0, 0, 0); +@define-color main-color #cdd6f4; +@define-color main-bg #11111b; +@define-color tool-bg #1e1e2e; +@define-color tool-color #cdd6f4; +@define-color tool-border #11111b; +@define-color wb-color #cdd6f4; +@define-color wb-act-bg #a6adc8; +@define-color wb-act-color #313244; +@define-color wb-hvr-bg #f5c2e7; +@define-color wb-hvr-color #313244; + +* { + border: none; + border-radius: 0px; + font-family: "JetBrainsMono Nerd Font"; + font-weight: bold; + font-size: 11px; + min-height: 10px; +} + +window#waybar { + background: @bar-bg; +} + +tooltip { + background: @tool-bg; + color: @tool-color; + border-radius: 21px; + border-width: 1px; + border-style: solid; + border-color: @tool-border; +} + +#workspaces button { + box-shadow: none; + text-shadow: none; + padding: 0px; + border-radius: 9px; + margin-top: 3px; + margin-bottom: 3px; + padding-left: 3px; + padding-right: 3px; + color: @wb-color; + animation: gradient_f 20s ease-in infinite; + transition: all 0.5s cubic-bezier(.55,-0.68,.48,1.682); +} + +#workspaces button.active { + background: @wb-act-bg; + color: @wb-act-color; + margin-left: 3px; + padding-left: 12px; + padding-right: 12px; + margin-right: 3px; + animation: gradient_f 20s ease-in infinite; + transition: all 0.3s cubic-bezier(.55,-0.68,.48,1.682); +} + +#workspaces button:hover { + background: @wb-hvr-bg; + color: @wb-hvr-color; + padding-left: 3px; + padding-right: 3px; + animation: gradient_f 20s ease-in infinite; + transition: all 0.3s cubic-bezier(.55,-0.68,.48,1.682); +} + +#taskbar button { + box-shadow: none; + text-shadow: none; + padding: 0px; + border-radius: 9px; + margin-top: 3px; + margin-bottom: 3px; + padding-left: 3px; + padding-right: 3px; + color: @wb-color; + animation: gradient_f 20s ease-in infinite; + transition: all 0.5s cubic-bezier(.55,-0.68,.48,1.682); +} + +#taskbar button.active { + background: @wb-act-bg; + color: @wb-act-color; + margin-left: 3px; + padding-left: 12px; + padding-right: 12px; + margin-right: 3px; + animation: gradient_f 20s ease-in infinite; + transition: all 0.3s cubic-bezier(.55,-0.68,.48,1.682); +} + +#taskbar button:hover { + background: @wb-hvr-bg; + color: @wb-hvr-color; + padding-left: 3px; + padding-right: 3px; + animation: gradient_f 20s ease-in infinite; + transition: all 0.3s cubic-bezier(.55,-0.68,.48,1.682); +} + +#cpu, +#memory, +#battery, +#clock, +#workspaces, +#window, +#taskbar, +#network, +#bluetooth, +#pulseaudio, +#mpris, +#custom-updates, +#custom-wallchange, +#custom-mode, +#custom-cliphist, +#custom-power, +#custom-wbar, +#custom-l_end, +#custom-r_end, +#custom-sl_end, +#custom-sr_end, +#custom-rl_end, +#custom-rr_end, +#tray { + color: @main-color; + background: @main-bg; + opacity: 1; + margin: 4px 0px 4px 0px; + padding-left: 4px; + padding-right: 4px; +} + +#workspaces, +#taskbar { + padding: 0px; +} + +#custom-r_end { + border-radius: 0px 21px 21px 0px; + margin-right: 9px; + padding-right: 3px; +} + +#custom-l_end { + border-radius: 21px 0px 0px 21px; + margin-left: 9px; + padding-left: 3px; +} + +#custom-sr_end { + border-radius: 0px; + margin-right: 9px; + padding-right: 3px; +} + +#custom-sl_end { + border-radius: 0px; + margin-left: 9px; + padding-left: 3px; +} + +#custom-rr_end { + border-radius: 0px 7px 7px 0px; + margin-right: 9px; + padding-right: 3px; +} + +#custom-rl_end { + border-radius: 7px 0px 0px 7px; + margin-left: 9px; + padding-left: 3px; +} diff --git a/modules/home/hyprland/conf/wlogout/icons/hibernate_dark.png b/modules/home/hyprland/conf/wlogout/icons/hibernate_dark.png new file mode 100644 index 0000000..6f98a08 Binary files /dev/null and b/modules/home/hyprland/conf/wlogout/icons/hibernate_dark.png differ diff --git a/modules/home/hyprland/conf/wlogout/icons/hibernate_light.png b/modules/home/hyprland/conf/wlogout/icons/hibernate_light.png new file mode 100644 index 0000000..cea1ebc Binary files /dev/null and b/modules/home/hyprland/conf/wlogout/icons/hibernate_light.png differ diff --git a/modules/home/hyprland/conf/wlogout/icons/lock_dark.png b/modules/home/hyprland/conf/wlogout/icons/lock_dark.png new file mode 100644 index 0000000..b4c8c52 Binary files /dev/null and b/modules/home/hyprland/conf/wlogout/icons/lock_dark.png differ diff --git a/modules/home/hyprland/conf/wlogout/icons/lock_light.png b/modules/home/hyprland/conf/wlogout/icons/lock_light.png new file mode 100644 index 0000000..2925c26 Binary files /dev/null and b/modules/home/hyprland/conf/wlogout/icons/lock_light.png differ diff --git a/modules/home/hyprland/conf/wlogout/icons/logout_dark.png b/modules/home/hyprland/conf/wlogout/icons/logout_dark.png new file mode 100644 index 0000000..b918ce7 Binary files /dev/null and b/modules/home/hyprland/conf/wlogout/icons/logout_dark.png differ diff --git a/modules/home/hyprland/conf/wlogout/icons/logout_light.png b/modules/home/hyprland/conf/wlogout/icons/logout_light.png new file mode 100644 index 0000000..33ecdc1 Binary files /dev/null and b/modules/home/hyprland/conf/wlogout/icons/logout_light.png differ diff --git a/modules/home/hyprland/conf/wlogout/icons/reboot_dark.png b/modules/home/hyprland/conf/wlogout/icons/reboot_dark.png new file mode 100644 index 0000000..0bbf256 Binary files /dev/null and b/modules/home/hyprland/conf/wlogout/icons/reboot_dark.png differ diff --git a/modules/home/hyprland/conf/wlogout/icons/reboot_light.png b/modules/home/hyprland/conf/wlogout/icons/reboot_light.png new file mode 100644 index 0000000..e4a6987 Binary files /dev/null and b/modules/home/hyprland/conf/wlogout/icons/reboot_light.png differ diff --git a/modules/home/hyprland/conf/wlogout/icons/shutdown_dark.png b/modules/home/hyprland/conf/wlogout/icons/shutdown_dark.png new file mode 100644 index 0000000..e57ea3a Binary files /dev/null and b/modules/home/hyprland/conf/wlogout/icons/shutdown_dark.png differ diff --git a/modules/home/hyprland/conf/wlogout/icons/shutdown_light.png b/modules/home/hyprland/conf/wlogout/icons/shutdown_light.png new file mode 100644 index 0000000..a8892ae Binary files /dev/null and b/modules/home/hyprland/conf/wlogout/icons/shutdown_light.png differ diff --git a/modules/home/hyprland/conf/wlogout/icons/suspend_dark.png b/modules/home/hyprland/conf/wlogout/icons/suspend_dark.png new file mode 100644 index 0000000..e307b6e Binary files /dev/null and b/modules/home/hyprland/conf/wlogout/icons/suspend_dark.png differ diff --git a/modules/home/hyprland/conf/wlogout/icons/suspend_light.png b/modules/home/hyprland/conf/wlogout/icons/suspend_light.png new file mode 100644 index 0000000..ee09b8c Binary files /dev/null and b/modules/home/hyprland/conf/wlogout/icons/suspend_light.png differ diff --git a/modules/home/hyprland/conf/wlogout/layout_1 b/modules/home/hyprland/conf/wlogout/layout_1 new file mode 100644 index 0000000..c6e3d7d --- /dev/null +++ b/modules/home/hyprland/conf/wlogout/layout_1 @@ -0,0 +1,41 @@ +{ + "label" : "lock", + "action" : "swaylock", + "text" : "Lock", + "keybind" : "l" +} + +{ + "label" : "logout", + "action" : "hyprctl dispatch exit 0", + "text" : "Logout", + "keybind" : "e" +} + +{ + "label" : "suspend", + "action" : "systemctl suspend", + "text" : "Suspend", + "keybind" : "u" +} + +{ + "label" : "shutdown", + "action" : "systemctl poweroff", + "text" : "Shutdown", + "keybind" : "s" +} + +{ + "label" : "hibernate", + "action" : "systemctl hibernate", + "text" : "Hibernate", + "keybind" : "h" +} + +{ + "label" : "reboot", + "action" : "systemctl reboot", + "text" : "Reboot", + "keybind" : "r" +} diff --git a/modules/home/hyprland/conf/wlogout/layout_2 b/modules/home/hyprland/conf/wlogout/layout_2 new file mode 100644 index 0000000..9876330 --- /dev/null +++ b/modules/home/hyprland/conf/wlogout/layout_2 @@ -0,0 +1,27 @@ +{ + "label" : "lock", + "action" : "swaylock", + "text" : "Lock", + "keybind" : "l" +} + +{ + "label" : "logout", + "action" : "hyprctl dispatch exit 0", + "text" : "Logout", + "keybind" : "e" +} + +{ + "label" : "shutdown", + "action" : "systemctl poweroff", + "text" : "Shutdown", + "keybind" : "s" +} + +{ + "label" : "reboot", + "action" : "systemctl reboot", + "text" : "Reboot", + "keybind" : "r" +} diff --git a/modules/home/hyprland/conf/wlogout/style_1.css b/modules/home/hyprland/conf/wlogout/style_1.css new file mode 100644 index 0000000..6a35ae9 --- /dev/null +++ b/modules/home/hyprland/conf/wlogout/style_1.css @@ -0,0 +1,104 @@ +* { + background-image: none; + font-size: ${fntSize}px; +} + +@import "${wbarTheme}"; + +window { + background-color: ${WindBg}; +} + +button { + color: ${BtnCol}; + background-color: @main-${BtnBkg}; + outline-style: none; + border: none; + border-width: 0px; + background-repeat: no-repeat; + background-position: center; + background-size: 20%; + border-radius: 0px; + box-shadow: none; + text-shadow: none; + animation: gradient_f 20s ease-in infinite; +} + +button:focus { + background-color: @wb-act-bg; + background-size: 30%; +} + +button:hover { + background-color: @wb-hvr-bg; + background-size: 40%; + border-radius: ${active_rad}px; + animation: gradient_f 20s ease-in infinite; + transition: all 0.3s cubic-bezier(.55,0.0,.28,1.682); +} + +button:hover#lock { + border-radius: ${active_rad}px; + margin : ${hvr}px 0px ${hvr}px ${mgn}px; +} + +button:hover#logout { + border-radius: ${active_rad}px; + margin : ${hvr}px 0px ${hvr}px 0px; +} + +button:hover#suspend { + border-radius: ${active_rad}px; + margin : ${hvr}px 0px ${hvr}px 0px; +} + +button:hover#shutdown { + border-radius: ${active_rad}px; + margin : ${hvr}px 0px ${hvr}px 0px; +} + +button:hover#hibernate { + border-radius: ${active_rad}px; + margin : ${hvr}px 0px ${hvr}px 0px; +} + +button:hover#reboot { + border-radius: ${active_rad}px; + margin : ${hvr}px ${mgn}px ${hvr}px 0px; +} + +#lock { + background-image: image(url("$HOME/.config/wlogout/icons/lock_${csMode}.png"), url("/usr/share/wlogout/icons/lock.png"), url("/usr/local/share/wlogout/icons/lock.png")); + border-radius: ${button_rad}px 0px 0px ${button_rad}px; + margin : ${mgn}px 0px ${mgn}px ${mgn}px; +} + +#logout { + background-image: image(url("$HOME/.config/wlogout/icons/logout_${csMode}.png"), url("/usr/share/wlogout/icons/logout.png"), url("/usr/local/share/wlogout/icons/logout.png")); + border-radius: 0px 0px 0px 0px; + margin : ${mgn}px 0px ${mgn}px 0px; +} + +#suspend { + background-image: image(url("$HOME/.config/wlogout/icons/suspend_${csMode}.png"), url("/usr/share/wlogout/icons/suspend.png"), url("/usr/local/share/wlogout/icons/suspend.png")); + border-radius: 0px 0px 0px 0px; + margin : ${mgn}px 0px ${mgn}px 0px; +} + +#shutdown { + background-image: image(url("$HOME/.config/wlogout/icons/shutdown_${csMode}.png"), url("/usr/share/wlogout/icons/shutdown.png"), url("/usr/local/share/wlogout/icons/shutdown.png")); + border-radius: 0px 0px 0px 0px; + margin : ${mgn}px 0px ${mgn}px 0px; +} + +#hibernate { + background-image: image(url("$HOME/.config/wlogout/icons/hibernate_${csMode}.png"), url("/usr/share/wlogout/icons/hibernate.png"), url("/usr/local/share/wlogout/icons/hibernate.png")); + border-radius: 0px 0px 0px 0px; + margin : ${mgn}px 0px ${mgn}px 0px; +} + +#reboot { + background-image: image(url("$HOME/.config/wlogout/icons/reboot_${csMode}.png"), url("/usr/share/wlogout/icons/reboot.png"), url("/usr/local/share/wlogout/icons/reboot.png")); + border-radius: 0px ${button_rad}px ${button_rad}px 0px; + margin : ${mgn}px ${mgn}px ${mgn}px 0px; +} diff --git a/modules/home/hyprland/conf/wlogout/style_2.css b/modules/home/hyprland/conf/wlogout/style_2.css new file mode 100644 index 0000000..5e371d7 --- /dev/null +++ b/modules/home/hyprland/conf/wlogout/style_2.css @@ -0,0 +1,82 @@ +* { + background-image: none; + font-size: ${fntSize}px; +} + +@import "${wbarTheme}"; + +window { + background-color: ${WindBg}; +} + +button { + color: ${BtnCol}; + background-color: @main-${BtnBkg}; + outline-style: none; + border: none; + border-width: 0px; + background-repeat: no-repeat; + background-position: center; + background-size: 10%; + border-radius: 0px; + box-shadow: none; + text-shadow: none; + animation: gradient_f 20s ease-in infinite; +} + +button:focus { + background-color: @wb-act-bg; + background-size: 20%; +} + +button:hover { + background-color: @wb-hvr-bg; + background-size: 25%; + border-radius: ${active_rad}px; + animation: gradient_f 20s ease-in infinite; + transition: all 0.3s cubic-bezier(.55,0.0,.28,1.682); +} + +button:hover#lock { + border-radius: ${active_rad}px ${active_rad}px 0px ${active_rad}px; + margin : ${hvr}px 0px 0px ${hvr2}px; +} + +button:hover#logout { + border-radius: ${active_rad}px 0px ${active_rad}px ${active_rad}px; + margin : 0px 0px ${hvr}px ${hvr2}px; +} + +button:hover#shutdown { + border-radius: ${active_rad}px ${active_rad}px ${active_rad}px 0px; + margin : ${hvr}px ${hvr2}px 0px 0px; +} + +button:hover#reboot { + border-radius: 0px ${active_rad}px ${active_rad}px ${active_rad}px; + margin : 0px ${hvr2}px ${hvr}px 0px; +} + +#lock { + background-image: image(url("$HOME/.config/wlogout/icons/lock_${csMode}.png"), url("/usr/share/wlogout/icons/lock.png"), url("/usr/local/share/wlogout/icons/lock.png")); + border-radius: ${button_rad}px 0px 0px 0px; + margin : ${mgn}px 0px 0px ${mgn2}px; +} + +#logout { + background-image: image(url("$HOME/.config/wlogout/icons/logout_${csMode}.png"), url("/usr/share/wlogout/icons/logout.png"), url("/usr/local/share/wlogout/icons/logout.png")); + border-radius: 0px 0px 0px ${button_rad}px; + margin : 0px 0px ${mgn}px ${mgn2}px; +} + +#shutdown { + background-image: image(url("$HOME/.config/wlogout/icons/shutdown_${csMode}.png"), url("/usr/share/wlogout/icons/shutdown.png"), url("/usr/local/share/wlogout/icons/shutdown.png")); + border-radius: 0px ${button_rad}px 0px 0px; + margin : ${mgn}px ${mgn2}px 0px 0px; +} + +#reboot { + background-image: image(url("$HOME/.config/wlogout/icons/reboot_${csMode}.png"), url("/usr/share/wlogout/icons/reboot.png"), url("/usr/local/share/wlogout/icons/reboot.png")); + border-radius: 0px 0px ${button_rad}px 0px; + margin : 0px ${mgn2}px ${mgn}px 0px; +} diff --git a/modules/home/hyprland/default.nix b/modules/home/hyprland/default.nix new file mode 100644 index 0000000..b382563 --- /dev/null +++ b/modules/home/hyprland/default.nix @@ -0,0 +1,73 @@ +{ config, lib, pkgs, hyprland, ... }: + +{ + imports = [ + hyprland.homeManagerModules.default + ./env.nix + ]; + + home.packages = with pkgs; [ + waybar # the status bar + # hyprpaper # wallpaper + swww # wallpaper + dunst # notify + rofi # app launcher + kitty + envsubst + killall + pavucontrol + wlogout + ]; + + + programs = { + bash = { + initExtra = '' + if [ -z $DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then + exec Hyprland + fi + ''; + }; + + swaylock.enable = true; + }; + + wayland.windowManager.hyprland = { + enable = true; + systemdIntegration = true; + enableNvidiaPatches = true; + # extraConfig = builtins.readFile ./conf/hyprland.conf; + }; + + # hyprland configs, based on https://github.com/notwidow/hyprland + home.file.".config/hypr" = { + source = ./conf/hypr; + # copy the scripts directory recursively + recursive = true; + }; + + home.file.".config/rofi" = { + source = ./conf/rofi; + recursive = true; + }; + + home.file.".config/kitty" = { + source = ./conf/kitty; + recursive = true; + }; + + home.file.".config/swww" = { + source = ./conf/swww; + recursive = true; + }; + + home.file.".config/waybar" = { + source = ./conf/waybar; + recursive = true; + }; + + home.file.".config/wlogout" = { + source = ./conf/wlogout; + recursive = true; + }; +} diff --git a/modules/home/hyprland/env.nix b/modules/home/hyprland/env.nix new file mode 100644 index 0000000..95f4765 --- /dev/null +++ b/modules/home/hyprland/env.nix @@ -0,0 +1,44 @@ +{ ... }: + +{ + home = { + sessionVariables = { + EDITOR = "vim"; + BROWSER = "microsoft-edge"; + TERMINAL = "kitty"; + QT_QPA_PLATFORMTHEME = "gtk3"; + QT_SCALE_FACTOR = "1"; + MOZ_ENABLE_WAYLAND = "1"; + # NIXOS_OZONE_WL = "1"; # for any ozone-based browser & electron apps to run on wayland + + + _JAVA_AWT_WM_NONREPARENTING = "1"; + SDL_VIDEODRIVER = "wayland"; + QT_QPA_PLATFORM = "wayland"; + QT_WAYLAND_DISABLE_WINDOWDECORATION = "1"; + QT_AUTO_SCREEN_SCALE_FACTOR = "1"; + + # for hyprland with nvidia gpu, ref https://wiki.hyprland.org/Nvidia/ + # 启用注释部分会导致NVIDIA下无法启动hyprland + # WLR_DRM_DEVICES = "/dev/dri/card1:/dev/dri/card0"; + # WLR_EGL_NO_MODIFIRES = "1"; + WLR_NO_HARDWARE_CURSORS = "1"; # if no cursor,uncomment this line + WLR_RENDERER_ALLOW_SOFTWARE = "1"; + # WLR_RENDERER = "vulkan"; + # GBM_BACKEND = "nvidia-drm"; + CLUTTER_BACKEND = "wayland"; + # LIBVA_DRIVER_NAME = "nvidia"; + # __GLX_VENDOR_LIBRARY_NAME = "nvidia"; + # __NV_PRIME_RENDER_OFFLOAD = "1"; + + XDG_CURRENT_DESKTOP = "Hyprland"; + XDG_SESSION_DESKTOP = "Hyprland"; + XDG_SESSION_TYPE = "wayland"; + XDG_BIN_HOME = "\${HOME}/.local/bin"; + }; + sessionPath = [ + "$HOME/.npm-global/bin" + "$HOME/.local/bin" + ]; + }; +} diff --git a/modules/home/theme.nix b/modules/home/theme.nix new file mode 100644 index 0000000..75fcbd3 --- /dev/null +++ b/modules/home/theme.nix @@ -0,0 +1,47 @@ +{ pkgs, ... }: + +{ + imports = [ + ]; + + home = { + pointerCursor = { + package = pkgs.capitaine-cursors; + name = "capitaine-cursors"; + size = 16; + gtk.enable = true; + x11.enable = true; + x11.defaultCursor = "capitaine-cursors"; + }; + }; + + # gtk's theme settings, generate files: + # 1. ~/.gtkrc-2.0 + # 2. ~/.config/gtk-3.0/settings.ini + # 3. ~/.config/gtk-4.0/settings.ini + gtk = { + enable = true; + # cursorTheme = { + # package = pkgs.capitaine-cursors; + # name = "capitaine-cursors"; + # size = 16; + # }; + + iconTheme = { + package = pkgs.papirus-icon-theme; + name = "Papirus-Dark"; + }; + gtk3.extraConfig = { + gtk-application-prefer-dark-theme = "0"; + gtk-theme-name = "Adwaita-dark"; + gtk-icon-theme-name = "Papirus-Dark"; + gtk-cursor-theme-name = "capitaine-cursors"; + }; + gtk4.extraConfig = { + gtk-application-prefer-dark-theme = "0"; + gtk-theme-name = "Adwaita-dark"; + gtk-icon-theme-name = "Papirus-Dark"; + gtk-cursor-theme-name = "capitaine-cursors"; + }; + }; +} diff --git a/modules/home/v2ray/default.nix b/modules/home/v2ray/default.nix new file mode 100644 index 0000000..24d686f --- /dev/null +++ b/modules/home/v2ray/default.nix @@ -0,0 +1,11 @@ +{ config, lib, pkgs, ... }: + +{ + imports = [ + ]; + + home.packages = with pkgs; [ + v2ray + v2raya + ]; +} \ No newline at end of file diff --git a/modules/home/vscode/default.nix b/modules/home/vscode/default.nix new file mode 100644 index 0000000..344ba38 --- /dev/null +++ b/modules/home/vscode/default.nix @@ -0,0 +1,28 @@ +{ config, lib, pkgs, ... }: + +{ + imports = [ + ]; + programs = { + vscode = { + enable = true; + extensions = with pkgs.vscode-extensions; [ + jnoortheen.nix-ide + esbenp.prettier-vscode + pkief.material-icon-theme + ] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [ + # { + # name = "aws-toolkit-vscode"; + # publisher = "amazonwebservices"; + # version = "1.9.0"; + # sha256 = "erRg/C0qSrPg0cK2qmnULOnFGj/mVQTyBy5Kyj1ZfVw="; + # } + ]; + userSettings = builtins.fromJSON (builtins.readFile ./settings.json); + }; + }; + + home.file.".config/Code/User/keybindings.json" = { + source = ./keybindings.json; + }; +} diff --git a/modules/home/vscode/keybindings.json b/modules/home/vscode/keybindings.json new file mode 100644 index 0000000..b5a24b0 --- /dev/null +++ b/modules/home/vscode/keybindings.json @@ -0,0 +1,69 @@ +// Place your key bindings in this file to override the defaultsauto[] +[ + { + "key": "shift+alt+f", + "command": "workbench.action.findInFiles" + }, + { + "key": "ctrl+shift+f", + "command": "-workbench.action.findInFiles" + }, + { + "key": "shift+alt+f", + "command": "workbench.action.terminal.searchWorkspace", + "when": "terminalFocus && terminalProcessSupported && terminalProcessSupported && terminalTextSelected" + }, + { + "key": "ctrl+shift+f", + "command": "-workbench.action.terminal.searchWorkspace", + "when": "terminalFocus && terminalProcessSupported && terminalProcessSupported && terminalTextSelected" + }, + { + "key": "shift+alt+f", + "command": "workbench.view.search", + "when": "!searchViewletVisible && config.search.mode == 'view'" + }, + { + "key": "ctrl+shift+f", + "command": "-workbench.view.search", + "when": "!searchViewletVisible && config.search.mode == 'view'" + }, + { + "key": "ctrl+shift+f", + "command": "editor.action.formatDocument", + "when": "editorHasDocumentFormattingProvider && editorTextFocus && !editorReadonly && !inCompositeEditor" + }, + { + "key": "ctrl+shift+i", + "command": "-editor.action.formatDocument", + "when": "editorHasDocumentFormattingProvider && editorTextFocus && !editorReadonly && !inCompositeEditor" + }, + { + "key": "ctrl+shift+f", + "command": "editor.action.formatDocument.none", + "when": "editorTextFocus && !editorHasDocumentFormattingProvider && !editorReadonly" + }, + { + "key": "ctrl+shift+i", + "command": "-editor.action.formatDocument.none", + "when": "editorTextFocus && !editorHasDocumentFormattingProvider && !editorReadonly" + }, + { + "key": "shift+alt+o", + "command": "workbench.action.gotoSymbol" + }, + { + "key": "ctrl+shift+o", + "command": "-workbench.action.gotoSymbol" + }, + { + "key": "ctrl+shift+o", + "command": "editor.action.organizeImports", + "when": "editorTextFocus && !editorReadonly && supportedCodeAction =~ /(\\s|^)source\\.organizeImports\\b/" + }, + { + "key": "shift+alt+o", + "command": "-editor.action.organizeImports", + "when": "editorTextFocus && !editorReadonly && supportedCodeAction =~ /(\\s|^)source\\.organizeImports\\b/" + } +] \ No newline at end of file diff --git a/modules/home/vscode/settings.json b/modules/home/vscode/settings.json new file mode 100644 index 0000000..9e9fce5 --- /dev/null +++ b/modules/home/vscode/settings.json @@ -0,0 +1,47 @@ +{ + "[css]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[html]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[javascript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[json]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[jsonc]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[less]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[nix]": { + "editor.defaultFormatter": "jnoortheen.nix-ide" + }, + "[typescript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[typescriptreact]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[vue]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "editor.formatOnPaste": false, + "editor.largeFileOptimizations": false, + "editor.tabSize": 2, + "editor.unicodeHighlight.allowedLocales": { + "zh-hans": true + }, + "editor.unicodeHighlight.nonBasicASCII": false, + "explorer.confirmDelete": false, + "git.enableSmartCommit": true, + "javascript.updateImportsOnFileMove.enabled": "always", + "security.workspace.trust.untrustedFiles": "open", + "terminal.integrated.fontFamily": "\"Source Code Pro\"", + "terminal.integrated.tabs.location": "left", + "typescript.updateImportsOnFileMove.enabled": "always", + "workbench.iconTheme": "material-icon-theme" +} diff --git a/modules/home/xdg.nix b/modules/home/xdg.nix new file mode 100644 index 0000000..4e117e7 --- /dev/null +++ b/modules/home/xdg.nix @@ -0,0 +1,77 @@ +# XDG stands for "Cross-Desktop Group", with X used to mean "cross". +# It's a bunch of specifications from freedesktop.org intended to standardize desktops and +# other GUI applications on various systems (primarily Unix-like) to be interoperable: +# https://www.freedesktop.org/wiki/Specifications/ +{ config, pkgs, ... }: { + home.packages = with pkgs; [ + xdg-utils # provides cli tools such as `xdg-mime` `xdg-open` + xdg-user-dirs + ]; + + xdg = { + enable = true; + cacheHome = config.home.homeDirectory + "/.cache"; + + # manage $XDG_CONFIG_HOME/mimeapps.list + # xdg search all desktop entries from $XDG_DATA_DIRS, check it by command: + # echo $XDG_DATA_DIRS + # the system-level desktop entries can be list by command: + # ls -l /run/current-system/sw/share/applications/ + # the user-level desktop entries can be list by command(user ryan): + # ls /etc/profiles/per-user/ryan/share/applications/ + mimeApps = { + enable = true; + # defaultApplications = + # let + # browser = [ "microsoft-edge.desktop" ]; + # in + # { + # "application/json" = browser; + # "application/pdf" = browser; # TODO: pdf viewer + + # "text/html" = browser; + # "text/xml" = browser; + # "application/xml" = browser; + # "application/xhtml+xml" = browser; + # "application/xhtml_xml" = browser; + # "application/rdf+xml" = browser; + # "application/rss+xml" = browser; + # "application/x-extension-htm" = browser; + # "application/x-extension-html" = browser; + # "application/x-extension-shtml" = browser; + # "application/x-extension-xht" = browser; + # "application/x-extension-xhtml" = browser; + + # "x-scheme-handler/about" = browser; + # "x-scheme-handler/ftp" = browser; + # "x-scheme-handler/http" = browser; + # "x-scheme-handler/https" = browser; + # "x-scheme-handler/unknown" = browser; + + # "x-scheme-handler/discord" = [ "discord.desktop" ]; + # "x-scheme-handler/tg" = [ "telegramdesktop.desktop" ]; + + # "audio/*" = [ "vlc.desktop" ]; + # "video/*" = [ "vlc.dekstop" ]; + # "image/*" = [ "imv.desktop" ]; + # "image/gif" = [ "imv.desktop" ]; + # "image/jpeg" = [ "imv.desktop" ]; + # "image/png" = [ "imv.desktop" ]; + # "image/webp" = [ "imv.desktop" ]; + # }; + + associations.removed = + { + # ...... + }; + }; + + userDirs = { + enable = false; + createDirectories = false; + extraConfig = { + XDG_SCREENSHOTS_DIR = "${config.xdg.userDirs.pictures}/Screenshots"; + }; + }; + }; +} diff --git a/modules/home/zsh.nix b/modules/home/zsh.nix new file mode 100644 index 0000000..e69de29 diff --git a/modules/nixos/adb.nix b/modules/nixos/adb.nix new file mode 100644 index 0000000..94a773b --- /dev/null +++ b/modules/nixos/adb.nix @@ -0,0 +1,5 @@ +{ username, ... }: +{ + programs.adb.enable = true; + users.users.${username}.extraGroups = [ "adbusers" ]; +} diff --git a/modules/nixos/core.nix b/modules/nixos/core.nix new file mode 100644 index 0000000..af56a93 --- /dev/null +++ b/modules/nixos/core.nix @@ -0,0 +1,70 @@ +{ lib, ... }: +{ + programs = { + git.enable = true; + dconf.enable = true; + vim = { + defaultEditor = true; + }; + }; + + + # This setups a SSH server. Very important if you're setting up a headless system. + # Feel free to remove if you don't need it. + services.openssh = { + enable = true; + # Forbid root login through SSH. + # Use keys only. Remove if you want to SSH using password (not recommended) + settings = { + # permitRootLogin = "no"; + # passwordAuthentication = false; + }; + }; + + + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + networking.firewall.enable = lib.mkDefault false; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + + i18n.extraLocaleSettings = { + LC_ADDRESS = "zh_CN.UTF-8"; + LC_IDENTIFICATION = "zh_CN.UTF-8"; + LC_MEASUREMENT = "zh_CN.UTF-8"; + LC_MONETARY = "zh_CN.UTF-8"; + LC_NAME = "zh_CN.UTF-8"; + LC_NUMERIC = "zh_CN.UTF-8"; + LC_PAPER = "zh_CN.UTF-8"; + LC_TELEPHONE = "zh_CN.UTF-8"; + LC_TIME = "zh_CN.UTF-8"; + }; + + time.timeZone = "Asia/Shanghai"; + + nix = { + settings = { + # Enable flakes and new 'nix' command + experimental-features = "nix-command flakes"; + # Deduplicate and optimize nix store + auto-optimise-store = true; + substituters = [ + "https://mirrors.ustc.edu.cn/nix-channels/store" + "https://nixos-cn.cachix.org" + "https://nix-community.cachix.org" + "https://cache.nixos.org/" + ]; + trusted-public-keys = [ + "nixos-cn.cachix.org-1:L0jEaL6w7kwQOPlLoCR3ADx+E3Q8SEFEcB9Jaibl0Xg=" + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; + }; + gc = { + automatic = true; + dates = "daily"; + options = "--delete-older-than 31d"; + }; + }; +} diff --git a/modules/nixos/fonts/default.nix b/modules/nixos/fonts/default.nix new file mode 100644 index 0000000..d8e3820 --- /dev/null +++ b/modules/nixos/fonts/default.nix @@ -0,0 +1,48 @@ +{ config, lib, pkgs, ... }: + +{ + imports = [ + ./fhs-fonts.nix + ]; + + environment.systemPackages = with pkgs; [ + twemoji-color-font + ]; + + # all fonts are linked to /nix/var/nix/profiles/system/sw/share/X11/fonts + fonts = { + # use fonts specified by user rather than default ones + enableDefaultFonts = false; + fontDir.enable = true; + + fonts = with pkgs; [ + # icon fonts + material-design-icons + font-awesome + + # Noto 系列字体是 Google 主导的,名字的含义是「没有豆腐」q(no tofu),因为缺字时显示的方框或者方框被叫作 tofu + # Noto 系列字族名只支持英文,命名规则是 Noto + Sans 或 Serif + 文字名称。 + # 其中汉字部分叫 Noto Sans/Serif CJK SC/TC/HK/JP/KR,最后一个词是地区变种。 + noto-fonts # 大部分文字的常见样式,不包含汉字 + noto-fonts-cjk # 汉字部分 + noto-fonts-emoji # 彩色的表情符号字体 + noto-fonts-extra # 提供额外的字重和宽度变种 + + # 思源系列字体是 Adobe 主导的。其中汉字部分被称为「思源黑体」和「思源宋体」,是由 Adobe + Google 共同开发的 + source-sans # 无衬线字体,不含汉字。字族名叫 Source Sans 3 和 Source Sans Pro,以及带字重的变体,加上 Source Sans 3 VF + source-serif # 衬线字体,不含汉字。字族名叫 Source Code Pro,以及带字重的变体 + source-han-sans # 思源黑体 + source-han-serif # 思源宋体 + + # nerdfonts + (nerdfonts.override { + fonts = [ + # "FiraCode" + "JetBrainsMono" + # "Iosevka" + ]; + }) + + ]; + }; +} diff --git a/modules/nixos/fonts/fhs-fonts.nix b/modules/nixos/fonts/fhs-fonts.nix new file mode 100644 index 0000000..9fc2a47 --- /dev/null +++ b/modules/nixos/fonts/fhs-fonts.nix @@ -0,0 +1,33 @@ +{ + config, + pkgs, + ... +}: { + ################################################################################### + # + # Copy from https://github.com/NixOS/nixpkgs/issues/119433#issuecomment-1326957279 + # Mainly for flatpak + # 1. bindfs resolves all symlink, + # 2. allowing all fonts to be accessed at `/usr/share/fonts` + # 3. without letting /nix into the sandbox. + # + ################################################################################### + + system.fsPackages = [pkgs.bindfs]; + fileSystems = let + mkRoSymBind = path: { + device = path; + fsType = "fuse.bindfs"; + options = ["ro" "resolve-symlinks" "x-gvfs-hide"]; + }; + aggregatedFonts = pkgs.buildEnv { + name = "system-fonts"; + paths = config.fonts.fonts; + pathsToLink = ["/share/fonts"]; + }; + in { + # Create an FHS mount to support flatpak host icons/fonts + "/usr/share/icons" = mkRoSymBind (config.system.path + "/share/icons"); + "/usr/share/fonts" = mkRoSymBind (aggregatedFonts + "/share/fonts"); + }; +} diff --git a/modules/nixos/gnome.nix b/modules/nixos/gnome.nix new file mode 100644 index 0000000..95662b7 --- /dev/null +++ b/modules/nixos/gnome.nix @@ -0,0 +1,47 @@ +{ config, pkgs, ... }: +{ + services.xserver = { + enable = true; + displayManager.gdm.enable = true; + desktopManager.gnome.enable = true; + }; + + environment = { + systemPackages = (with pkgs;[ + gnome.gnome-tweaks + ]) ++ (with pkgs.gnomeExtensions;[ + dash-to-dock + captivate # cap button indicator + appindicator # tray icon + ]); + + gnome.excludePackages = (with pkgs; [ + gnome-photos + gnome-tour + gnome-text-editor + ]) ++ (with pkgs.gnome; [ + atomix # puzzle game + cheese # webcam tool + epiphany # web browser + # geary # email reader + evince # document viewer + gedit # text editor + gnome-contacts + gnome-maps + gnome-weather + gnome-music + gnome-characters + # gnome-terminal + hitori # sudoku game + iagno # go game + simple-scan + totem # video player + tali # poker game + yelp # help viewer + ]); + }; +} + + + + diff --git a/modules/nixos/hyprland.nix b/modules/nixos/hyprland.nix new file mode 100644 index 0000000..99c18a7 --- /dev/null +++ b/modules/nixos/hyprland.nix @@ -0,0 +1,7 @@ +{inputs, pkgs, ...}:{ + # programs.hyprland = { + # enable = true; + # package = inputs.hyprland.packages.${pkgs.system}.hyprland; + # }; + security.pam.services.swaylock = { }; +} diff --git a/modules/nixos/nvidia.nix b/modules/nixos/nvidia.nix new file mode 100644 index 0000000..d404971 --- /dev/null +++ b/modules/nixos/nvidia.nix @@ -0,0 +1,31 @@ +{config, ...}: +{ +# Make sure opengl is enabled + hardware.opengl = { + enable = true; + driSupport = true; + driSupport32Bit = true; + }; + + # Tell Xorg to use the nvidia driver (also valid for Wayland) + services.xserver.videoDrivers = ["nvidia"]; + + hardware.nvidia = { + + # Modesetting is needed for most Wayland compositors + modesetting.enable = true; + + # Use the open source version of the kernel module + # Only available on driver 515.43.04+ + open = false; + + # Enable the nvidia settings menu + nvidiaSettings = true; + + powerManagement.enable = true; + + # Optionally, you may need to select the appropriate driver version for your specific GPU. + package = config.boot.kernelPackages.nvidiaPackages.stable; + }; + +} diff --git a/modules/nixos/samba.nix b/modules/nixos/samba.nix new file mode 100644 index 0000000..19875f9 --- /dev/null +++ b/modules/nixos/samba.nix @@ -0,0 +1,50 @@ +{ username, pkgs, ... }: +{ + + services.samba-wsdd.enable = true; # make shares visible for windows 10 clients + networking.firewall.allowedTCPPorts = [ + 5357 # wsdd + ]; + networking.firewall.allowedUDPPorts = [ + 3702 # wsdd + ]; + services.samba = { + enable = true; + securityType = "user"; + extraConfig = '' + workgroup = WORKGROUP + server string = smbnix + netbios name = smbnix + security = user + #use sendfile = yes + #max protocol = smb2 + # note: localhost is the ipv6 localhost ::1 + hosts allow = 10.7.43. 127.0.0.1 localhost + hosts deny = 0.0.0.0/0 + guest account = nobody + map to guest = bad user + ''; + shares = { + tmp = { + path = "/home/alex/tmp"; + browseable = "yes"; + "read only" = "no"; + "guest ok" = "yes"; + "create mask" = "0644"; + "directory mask" = "0755"; + "force user" = "alex"; + "force group" = "users"; + }; + inst = { + path = "/home/alex/inst"; + browseable = "yes"; + "read only" = "no"; + "guest ok" = "no"; + "create mask" = "0644"; + "directory mask" = "0755"; + "force user" = "alex"; + "force group" = "users"; + }; + }; + }; +} diff --git a/modules/nixos/user-group.nix b/modules/nixos/user-group.nix new file mode 100644 index 0000000..b45707e --- /dev/null +++ b/modules/nixos/user-group.nix @@ -0,0 +1,62 @@ +{ pkgs, username, ... }: + +{ + nix.settings.trusted-users = [ username ]; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users = { + groups = { + docker = { }; + }; + users."${username}" = { + # the hashed password with salt is generated by run `mkpasswd`. + hashedPassword = "$y$j9T$inkrp6FuM46uoPFVrOlbz1$igJed6pECf4AENVaLT4mk.Q4z02MmxjWnGo.OVvCyC."; + home = "/home/${username}"; + isNormalUser = true; + description = username; + extraGroups = [ + "users" + "wheel" + "networkmanager" + "audio" + ]; + openssh.authorizedKeys.keys = [ + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDQOn+imHUzz7KvNYE1mBTjwhMZ0HMyVNwkc6p/6Qak0ejzdyx6mNk9AlKOZB1UQvniWBT8z//u/8DqMT9OL8X0VZmQQTTIpSnvuYRxkH6thkoX9c0umo9GrMGWZN3WIsD71dfiJLMagqPxX7HWgkONBFxJHmBUfP4CXLgLdZs7dUMBm5tILx09zWU7Ttv120NuFdPYENAg8hNka3hjBbXbnDQdp2Y8TPY2Dbcg3MnVZ6Q7LMfKUkVYIoDHEiN6ZAJQaYIU+f2PeNxCb5WqRo2AiZwuzJtQO0VARRIf8hAs5wnX3gU68sWBvLr7payeaYsAyD+C7I4EpyNA8TrwKotrmripv+y5hjHiG7fL97vZEzSfIJH2KEAg7ojGDBbcwAcBKGn4PjwaCdUM7MGm6hj7cMHJf/32rXyc4u7LUZxTjXS5/dKWhF+sCycbBASRlSW93jlnxoUY/zPK4IRnzaF0WL7kUxfBglfFf8UMSgAZNncESNr36hsWFKcFqKUto48= alex@zion.xzdcbj.com.cn" + ]; + }; + }; + + # DO NOT promote the specified user to input password for `nix-store` and `nix-copy-closure` + security.sudo = { + # wheelNeedsPassword = false; + extraRules = [ + { + users = [ username ]; + commands = + [ + { + command = "/run/current-system/sw/bin/nix-store"; + options = [ "NOPASSWD" ]; + } + { + command = "/run/current-system/sw/bin/nixos-rebuild"; + options = [ "NOPASSWD" "SETENV" ]; + } + { + command = "${pkgs.systemd}/bin/systemctl suspend"; + options = [ "NOPASSWD" ]; + } + { + command = "${pkgs.systemd}/bin/reboot"; + options = [ "NOPASSWD" ]; + } + { + command = "${pkgs.systemd}/bin/poweroff"; + options = [ "NOPASSWD" ]; + } + ]; + } + ]; + }; +} + diff --git a/modules/nixos/virtualize/android.nix b/modules/nixos/virtualize/android.nix new file mode 100644 index 0000000..04bc6be --- /dev/null +++ b/modules/nixos/virtualize/android.nix @@ -0,0 +1,7 @@ +{ config, pkgs, lib, ... }: +{ + virtualisation.waydroid.enable = true; # need dns port + environment.systemPackages = [ + pkgs.waydroid-script + ]; +} diff --git a/modules/nixos/virtualize/appimage.nix b/modules/nixos/virtualize/appimage.nix new file mode 100644 index 0000000..887e689 --- /dev/null +++ b/modules/nixos/virtualize/appimage.nix @@ -0,0 +1,9 @@ +{ config, pkgs, lib, ... }: +{ + config = { + environment.systemPackages = with pkgs; [ + appimage-run + ]; + + }; +} diff --git a/modules/nixos/virtualize/docker.nix b/modules/nixos/virtualize/docker.nix new file mode 100644 index 0000000..7536714 --- /dev/null +++ b/modules/nixos/virtualize/docker.nix @@ -0,0 +1,11 @@ +{ config, pkgs, lib, username, ... }: +{ + # Enable Docker + virtualisation.docker.enable = true; + + # Enable Podman + # virtualisation.podman.enable = true; + #virtualisation.podman.dockerCompat = true; # Create a `docker` alias for podman, to use it as a drop-in replacement + + users.users.${username}.extraGroups = lib.mkIf config.virtualisation.docker.enable [ "docker" ]; +} diff --git a/modules/nixos/virtualize/libvirtd/default.nix b/modules/nixos/virtualize/libvirtd/default.nix new file mode 100644 index 0000000..7ec826b --- /dev/null +++ b/modules/nixos/virtualize/libvirtd/default.nix @@ -0,0 +1,45 @@ +{ config, pkgs, lib, username, ... }: +{ + + imports = [ + ./hooks.nix + ]; + + config = { + + # Ref: https://nixos.wiki/wiki/NixOps/Virtualization + + boot = { + kernelModules = [ "kvm-intel" "vfio" "vfio_iommu_type1" "vfio_pci" "vfio_virqfd" ]; + kernelParams = [ "intel_iommu=on" "iommu=pt" ]; + # extraModprobeConfig = "options vfio-pci ids=8086:1901,10de:1b81,10de:10f0"; + }; + virtualisation.libvirtd = { + enable = true; + qemu = { + package = pkgs.qemu_kvm; + ovmf.enable = true; + ovmf.packages = [ pkgs.OVMFFull.fd ]; + swtpm.enable = true; + runAsRoot = false; + }; + }; + + # tpm + security.tpm2 = { + pkcs11.enable = true; # expose /run/current-system/sw/lib/libtpm2_pkcs11.so + enable = true; + tctiEnvironment.enable = true; # TPM2TOOLS_TCTI and TPM2_PKCS11_TCTI env variables + }; + + # Ref: https://nixos.wiki/wiki/Virt-manager + + environment.systemPackages = with pkgs; [ + virt-manager + virglrenderer + #virt-manager-qt + ]; + + users.users.${username}.extraGroups = lib.mkIf config.virtualisation.libvirtd.enable [ "libvirtd" "tss" ]; + }; +} diff --git a/modules/nixos/virtualize/libvirtd/hooks.nix b/modules/nixos/virtualize/libvirtd/hooks.nix new file mode 100644 index 0000000..6659502 --- /dev/null +++ b/modules/nixos/virtualize/libvirtd/hooks.nix @@ -0,0 +1,37 @@ +{ pkgs, ... }: +{ + # Load Hooks for Libvirt + systemd.services.libvirtd.preStart = let + qemuHook = pkgs.writeScript "qemu-hook" '' + #!${pkgs.stdenv.shell} + + GUEST_NAME="$1" + HOOK_NAME="$2" + STATE_NAME="$3" + MISC="$\{@:4}" + + BASEDIR="$(dirname $0)" + + HOOKPATH="$BASEDIR/qemu.d/$GUEST_NAME/$HOOK_NAME/$STATE_NAME" + set -e # If a script exits with an error, we should as well. + + if [ -f "$HOOKPATH" ]; then + eval \""$HOOKPATH"\" "$@" + elif [ -d "$HOOKPATH" ]; then + while read file; do + eval \""$file"\" "$@" + done <<< "$(find -L "$HOOKPATH" -maxdepth 1 -type f -executable -print;)" + fi + ''; + in '' + mkdir -p /var/lib/libvirt/hooks + chmod 755 /var/lib/libvirt/hooks + + # Copy hook files + ln -sf ${qemuHook} /var/lib/libvirt/hooks/qemu + cp -rfT ${./qemu.d} /var/lib/libvirt/hooks/qemu.d + + # Make executable + chmod -R +x /var/lib/libvirt/hooks/qemu.d/ + ''; +} \ No newline at end of file diff --git a/modules/nixos/virtualize/libvirtd/qemu.d/win11/prepare/begin/start.sh b/modules/nixos/virtualize/libvirtd/qemu.d/win11/prepare/begin/start.sh new file mode 100644 index 0000000..febc9fb --- /dev/null +++ b/modules/nixos/virtualize/libvirtd/qemu.d/win11/prepare/begin/start.sh @@ -0,0 +1,44 @@ +#!/run/current-system/sw/bin/bash +set -x + +# Xpad affects the work of the xbox controller and its wireless adapter +# The xpad will shake hands with the handle/wireless adapter when it is plugged in. At this time, +# if you pass the usb device directly to the virtual machine, the xbox handle will not re-handshake with the root of windows, +# which will eventually cause it to fail to work. +# I can't find a way to make the usb device passthrough into the virtual machine from before/when it is plugged in, +# so I suggest you disable this driver if you need to use the gamepad in virtual machine +modprobe -r xpad + +# dGPU PCI slots +pci_slot="01:00" + +# Determine whether the graphics card has been used by VFIO kernel modules +if [ -z "$(lspci -k -s $pci_slot | grep vfio_pci)" ]; then + # Determine whether nvidia kernel modules has been loaded + lsmod_result=$(lsmod | grep nvidia) + if [ -n "$lsmod_result" ]; then + # Stop display manager + systemctl stop display-manager + + sleep 2 + + # Unload NVIDIA kernel modules + modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia + + # Unload AMD kernel module + # modprobe -r amdgpu + fi + + # Detach GPU devices from host + # Use your GPU and HDMI Audio PCI host device + virsh nodedev-detach pci_0000_01_00_0 + virsh nodedev-detach pci_0000_01_00_1 + + # Load vfio module + modprobe vfio_pci + + if [ -n "$lsmod_result" ]; then + # Restart Display Manager + systemctl start display-manager + fi +fi \ No newline at end of file diff --git a/modules/nixos/virtualize/libvirtd/qemu.d/win11/release/end/stop.sh b/modules/nixos/virtualize/libvirtd/qemu.d/win11/release/end/stop.sh new file mode 100644 index 0000000..f3dbbb0 --- /dev/null +++ b/modules/nixos/virtualize/libvirtd/qemu.d/win11/release/end/stop.sh @@ -0,0 +1,13 @@ +#!/run/current-system/sw/bin/bash +set -x + +# Load Xpad +modprobe nvidia_drm nvidia_modeset nvidia_uvm nvidia xpad + +# Attach GPU devices to host +# Use your GPU and HDMI Audio PCI host device +virsh nodedev-reattach pci_0000_01_00_0 +virsh nodedev-reattach pci_0000_01_00_1 + +# Unload vfio module +modprobe -r vfio_pci \ No newline at end of file diff --git a/modules/nixos/virtualize/nixos-generators.nix b/modules/nixos/virtualize/nixos-generators.nix new file mode 100644 index 0000000..4d902d7 --- /dev/null +++ b/modules/nixos/virtualize/nixos-generators.nix @@ -0,0 +1,6 @@ +{ config, pkgs, lib, ... }: +{ + environment.systemPackages = with pkgs; [ + nixos-generators + ]; +} diff --git a/modules/nixos/virtualize/virtualbox.nix b/modules/nixos/virtualize/virtualbox.nix new file mode 100644 index 0000000..c9130c2 --- /dev/null +++ b/modules/nixos/virtualize/virtualbox.nix @@ -0,0 +1,15 @@ +{ config, pkgs, lib, ... }: +{ + config = { + # Enable virtualbox + # Ref: https://nixos.wiki/wiki/Virtualbox + #virtualisation.virtualbox.host.enable = true; + #virtualisation.virtualbox.host.enableExtensionPack = true; //NOTE: this is unfree + #users.extraGroups.vboxusers.members = [ config.owner ]; + + environment.systemPackages = with pkgs; [ + #linuxPackages_latest.virtualboxGuestAdditions + ]; + + }; +} diff --git a/modules/nixos/virtualize/wine.nix b/modules/nixos/virtualize/wine.nix new file mode 100644 index 0000000..a29bb01 --- /dev/null +++ b/modules/nixos/virtualize/wine.nix @@ -0,0 +1,12 @@ +{ config, pkgs, lib, ... }: +{ + config = { + environment.systemPackages = with pkgs; [ + ## [wine] see: https://nixos.wiki/wiki/Wine + #wineWowPackages.staging + #wineWowPackages.fonts + #winetricks + ]; + + }; +} diff --git a/modules/nixos/zfs.nix b/modules/nixos/zfs.nix new file mode 100644 index 0000000..cad2373 --- /dev/null +++ b/modules/nixos/zfs.nix @@ -0,0 +1,7 @@ +{ config, pkgs, ... }: +{ + boot = { + supportedFilesystems = [ "zfs" ]; + kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages; + }; +} diff --git a/nixos-install.sh b/nixos-install.sh new file mode 100755 index 0000000..8d21818 --- /dev/null +++ b/nixos-install.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +nixos-install \ +--option substituters https://mirrors.ustc.edu.cn/nix-channels/store \ +--no-root-passwd --flake .#$1 \ No newline at end of file diff --git a/nixos-switch.sh b/nixos-switch.sh new file mode 100755 index 0000000..8c8887f --- /dev/null +++ b/nixos-switch.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +sudo nixos-rebuild switch --flake . \ No newline at end of file diff --git a/nixpkgs.nix b/nixpkgs.nix new file mode 100644 index 0000000..041de40 --- /dev/null +++ b/nixpkgs.nix @@ -0,0 +1,8 @@ +# A nixpkgs instance that is grabbed from the pinned nixpkgs commit in the lock file +# This is useful to avoid using channels when using legacy nix commands +let lock = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.nixpkgs.locked; +in +import (fetchTarball { + url = "https://github.com/nixos/nixpkgs/archive/${lock.rev}.tar.gz"; + sha256 = lock.narHash; +}) diff --git a/non-nixos-install.sh b/non-nixos-install.sh new file mode 100644 index 0000000..6495bda --- /dev/null +++ b/non-nixos-install.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +nix build .#homeConfigurations.alex.activationPackage + +# active home manager config +./result/activate \ No newline at end of file diff --git a/overlays/default.nix b/overlays/default.nix new file mode 100644 index 0000000..d96dc0c --- /dev/null +++ b/overlays/default.nix @@ -0,0 +1,34 @@ +# This file defines overlays +{ inputs, ... }: +{ + # This one brings our custom packages from the 'pkgs' directory + additions = final: _prev: import ../pkgs { pkgs = final; }; + + # This one contains whatever you want to overlay + # You can change versions, add patches, set compilation flags, anything really. + # https://nixos.wiki/wiki/Overlays + modifications = final: prev: { + # example = prev.example.overrideAttrs (oldAttrs: rec { + # ... + # }); + waybar = prev.waybar.overrideAttrs (oldAttrs: { + mesonFlags = oldAttrs.mesonFlags ++ [ "-Dexperimental=true" ]; + }); + }; + + # When applied, the unstable nixpkgs set (declared in the flake inputs) will + # be accessible through 'pkgs.unstable' + unstable-packages = final: _prev: { + unstable = import inputs.nixpkgs-unstable { + system = final.system; + config.allowUnfree = true; + }; + }; + + nur-packages = final: _prev: { + nur = import inputs.nur { + nurpkgs = final; + pkgs = final; + }; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix new file mode 100644 index 0000000..1c422d5 --- /dev/null +++ b/pkgs/default.nix @@ -0,0 +1,5 @@ +# Custom packages, that can be defined similarly to ones from nixpkgs +# You can build them using 'nix build .#example' or (legacy) 'nix-build -A example' +{ pkgs ? (import ../nixpkgs.nix) { } }: with pkgs; { + waydroid-script = callPackage ./waydroid-script { }; +} diff --git a/pkgs/waydroid-script/default.nix b/pkgs/waydroid-script/default.nix new file mode 100644 index 0000000..6ea789a --- /dev/null +++ b/pkgs/waydroid-script/default.nix @@ -0,0 +1,67 @@ +{ stdenv +, lib +, python3Packages +, fetchFromGitHub +, substituteAll +, lzip +, util-linux +, nix-update-script +}: +let + pname = "waydroid-script"; + version = "unstable-2023-08-25"; + src = fetchFromGitHub { + repo = "waydroid_script"; + owner = "casualsnek"; + rev = "77e222fb166c645a18c6a65aba8547631ff17704"; + hash = "sha256-FstkA6SKqrX0bD4NfyFbPQCLyfHfvWakmiRPmTGo78g="; + }; + + resetprop = stdenv.mkDerivation { + pname = "resetprop"; + inherit version src; + dontBuild = true; + installPhase = '' + mkdir -p $out/share + cp -r bin/* $out/share/ + ''; + }; +in python3Packages.buildPythonApplication rec { + inherit pname version src; + + propagatedBuildInputs = with python3Packages; [ + inquirerpy + requests + tqdm + + lzip + util-linux + ]; + + postPatch = let + setup = substituteAll { + src = ./setup.py; + inherit pname; + desc = meta.description; + version = builtins.replaceStrings [ "-" ] [ "." ] + (lib.strings.removePrefix "unstable-" version); + }; + in '' + ln -s ${setup} setup.py + + substituteInPlace stuff/general.py \ + --replace "os.path.dirname(__file__), \"..\", \"bin\"," "\"${resetprop}/share\"," + ''; + + passthru.updateScript = nix-update-script { + extraArgs = [ "--version=branch" ]; + }; + + meta = with lib; { + description = "Python Script to add libraries to waydroid"; + homepage = "https://github.com/casualsnek/waydroid_script"; + license = licenses.gpl3; + platforms = platforms.linux; + maintainers = with maintainers; [ ataraxiasjel ]; + }; +} \ No newline at end of file diff --git a/pkgs/waydroid-script/setup.py b/pkgs/waydroid-script/setup.py new file mode 100644 index 0000000..5f30afe --- /dev/null +++ b/pkgs/waydroid-script/setup.py @@ -0,0 +1,16 @@ +from setuptools import setup + +setup( + name='@pname@', + version='@version@', + description='@desc@', + packages=["main", "stuff", "tools"], + python_requires='>=3.8', + install_requires = ['tqdm', 'requests', 'InquirerPy'], + package_dir = { + 'main': '.', + }, + entry_points = { + 'console_scripts': ['waydroid-script=main.main:main'], + } +) \ No newline at end of file diff --git a/profiles/gaea/default.nix b/profiles/gaea/default.nix new file mode 100644 index 0000000..e31bd7b --- /dev/null +++ b/profiles/gaea/default.nix @@ -0,0 +1,134 @@ +{ inputs, outputs, lib, pkgs, config, self, username, useremail, hostname, sysversion, ... }: +let + inherit (inputs) home-manager hyprland nixpkgs-unstable; +in +{ + # You can import other NixOS modules here + imports = [ + # If you want to use modules your own flake exports (from modules/nixos): + # outputs.nixosModules.example + + # Or modules from other flakes (such as nixos-hardware): + # inputs.hardware.nixosModules.common-cpu-amd + # inputs.hardware.nixosModules.common-ssd + + # You can also split up your configuration and import pieces of it here: + # ./users.nix + + # Import your generated (nixos-generate-config) hardware configuration + ./hardware-configuration.nix + ./networking.nix + "${self}/modules/nixos/core.nix" + "${self}/modules/nixos/nvidia.nix" + "${self}/modules/nixos/gnome.nix" + "${self}/modules/nixos/hyprland.nix" + "${self}/modules/nixos/user-group.nix" + "${self}/modules/nixos/samba.nix" + "${self}/modules/nixos/zfs.nix" + "${self}/modules/nixos/adb.nix" + + "${self}/modules/nixos/virtualize/libvirtd" + "${self}/modules/nixos/virtualize/android.nix" + "${self}/modules/nixos/virtualize/docker.nix" + + "${self}/modules/nixos/fonts" + + home-manager.nixosModules.home-manager + { + # home-manager.useGlobalPkgs = true; + # home-manager.useUserPackages = true; + home-manager.extraSpecialArgs = { + inherit inputs outputs hostname username useremail hyprland sysversion; + + # enable unstable packages + nixpkgs = nixpkgs-unstable; + pkgs = import nixpkgs-unstable { + system = "x86_64-linux"; + config.allowUnfree = true; + + # if you import pkgs, must specify overlays + overlays = [ + outputs.overlays.additions + outputs.overlays.modifications + outputs.overlays.unstable-packages + outputs.overlays.nur-packages + ]; + }; + }; + home-manager.users."${username}" = import ../../home/desktop.nix; + } + ]; + + boot = { + loader = { + efi = { + canTouchEfiVariables = true; + efiSysMountPoint = "/boot"; + }; + + grub = { + enable = true; + efiSupport = true; + device = "nodev"; + }; + }; + + zfs.extraPools = [ "zroot" ]; + + # Allow to modify store. It's dangerous!! + readOnlyNixStore = true; + }; + + + environment.systemPackages = with pkgs;[ + # audio control software + pamixer + ntfs3g + ]; + + # set hdmi audio default device + hardware.pulseaudio = { + enable = true; + support32Bit = true; + extraConfig = "set-card-profile 1 output:alsa_output.pci-0000_00_1f.3.hdmi-stereo"; + }; + + nix = { + # This will add each flake input as a registry + # To make nix3 commands consistent with your flake + registry = lib.mapAttrs (_: value: { flake = value; }) inputs; + + # This will additionally add your inputs to the system's legacy channels + # Making legacy nix commands consistent as well, awesome! + nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry; + }; + + nixpkgs = { + # You can add overlays here + overlays = [ + # Add overlays your own flake exports (from overlays and pkgs dir): + outputs.overlays.additions + outputs.overlays.modifications + outputs.overlays.unstable-packages + outputs.overlays.nur-packages + + # You can also add overlays exported from other flakes: + # neovim-nightly-overlay.overlays.default + + # Or define it inline, for example: + # (final: prev: { + # hi = final.hello.overrideAttrs (oldAttrs: { + # patches = [ ./change-hello-to-hi.patch ]; + # }); + # }) + ]; + # Configure your nixpkgs instance + config = { + # Disable if you don't want unfree packages + allowUnfree = true; + }; + }; + + # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion + system.stateVersion = sysversion; +} diff --git a/profiles/gaea/hardware-configuration.nix b/profiles/gaea/hardware-configuration.nix new file mode 100644 index 0000000..8fbef2a --- /dev/null +++ b/profiles/gaea/hardware-configuration.nix @@ -0,0 +1,58 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, username, ... }: + +{ + imports = + [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { + device = "/dev/disk/by-uuid/1be5aa7e-2b12-4532-9e42-65cd48b72aa6"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { + device = "/dev/disk/by-uuid/F436-93A1"; + fsType = "vfat"; + }; + + fileSystems."/home/${username}/tmp" = + { + device = "none"; + fsType = "tmpfs"; + options = [ "uid=1000" "gid=100" "defaults" "size=8G" "mode=755" ]; + }; + + fileSystems."/tmp" = + { + device = "tmpfs"; + fsType = "tmpfs"; + }; + + swapDevices = [{ + device = "/var/swapfile"; + size = 8 * 1024; + }]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.eno1.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp4s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/profiles/gaea/networking.nix b/profiles/gaea/networking.nix new file mode 100644 index 0000000..8346d09 --- /dev/null +++ b/profiles/gaea/networking.nix @@ -0,0 +1,42 @@ +{ config, pkgs, hostname, ... }: { + networking = { + hostId = "5def12be"; + hostName = "${hostname}"; + + wireless.enable = false; # Enables wireless support via wpa_supplicant. + + # Configure network proxy if necessary + # proxy.default = "http://user:password@proxy:port/"; + # proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + networkmanager = { + enable = true; + }; + + enableIPv6 = true; + + # Set up bridge network + interfaces.eno1 = { + useDHCP = false; + }; + + bridges = { + br0 = { interfaces = [ "eno1" ]; }; + }; + + interfaces.br0 = { + useDHCP = false; + ipv4.addresses = [ + { + address = "10.7.43.20"; + prefixLength = 32; + } + ]; + }; + defaultGateway = { + address = "10.7.43.1"; + interface = "br0"; + }; + nameservers = [ "119.29.29.29" "223.5.5.5" ]; + }; +} diff --git a/profiles/luna/default.nix b/profiles/luna/default.nix new file mode 100644 index 0000000..e49e00b --- /dev/null +++ b/profiles/luna/default.nix @@ -0,0 +1,142 @@ +{ inputs, outputs, lib, pkgs, config, self, username, useremail, hostname, sysversion, ... }: +let + inherit (inputs) home-manager hyprland; +in +{ + # You can import other NixOS modules here + imports = [ + # If you want to use modules your own flake exports (from modules/nixos): + # outputs.nixosModules.example + + # Or modules from other flakes (such as nixos-hardware): + # inputs.hardware.nixosModules.common-cpu-amd + # inputs.hardware.nixosModules.common-ssd + + # You can also split up your configuration and import pieces of it here: + # ./users.nix + + # Import your generated (nixos-generate-config) hardware configuration + ./hardware-configuration.nix + "${self}/modules/nixos/core.nix" + "${self}/modules/nixos/user-group.nix" + "${self}/modules/nixos/hyprland.nix" + + home-manager.nixosModules.home-manager + { + # home-manager.useGlobalPkgs = true; + # home-manager.useUserPackages = true; + home-manager.extraSpecialArgs = { + inherit inputs outputs hostname username hyprland sysversion; + }; + home-manager.users."${username}" = import ../../home/desktop.nix; + } + ]; + + boot.loader = { + efi = { + canTouchEfiVariables = true; + efiSysMountPoint = "/boot"; + }; + + grub = { + enable = true; + efiSupport = true; + device = "nodev"; + }; + }; + + networking = { + hostName = "${hostname}"; + + wireless.enable = false; # Enables wireless support via wpa_supplicant. + + # Configure network proxy if necessary + # proxy.default = "http://user:password@proxy:port/"; + # proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + networkmanager.enable = true; + + enableIPv6 = false; # disable ipv6 + interfaces.enp0s3 = { + useDHCP = false; + ipv4.addresses = [ + { + address = "10.7.45.130"; + prefixLength = 32; + } + ]; + }; + defaultGateway = "10.7.45.1"; + nameservers = [ + "119.29.29.29" # DNSPod + "223.5.5.5" # AliDNS + ]; + }; + + users.users."${username}".packages = with pkgs; [ + vim + ]; + + + # This setups a SSH server. Very important if you're setting up a headless system. + # Feel free to remove if you don't need it. + services.openssh = { + enable = true; + # Forbid root login through SSH. + # Use keys only. Remove if you want to SSH using password (not recommended) + settings = { + # permitRootLogin = "no"; + # passwordAuthentication = false; + }; + }; + + + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = lib.mkDefault false; + + nix = { + # This will add each flake input as a registry + # To make nix3 commands consistent with your flake + registry = lib.mapAttrs (_: value: { flake = value; }) inputs; + + # This will additionally add your inputs to the system's legacy channels + # Making legacy nix commands consistent as well, awesome! + nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry; + + settings = { + # Enable flakes and new 'nix' command + experimental-features = "nix-command flakes"; + # Deduplicate and optimize nix store + auto-optimise-store = true; + }; + }; + nixpkgs = { + # You can add overlays here + overlays = [ + # Add overlays your own flake exports (from overlays and pkgs dir): + outputs.overlays.additions + outputs.overlays.modifications + outputs.overlays.unstable-packages + + # You can also add overlays exported from other flakes: + # neovim-nightly-overlay.overlays.default + + # Or define it inline, for example: + # (final: prev: { + # hi = final.hello.overrideAttrs (oldAttrs: { + # patches = [ ./change-hello-to-hi.patch ]; + # }); + # }) + ]; + # Configure your nixpkgs instance + config = { + # Disable if you don't want unfree packages + allowUnfree = true; + }; + }; + + # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion + system.stateVersion = sysversion; +} diff --git a/profiles/luna/hardware-configuration.nix b/profiles/luna/hardware-configuration.nix new file mode 100644 index 0000000..3f34a3a --- /dev/null +++ b/profiles/luna/hardware-configuration.nix @@ -0,0 +1,35 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = [ ]; + + boot.initrd.availableKernelModules = [ "ata_piix" "ohci_pci" "ehci_pci" "ahci" "sd_mod" "sr_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/f8c5e9ad-010f-4201-9465-7486c5ffbaaa"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/FEB9-6991"; + fsType = "vfat"; + }; + + swapDevices = [ ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp0s3.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + virtualisation.virtualbox.guest.enable = true; +}