commit ccf46b865e00044e8b150c9213495f83f086a4b1 Author: alex Date: Fri Apr 25 23:10:55 2025 +0800 init diff --git a/README.md b/README.md new file mode 100644 index 0000000..6b2d78f --- /dev/null +++ b/README.md @@ -0,0 +1,172 @@ +# NixOS 和 Home Manager 配置 + +这是一个基于 Nix Flakes 的 NixOS 和 Home Manager 配置仓库,支持多台机器的配置管理。当前系统版本基于 NixOS 24.11。 + +## 目录结构 + +``` +├── home # home manager 配置信息 +│ ├── core.nix # 核心的通用配置,由其他配置引入 +│ ├── desktop.nix # 桌面环境配置 +│ └── server.nix # 服务器配置 +├── libs # 自定义库函数 +│ ├── default.nix # 导出所有库函数 +│ └── mkNixosSystem.nix # 创建nixosSystem的通用函数 +├── modules # 通用模块,不同机器可以根据的需要引入 +│ ├── home # home manager 通用模块 +│ │ └── - # home manager 通用模块 +│ └── nixos # nixos 通用模块 +│ └── - # nixos 通用模块 +├── overlays # 安装包的修改配置 +│ └── - # 安装包的修改配置 +├── pkgs # 自定义软件包 +│ └── - +├── profiles # 不同机器的配置文件, 放置只有特定主机可以使用的配置 +│ ├── apollo # 主服务器配置 +│ │ ├── configuration.nix # 主要配置文件,包含系统模块、服务、用户设置等 +│ │ └── default.nix # 入口文件,负责创建nixosSystem并选择使用的nixpkgs版本 +│ ├── gaea # 主用机配置 +│ │ ├── configuration.nix # 主要配置文件,包含系统模块、服务、用户设置等 +│ │ └── default.nix # 入口文件,负责创建nixosSystem并选择使用的nixpkgs版本 +│ └── luna # 虚拟机配置 +│ ├── configuration.nix # 主要配置文件,包含系统模块、服务、用户设置等 +│ └── default.nix # 入口文件,负责创建nixosSystem并选择使用的nixpkgs版本 +├── flake.lock # flake 锁定文件 +├── flake.nix # nix flake 入口 +├── nixos-install.sh # nixos 全新安装脚本 +├── nixos-switch.sh # 日常更新系统脚本 +├── non-nixos-install.sh # 非NixOS系统安装home-manager配置脚本 +└── nixpkgs.nix # 从flake.lock中提取nixpkgs版本信息,用于非flake命令 +``` + +## 如何安装? + +0. 准备一个 64 位的 nixos [minimal iso image](https://channels.nixos.org/nixos-24.11/latest-nixos-minimal-x86_64-linux.iso) 烧录好,然后进入 live 系统。 +1. 分区 + +使用 fdisk 或 parted 工具进行分区。现在假设两个分区为:`/dev/sda1` `/dev/sda2`。 + +```bash +# 使用parted分区 +parted /dev/nvme0n1 mklabel gpt +parted /dev/nvme0n1 mkpart primary fat32 1MiB 1024MiB +parted /dev/nvme0n1 mkpart primary btrfs 1024MiB 95% +``` + +2. 格式化分区 + +```bash + mkfs.fat -F 32 /dev/nvme0n1p1 # boot / EFI 分区 + mkfs.btrfs /dev/nvme0n1p2 # 系统分区 +``` + +3. 挂载 + +```bash + mount /dev/nvme0n1p2 /mnt + btrfs subvolume create /mnt/home # home 分区 + btrfs subvolume create /mnt/nix # nix 分区 + btrfs subvolume create /mnt/swap # swap 分区 + + umount /mnt + mount -o compress=zstd /dev/nvme0n1p2 /mnt + mkdir -p /mnt/{boot,nix,home,swap} + mount /dev/nvme0n1p1 /mnt/boot + mount -o compress=zstd,noatime,subvol=nix /dev/nvme0n1p2 /mnt/nix + mount -o compress=noatime,subvol=swap /dev/nvme0n1p2 /mnt/swap + mount -o compress=zstd,subvol=home /dev/nvme0n1p2 /mnt/home + + btrfs filesystem mkswapfile --size 16g --uuid clear /mnt/swap/swapfile +``` + +3.1 不变系统 + +如果希望使用不变原子系统(即系统更新时不会修改当前运行的系统,而是创建新的系统生成),在 profile 中引入 `modules/nixos/sysatomic.nix` 模块。这种情况下的挂载方式更简单: + +```bash + mkdir -p /mnt/{boot,nix} + mount /dev/nvme0n1p2 /mnt/nix + mount /dev/nvme0n1p1 /mnt/boot +``` + +4. 生成一个基本的配置 + +```bash + nixos-generate-config --root /mnt +``` + +5. 克隆仓库到本地 + +```bash +git clone https://github.com/synebula/.nix.git /mnt/nix/.nix +cd /mnt/nix/.nix +``` + +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**、**useremail** 和 **sysversion**(系统版本)变量。 + +8. 使用 `mkpasswd {PASSWORD} -m sha-512` 命令生成的密码哈希串替换掉 `/mnt/.nix/modules/nixos/user-group.nix` 中的 `users.users..hashedPassword` 值替换掉。 + +9. 安装 + +```bash +./nixos-install.sh + +# 或者 + +nixos-install --option substituters "https://mirrors.ustc.edu.cn/nix-channels/store https://cache.nixos.org" --no-root-passwd --flake .# + +``` + +10. 重启 + +```bash +reboot +``` + +## 日常使用 + +### NixOS 系统更新 + +在完成对配置文件的修改后,使用以下命令更新系统: + +```bash +# 执行 bash alias +nixos-switch + +# 或执行本机脚本 +./nixos-switch.sh +``` + +### 非 NixOS 系统安装 home-manager 配置 + +在非 NixOS 系统上(如 Ubuntu、Arch Linux 等),可以使用以下命令安装 home-manager 配置: + +```bash +./non-nixos-install.sh +``` + +## 自定义配置 + +要添加新的机器配置,可以在`profiles`目录下创建新的目录,并根据现有的配置文件进行修改。 + +要添加新的模块,可以在`modules`目录下创建新的模块文件,并在相应的配置文件中引入。 + +## profiles 目录和 nixosSystem 创建 + +在这个配置中,我们使用了一个抽象的方法来创建 nixosSystem,同时保留了每个 profile 自行决定使用哪个版本的 nixpkgs 的能力,并简化了参数传递: + +1. **libs/mkNixosSystem.nix** - 这个文件提供了一个通用函数,用于创建 nixosSystem。它接受以下参数: + + - `args`: 从 flake.nix 传递的所有参数,包含 self、inputs、outputs、username 等 + - `nixpkgs`: 要使用的 nixpkgs (由 profile 的 default.nix 决定) + - `path`: profile 目录的路径 + +2. **profiles/[hostname]/default.nix** - 这是配置的入口文件,负责选择使用的 nixpkgs 版本并调用 libs.mkNixosSystem 函数。 + +3. **profiles/[hostname]/configuration.nix** - 包含实际的配置内容,如系统模块、服务、用户设置等。 diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..45888d9 --- /dev/null +++ b/flake.lock @@ -0,0 +1,103 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1744743431, + "narHash": "sha256-iyn/WBYDc7OtjSawbegINDe/gIkok888kQxk3aVnkgg=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "c61bfe3ae692f42ce688b5865fac9e0de58e1387", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-24.11", + "repo": "home-manager", + "type": "github" + } + }, + "home-manager-unstable": { + "inputs": { + "nixpkgs": [ + "nixpkgs-unstable" + ] + }, + "locked": { + "lastModified": 1745205007, + "narHash": "sha256-k67bEcLkSo13TIBfs0CGYkJjG12aaikabMtxWbSeqr0=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "3fbe9a2b76ff5c4dcb2a2a2027dac31cfc993c8c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "impermanence": { + "locked": { + "lastModified": 1737831083, + "narHash": "sha256-LJggUHbpyeDvNagTUrdhe/pRVp4pnS6wVKALS782gRI=", + "owner": "nix-community", + "repo": "impermanence", + "rev": "4b3e914cdf97a5b536a889e939fb2fd2b043a170", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "impermanence", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1744440957, + "narHash": "sha256-FHlSkNqFmPxPJvy+6fNLaNeWnF1lZSgqVCl/eWaJRc4=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "26d499fc9f1d567283d5d56fcf367edd815dba1d", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-24.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1744932701, + "narHash": "sha256-fusHbZCyv126cyArUwwKrLdCkgVAIaa/fQJYFlCEqiU=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "b024ced1aac25639f8ca8fdfc2f8c4fbd66c48ef", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "home-manager-unstable": "home-manager-unstable", + "impermanence": "impermanence", + "nixpkgs": "nixpkgs", + "nixpkgs-unstable": "nixpkgs-unstable" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..12d453c --- /dev/null +++ b/flake.nix @@ -0,0 +1,82 @@ +{ + 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; + in + rec { + # Your custom packages and modifications, exported as overlays + overlays = import ./overlays { inherit inputs; }; + + # NixOS configuration entrypoint + # Available through 'nixos-rebuild --flake .#your-hostname' + # The default.nix file in each profile directory is responsible for creating its own nixosSystem. + nixosConfigurations = + with builtins; listToAttrs (map + (profile: { + name = profile; + value = import ./profiles/${profile} { + inherit self libs inputs outputs username useremail sysversion; + }; + }) + (attrNames (readDir ./profiles)) + ); + + # 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 = { + "${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-24.11"; + nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; + + # The Nix User Repository + # nur.url = github:nix-community/NUR; + + # Home manager + home-manager = { + url = "github:nix-community/home-manager/release-24.11"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + home-manager-unstable = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs-unstable"; + }; + + # Impermanence system + impermanence.url = "github:nix-community/impermanence"; + + # 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..fb39c85 --- /dev/null +++ b/home/core.nix @@ -0,0 +1,112 @@ +# This is your home-manager configuration file +# Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix) + +{ 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 git + programs = { + 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 = { + la = "ls -la"; + ll = "ls -l"; + "nixos-switch" = "sudo nixos-rebuild switch --flake /home/${username}/.nix"; + }; + }; + + vim = { + enable = true; + defaultEditor = 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..7b3b1d6 --- /dev/null +++ b/home/desktop.nix @@ -0,0 +1,56 @@ +# 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, ... }: +{ + # 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: + ./core.nix + ../modules/home/hyprland + ../modules/home/vscode + ../modules/home/zsh + ../modules/home/xdg.nix + ../modules/home/theme.nix + ../modules/home/fcitx.nix + ../modules/home/wechat.nix + ]; + + home = { + # Add stuff for your user as you see fit: + packages = with pkgs; [ + bc # GNU software calculator + vlc + imv # image viewer + microsoft-edge + chromium + wpsoffice + yazi # terminal file manager + + zip + unzip + usbutils # lsusb etc. + lsof # lsof process util + htop # process monitor + pciutils # lspci etc. + ]; + + sessionVariables = { + JAVA_HOME = ""; + }; + }; + + + + # 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..4cf2f63 --- /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, ... }: { + # 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..da1b209 --- /dev/null +++ b/libs/default.nix @@ -0,0 +1,8 @@ +let + # 导入mkNixosSystem函数 + mkNixosSystemLib = import ./mkNixosSystem.nix; +in +{ + # 导出mkNixosSystem函数 + inherit (mkNixosSystemLib) mkNixosSystem; +} diff --git a/libs/mkNixosSystem.nix b/libs/mkNixosSystem.nix new file mode 100644 index 0000000..433e7d7 --- /dev/null +++ b/libs/mkNixosSystem.nix @@ -0,0 +1,22 @@ +# 这个文件提供了一个通用函数,用于创建nixosSystem +{ + # 创建nixosSystem的通用函数 + # 这个函数只负责创建nixosSystem,不处理nixpkgs的选择 + # args: 从flake.nix传递的所有参数 + # profile: 要使用的nixpkgs (由profile的default.nix决定) + # path: profile目录的路径 + mkNixosSystem = { args, nixpkgs, path }: + let + # 获取profile名称(目录名) + profile = builtins.baseNameOf path; + specialArgs = args // { hostname = profile; }; # 添加hostname + in + nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + inherit specialArgs; + modules = [ + # 导入configuration.nix模块,其中包含了实际的配置 + "${path}/configuration.nix" + ]; + }; +} diff --git a/modules/home/develop.nix b/modules/home/develop.nix new file mode 100644 index 0000000..607643a --- /dev/null +++ b/modules/home/develop.nix @@ -0,0 +1,18 @@ +{ pkgs, ... }: + +{ + imports = [ + ]; + + home = { + packages = with pkgs.unstable; [ + dbeaver-bin + go + nodejs + yarn + + steam-run + jetbrains.idea-community + ]; + }; +} diff --git a/modules/home/fcitx.nix b/modules/home/fcitx.nix new file mode 100644 index 0000000..5ab3647 --- /dev/null +++ b/modules/home/fcitx.nix @@ -0,0 +1,26 @@ +# 输入法配置模块 +{ config, lib, pkgs, ... }: { + + i18n.inputMethod = { + enabled = "fcitx5"; + fcitx5 = { + addons = with pkgs; [ + fcitx5-gtk + fcitx5-chinese-addons + fcitx5-nord + ]; + waylandFrontend = true; # available in home-manager-25.05 + }; + }; + + gtk = { + gtk3.extraConfig = lib.mkOptionDefault { + gtk-im-module = "fcitx"; + }; + + gtk4.extraConfig = lib.mkOptionDefault { + gtk-im-module = "fcitx"; + }; + }; + +} 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..e3ddc5a --- /dev/null +++ b/modules/home/hyprland/conf/hypr/hyprland.conf @@ -0,0 +1,143 @@ +###################################################################################### +#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 = mako # 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 = ~/.config/swww/swwwallpaper.sh # start wallpaper daemon +exec-once = fcitx5 -d -r +#exec-once = swayidle -w timeout 900 'hyprctl dispatch dpms off' resume 'hyprctl dispatch dpms on' # turn off monitor after 15 mins + + + +# █▀▀ █▄░█ █░█ +# ██▄ █░▀█ ▀▄▀ + +# Some default env vars. + +# env = XDG_CURRENT_DESKTOP,Hyprland +# env = XDG_SESSION_TYPE,wayland +# env = XDG_SESSION_DESKTOP,Hyprland +# env = GDK_BACKEND,wayland +# env = QT_QPA_PLATFORM,wayland +# #env = QT_STYLE_OVERRIDE,kvantum +# env = QT_QPA_PLATFORMTHEME,qt5ct +# env = QT_WAYLAND_DISABLE_WINDOWDECORATION,1 +# env = QT_AUTO_SCREEN_SCALE_FACTOR,1 +# env = XDG_PICTURES_DIR,$HOME/Pictures + + + +# █ █▄░█ █▀█ █░█ ▀█▀ +# █ █░▀█ █▀▀ █▄█ ░█░ + +# For all categories, see https://wiki.hyprland.org/Configuring/Variables/ + +input { + kb_layout = us + kb_variant = + kb_model = + kb_options = + kb_rules = + follow_mouse = 0 # 0 = disabled, 1 = enabled, 2 = enabled but only when mouse is over a window + + 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 +#} + + + +# █▀▄▀█ █ █▀ █▀▀ +# █░▀░█ █ ▄█ █▄▄ + +# See https://wiki.hyprland.org/Configuring/Variables/ for more + +misc { + vrr = 0 +} + + + +# █▀ █▀█ █░█ █▀█ █▀▀ █▀▀ +# ▄█ █▄█ █▄█ █▀▄ █▄▄ ██▄ + +# 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..4c2a995 --- /dev/null +++ b/modules/home/hyprland/conf/hypr/keybindings.conf @@ -0,0 +1,146 @@ +# █▄▀ █▀▀ █▄█ █▄▄ █ █▄░█ █▀▄ █ █▄░█ █▀▀ █▀ +# █░█ ██▄ ░█░ █▄█ █ █░▀█ █▄▀ █ █░▀█ █▄█ ▄█ + + +# 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 +$terminal = kitty +$filemanager = dolphin + + + +################################################ +# Main actions +################################################ +bind = $mainMod, Q, exec, ~/.config/hypr/scripts/dontkillsteam.sh # killactive, # kill the window on focus +bind = $mainMod CTRL, delete, 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 = $mainMod, return, fullscreen, # toggle the window on focus to fullscreen + +# Application shortcuts +bind = $mainMod, grave, exec, $terminal # ~ open terminal +bind = $mainMod, E, exec, $filemanager # 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 || rofi -show drun # launch desktop applications +bind = $mainMod, tab, exec, pkill rofi || rofi -show window # switch between desktop applications +bind = $mainMod, D, exec, pkill rofi || rofi -show filebrowser # browse system files +bind = $mainMod, R, exec, pkill rofi || rofi -show run # run a command + +# 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 = , PRINT, exec, hyprshot -m window # logout menu +bind = ALT, PRINT, exec, hyprshot -m region # logout menu +bind = $CONTROL SHIFT, P, pass, ^(com\.obsproject\.Studio)$ # start/stop obs screen recording + + +################################################ +# Exec custom scripts +################################################ +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 CTRL, right, workspace, e+1 +bind = $mainMod, mouse_up, workspace, e+1 +bind = $mainMod CTRL, left, workspace, e-1 +bind = $mainMod, mouse_down, 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..c5db16a --- /dev/null +++ b/modules/home/hyprland/conf/hypr/monitors.conf @@ -0,0 +1,22 @@ +# █▀▄▀█ █▀█ █▄░█ █ ▀█▀ █▀█ █▀█ █▀ +# █░▀░█ █▄█ █░▀█ █ ░█░ █▄█ █▀▄ ▄█ + +# See https://wiki.hyprland.org/Configuring/Monitors/ + +# monitor = name, resolution, offset, scale, extra-args +# monitor = ,preferred,auto,auto +monitor = HDMI-A-2, 1920x1080@60, 1080x0, 1 +monitor = HDMI-A-3, preferred, auto, 1 +# monitor = DP-3, 1920x1080@60, x0, 1, transform,1 + +workspace = 1,monitor:HDMI-A-3 +workspace = 2,monitor:HDMI-A-3 +workspace = 3,monitor:HDMI-A-3 +workspace = 4,monitor:HDMI-A-3 +workspace = 5,monitor:HDMI-A-3 + +workspace = 6,monitor:HDMI-A-2 +workspace = 7,monitor:HDMI-A-2 +workspace = 8,monitor:HDMI-A-2 +workspace = 9,monitor:HDMI-A-2 +workspace = 10,monitor:HDMI-A-2 diff --git a/modules/home/hyprland/conf/hypr/nvidia.conf b/modules/home/hyprland/conf/hypr/nvidia.conf new file mode 100644 index 0000000..af6395b --- /dev/null +++ b/modules/home/hyprland/conf/hypr/nvidia.conf @@ -0,0 +1,26 @@ + +# █▄░█ █░█ █ █▀▄ █ ▄▀█ +# █░▀█ ▀▄▀ █ █▄▀ █ █▀█ + +# Hyprland Nvidia Configuration +# See https://wiki.hyprland.org/Nvidia/ +env = LIBVA_DRIVER_NAME,nvidia +env = __GLX_VENDOR_LIBRARY_NAME,nvidia # Disable this if you have issues with screensharing + +# If you want to try hardware cursors, +# you can enable them by setting `cursor:no_hardware_cursors = false` , +# but it will require also enabling `cursor:allow_dumb_copy` +# which may cause small to major hitches whenever the cursor shape changes. +# If this is a problem on your system, keep hardware cursors disabled. +cursor:no_hardware_cursors = true # Set to true to avoid hitches +# cursor:allow_dumb_copy = true + +# https://wiki.hyprland.org/Nvidia/#va-api-hardware-video-acceleration +# Hardware video acceleration on Nvidia and Wayland is +# possible with the nvidia-vaapi-driver. +# This may solve specific issues in Electron apps. +env = NVD_BACKEND,direct # Requires 'libva-nvidia-driver' package + +# https://wiki.hyprland.org/Nvidia/#regarding-environment-variables +# If you encounter crashes in Firefox, remove this line +env = GBM_BACKEND,nvidia-drm 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..c0e1696 --- /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 + notify-send $ncolor "brightctl" -i $ico -a "$brightness$bar" "Device: $brightinfo" -r 91190 -t 800 + + else + notify-send -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/create-dirs.sh b/modules/home/hyprland/conf/hypr/scripts/create-dirs.sh new file mode 100644 index 0000000..a1d868e --- /dev/null +++ b/modules/home/hyprland/conf/hypr/scripts/create-dirs.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# 创建截图目录 +mkdir -p $HOME/tmp/Screenshots 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/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..13610db --- /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" +notify-send $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..ddf119a --- /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') + notify-send $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 + notify-send $ncolor "volctl" -a "muted" "$nsink" -i ${icodir}/muted-${dvce}.svg -r 91190 -t 800 + else + notify-send $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..11a8aca --- /dev/null +++ b/modules/home/hyprland/conf/hypr/theme.conf @@ -0,0 +1,41 @@ +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 = 2 + gaps_out = 4 + 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 + 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..7e50d68 --- /dev/null +++ b/modules/home/hyprland/conf/hypr/windowrules.conf @@ -0,0 +1,30 @@ + +# █░█░█ █ █▄░█ █▀▄ █▀█ █░█░█   █▀█ █░█ █░░ █▀▀ █▀ +# ▀▄▀▄▀ █ █░▀█ █▄▀ █▄█ ▀▄▀▄▀   █▀▄ █▄█ █▄▄ ██▄ ▄█ + + +# 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 + +# Float rules for system dialogs and popups +# windowrulev2 = center, class:^((?!fcitx).)*$ +windowrulev2 = center,class:^(.*)$,title:^(Open [Ff]ile) +windowrulev2 = center,class:^(.*)$,title:^(Open [Ff]older) +windowrulev2 = center,class:^(.*)$,title:^(Save [Ff]ile) +windowrulev2 = center,class:^(.*)$,title:^(Save [Aa]s) +windowrulev2 = center,class:^(.*)$,title:^(Location)$ +windowrulev2 = center,class:^(Code)$ + +windowrulev2 = opacity 0.90 0.90,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.70,class:^(pavucontrol)$ +windowrulev2 = opacity 0.80 0.70,class:^(blueman-manager)$ + +windowrulev2 = float,class:^(pavucontrol)$ +windowrulev2 = float,class:^(blueman-manager)$ + diff --git a/modules/home/hyprland/conf/kitty/kitty.conf b/modules/home/hyprland/conf/kitty/kitty.conf new file mode 100644 index 0000000..77ae653 --- /dev/null +++ b/modules/home/hyprland/conf/kitty/kitty.conf @@ -0,0 +1,88 @@ +# 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 + +# 终端兼容性设置 +term xterm-256color +shell_integration no-rc + +# 修复 SSH 退格键问题 +map ctrl+h send_text all \x08 +backspace_sends_backspace yes diff --git a/modules/home/hyprland/conf/mako/config b/modules/home/hyprland/conf/mako/config new file mode 100644 index 0000000..cb148bd --- /dev/null +++ b/modules/home/hyprland/conf/mako/config @@ -0,0 +1,28 @@ +sort=-time +layer=overlay +background-color=#2e3440 +width=360 +height=160 +padding=10 +border-size=2 +border-color=#88c0d0 +border-radius=15 +icons=1 +max-icon-size=64 +default-timeout=10000 +ignore-timeout=1 +font=monospace 8 + +[urgency=low] +border-color=#cccccc + +[urgency=normal] +border-color=#d08770 + +[urgency=high] +border-color=#bf616a +default-timeout=0 + +[category=mpd] +default-timeout=2000 +group-by=category \ No newline at end of file diff --git a/modules/home/hyprland/conf/rofi/config.rasi b/modules/home/hyprland/conf/rofi/config.rasi new file mode 100644 index 0000000..a038244 --- /dev/null +++ b/modules/home/hyprland/conf/rofi/config.rasi @@ -0,0 +1,126 @@ +/* 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: 0px; + padding: 0px; + spacing: 0px; +} + +/* 主窗口样式 */ +window { + background-color: @bg0; + location: center; + width: 560px; + height: 450px; + border-radius: 8px; + border: 1px; + border-color: @bg1; +} + +/* 搜索输入栏样式 */ +inputbar { + font: "Montserrat 18"; + padding: 12px; + spacing: 12px; + children: [ icon-search, entry]; +} + +/* 搜索图标样式 */ +icon-search { + expand: false; + filename: "search"; + size: 24px; +} + +/* 元素垂直对齐设置 */ +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: 0px; + border-radius: 4px; + 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.35em; +} diff --git a/modules/home/hyprland/conf/waybar/config.jsonc b/modules/home/hyprland/conf/waybar/config.jsonc new file mode 100644 index 0000000..da28b29 --- /dev/null +++ b/modules/home/hyprland/conf/waybar/config.jsonc @@ -0,0 +1,205 @@ +// --// waybar config generated by wbarconfgen.sh //-- // + +{ + // sourced from header module // + + "layer": "top", + "position": "top", + "mod": "dock", + "height": 28, + "exclusive": true, + "passthrough": false, + "gtk-layer-shell": true, + + // positions generated based on config.ctl // + + "modules-left": [ + "custom/lr", + "hyprland/workspaces", + "hyprland/window", + "custom/rr" + ], + "modules-center": ["custom/lr", "clock", "custom/rr"], + "modules-right": [ + "custom/lr", + "wlr/taskbar", + "custom/rr", + "custom/lr", + "tray", + "custom/rr", + "custom/lr", + "cpu", + "temperature", + "memory", + "custom/rr", + "custom/lr", + "network", + "bluetooth", + "wireplumber", + "wireplumber#microphone", + "custom/cliphist", + "custom/power", + "custom/rr" + ], + + // 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 + }, + + "hyprland/workspaces": { + "disable-scroll": true, + "on-click": "activate", + "persistent_workspaces": { + "1": ["HDMI-A-3"], + "2": ["HDMI-A-3"], + "3": ["HDMI-A-3"], + "4": ["HDMI-A-3"], + "5": ["HDMI-A-3"], + "6": ["HDMI-A-2"], + "7": ["HDMI-A-2"], + "8": ["HDMI-A-2"], + "9": ["HDMI-A-2"], + "10": ["HDMI-A-2"] + } + }, + + "clock": { + "format": "{:%Y/%m/%d %H:%M}", + "format-alt": "{:%I:%M%p 周%u}", + "tooltip-format": "{calendar}", + "locale": "zh_CN.UTF-8" + }, + + "wlr/taskbar": { + "format": "{icon}", + "icon-size": 14, + "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" + } + }, + + "tray": { + "icon-size": 14, + "spacing": 4 + }, + + "cpu": { + "interval": 10, + "format": "󰍛 {usage}%", + "format-alt": "{icon0}{icon1}{icon2}{icon3}", + "format-icons": ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"] + }, + + "temperature": { + "interval": 10, + "hwmon-path": "/sys/devices/platform/coretemp.0/hwmon/hwmon2/temp1_input", + "format": " {temperatureC}°C" + }, + + "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}" + }, + + "wireplumber": { + "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": ["", "", ""] + } + }, + + "wireplumber#microphone": { + "format": "{format_source}", + "format-source": "", + "format-source-muted": "", + "on-click": "c -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/lr": { + "format": " ", + "interval": "once", + "tooltip": false + }, + + "custom/rr": { + "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..5852913 --- /dev/null +++ b/modules/home/hyprland/conf/waybar/style.css @@ -0,0 +1,143 @@ +@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: 12px; + min-height: 12px; +} + +window#waybar { + background: @bar-bg; +} + +tooltip { + background: @tool-bg; + color: @tool-color; + border-radius: 16px; + border-width: 1px; + border-style: solid; + border-color: @tool-border; +} + +#workspaces button { + box-shadow: none; + text-shadow: none; + padding: 0px; + border-radius: 8px; + margin-top: 2px; + margin-bottom: 2px; + margin-left: 2px; + margin-right: 2px; + padding-left: 2px; + padding-right: 2px; + color: @wb-color; + animation: gradient_f 20s ease-in infinite; + transition: all 0.5s cubic-bezier(0.55, -0.68, 0.48, 1.682); +} + +#workspaces button.active { + background: @wb-act-bg; + color: @wb-act-color; + animation: gradient_f 20s ease-in infinite; + transition: all 0.3s cubic-bezier(0.55, -0.68, 0.48, 1.682); +} + +#workspaces button:hover { + background: @wb-hvr-bg; + color: @wb-hvr-color; + padding-left: 2px; + padding-right: 2px; + animation: gradient_f 20s ease-in infinite; + transition: all 0.3s cubic-bezier(0.55, -0.68, 0.48, 1.682); +} + +#taskbar button { + box-shadow: none; + text-shadow: none; + padding: 0px; + border-radius: 8px; + margin-top: 2px; + margin-bottom: 2px; + margin-right: 2px; + padding-left: 2px; + padding-left: 2px; + padding-right: 2px; + color: @wb-color; + animation: gradient_f 20s ease-in infinite; + transition: all 0.5s cubic-bezier(0.55, -0.68, 0.48, 1.682); +} + +#taskbar button.active { + background: @wb-act-bg; + color: @wb-act-color; + animation: gradient_f 20s ease-in infinite; + transition: all 0.3s cubic-bezier(0.55, -0.68, 0.48, 1.682); +} + +#taskbar button:hover { + background: @wb-hvr-bg; + color: @wb-hvr-color; + padding-left: 2px; + padding-right: 2px; + animation: gradient_f 20s ease-in infinite; + transition: all 0.3s cubic-bezier(0.55, -0.68, 0.48, 1.682); +} + +#cpu, +#memory, +#temperature, +#battery, +#clock, +#workspaces, +#window, +#taskbar, +#network, +#bluetooth, +#wireplumber, +#mpris, +#custom-updates, +#custom-wallchange, +#custom-mode, +#custom-cliphist, +#custom-power, +#custom-wbar, +#custom-lr, +#custom-rr, +#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-rr { + border-radius: 0px 24px 24px 0px; + margin-right: 4px; + padding-right: 2px; +} + +#custom-lr { + border-radius: 24px 0px 0px 24px; + margin-left: 4px; + padding-left: 2px; +} 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..bd7f285 --- /dev/null +++ b/modules/home/hyprland/default.nix @@ -0,0 +1,93 @@ +{ config, lib, pkgs, ... }: + +{ + imports = [ + ./env.nix + ]; + + wayland.windowManager.hyprland = { + # Whether to enable Hyprland wayland compositor + enable = true; + # The hyprland package to use + package = pkgs.hyprland; + # Whether to enable XWayland + xwayland.enable = true; + + # Optional + # Whether to enable hyprland-session.target on hyprland startup + # systemd.enable = true; + settings = lib.mkDefault { + decoration = { + shadow_offset = "0 5"; + "col.shadow" = "rgba(00000099)"; + }; + }; + }; + + home.packages = with pkgs; [ + waybar # the status bar + swww # wallpaper + libnotify # for notify-send command + mako # notify daemon + hyprshot #screenshot + rofi # app launcher + kitty # terminal + wlogout # logout menu + killall + pavucontrol # audio control + nautilus #file manager for GNOME + ]; + + + programs = { + bash = { + initExtra = '' + if [ -z $DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; + then + echo 'Welcome! ' + fi + ''; + }; + + swaylock.enable = true; + }; + + # 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/mako" = { + source = ./conf/mako; + 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..9c436b3 --- /dev/null +++ b/modules/home/hyprland/env.nix @@ -0,0 +1,39 @@ +{ ... }: + +{ + home = { + sessionVariables = { + EDITOR = "vim"; + BROWSER = "microsoft-edge"; + TERMINAL = "kitty"; + QT_QPA_PLATFORMTHEME = "gtk4"; + 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_EGL_NO_MODIFIRES = "1"; + WLR_NO_HARDWARE_CURSORS = "1"; # if no cursor,uncomment this line + WLR_RENDERER_ALLOW_SOFTWARE = "1"; + + CLUTTER_BACKEND = "wayland"; + + XDG_CURRENT_DESKTOP = "Hyprland"; + XDG_SESSION_DESKTOP = "Hyprland"; + XDG_SESSION_TYPE = "wayland"; + XDG_BIN_HOME = "\${HOME}/.local/bin"; + XDG_PICTURES_DIR = "\${HOME}/tmp"; + }; + 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..ef6bdeb --- /dev/null +++ b/modules/home/vscode/default.nix @@ -0,0 +1,31 @@ +{ pkgs, ... }: + +{ + imports = [ + ]; + programs = { + vscode = { + enable = true; + profiles.default = { + extensions = with pkgs.vscode-extensions; [ + bierner.markdown-mermaid + esbenp.prettier-vscode + foxundermoon.shell-format + github.copilot + github.copilot-chat + golang.go + jnoortheen.nix-ide + pkief.material-icon-theme + ] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [ + ]; + 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..23c4745 --- /dev/null +++ b/modules/home/vscode/settings.json @@ -0,0 +1,52 @@ +{ + "[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" + }, + "[typescript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[typescriptreact]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[vue]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[nix]": { + "editor.defaultFormatter": "jnoortheen.nix-ide" + }, + "editor.formatOnPaste": false, + "editor.largeFileOptimizations": false, + "editor.tabSize": 4, + "editor.unicodeHighlight.allowedLocales": { + "zh-hans": true + }, + "editor.unicodeHighlight.nonBasicASCII": false, + "explorer.confirmDelete": false, + "git.enableSmartCommit": true, + "javascript.updateImportsOnFileMove.enabled": "always", + "nix.formatterPath": "nixpkgs-fmt", + "security.workspace.trust.untrustedFiles": "open", + "terminal.integrated.fontFamily": "'Source Code Pro', 'JetBrainsMono Nerd Font'", + "terminal.integrated.tabs.location": "left", + "typescript.updateImportsOnFileMove.enabled": "always", + "workbench.iconTheme": "material-icon-theme", + "workbench.colorTheme": "Default Light Modern", + "augment.chat.userGuidelines": "Always response in 中文", + "augment.completions.enableAutomaticCompletions": true, + "editor.fontFamily": "'Droid Sans Mono', 'monospace', monospace, 'JetBrainsMono Nerd Font'" +} diff --git a/modules/home/wechat.nix b/modules/home/wechat.nix new file mode 100644 index 0000000..f8c8029 --- /dev/null +++ b/modules/home/wechat.nix @@ -0,0 +1,11 @@ +{ pkgs, ... }: { + home = { + packages = with pkgs.unstable; [ + wechat-uos + ]; + + sessionVariables = { + WECHAT_DATA_DIR = "~/.local/WeChat"; + }; + }; +} diff --git a/modules/home/xdg.nix b/modules/home/xdg.nix new file mode 100644 index 0000000..6746f59 --- /dev/null +++ b/modules/home/xdg.nix @@ -0,0 +1,84 @@ +# 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; + documents = config.home.homeDirectory + "/doc"; + music = config.home.homeDirectory + "/doc/music"; + desktop = config.home.homeDirectory + "/tmp"; + download = config.home.homeDirectory + "/tmp"; + videos = config.home.homeDirectory + "/tmp"; + pictures = config.home.homeDirectory + "/tmp"; + templates = config.home.homeDirectory + "/tmp"; + extraConfig = { + XDG_SCREENSHOTS_DIR = config.home.homeDirectory + "/tmp/Screenshots"; + }; + }; + }; +} diff --git a/modules/home/zsh/default.nix b/modules/home/zsh/default.nix new file mode 100644 index 0000000..e753b7c --- /dev/null +++ b/modules/home/zsh/default.nix @@ -0,0 +1,46 @@ +{ username, pkgs, ... }: +{ + programs = { + zsh = { + enable = true; + enableCompletion = true; + autosuggestion.enable = true; + syntaxHighlighting.enable = true; + + shellAliases = { + la = "ls -la"; + ll = "ls -l"; + "nixos-switch" = "sudo nixos-rebuild switch --flake /home/${username}/.nix"; + f = "fuck"; + }; + + history.size = 10000; + history.ignoreAllDups = true; + history.path = "$HOME/.zsh_history"; + history.ignorePatterns = [ "rm *" "pkill *" "cp *" ]; + + oh-my-zsh = { + enable = true; + plugins = [ "git" "sudo" "docker" "docker-compose" ]; + }; + + plugins = [ + { + name = "powerlevel10k"; + src = pkgs.zsh-powerlevel10k; + file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme"; + } + { + name = "powerlevel10k-config"; + src = ./powerlevel10k; + file = "p10k.zsh"; + } + ]; + }; + + thefuck = { + enable = true; + enableZshIntegration = true; # 自动为 Zsh 设置别名 (通常是 'fuck') + }; + }; +} diff --git a/modules/home/zsh/powerlevel10k/p10k.zsh b/modules/home/zsh/powerlevel10k/p10k.zsh new file mode 100644 index 0000000..46ebda7 --- /dev/null +++ b/modules/home/zsh/powerlevel10k/p10k.zsh @@ -0,0 +1,1844 @@ +# Generated by Powerlevel10k configuration wizard on 2025-04-25 at 18:11 CST. +# Based on romkatv/powerlevel10k/config/p10k-rainbow.zsh. +# Wizard options: nerdfont-v3 + powerline, small icons, rainbow, unicode, 24h time, +# slanted separators, sharp heads, flat tails, 2 lines, dotted, no frame, +# lightest-ornaments, sparse, many icons, concise, transient_prompt, +# instant_prompt=verbose. +# Type `p10k configure` to generate another config. +# +# Config for Powerlevel10k with powerline prompt style with colorful background. +# Type `p10k configure` to generate your own config based on it. +# +# Tip: Looking for a nice color? Here's a one-liner to print colormap. +# +# for i in {0..255}; do print -Pn "%K{$i} %k%F{$i}${(l:3::0:)i}%f " ${${(M)$((i%6)):#3}:+$'\n'}; done + +# Temporarily change options. +'builtin' 'local' '-a' 'p10k_config_opts' +[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') +[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') +[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') +'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' + +() { + emulate -L zsh -o extended_glob + + # Unset all configuration options. This allows you to apply configuration changes without + # restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`. + unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR' + + # Zsh >= 5.1 is required. + [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]] || return + + # The list of segments shown on the left. Fill it with the most important segments. + typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( + # =========================[ Line #1 ]========================= + os_icon # os identifier + dir # current directory + vcs # git status + # =========================[ Line #2 ]========================= + newline # \n + prompt_char # prompt symbol + ) + + # The list of segments shown on the right. Fill it with less important segments. + # Right prompt on the last prompt line (where you are typing your commands) gets + # automatically hidden when the input line reaches it. Right prompt above the + # last prompt line gets hidden if it would overlap with left prompt. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=( + # =========================[ Line #1 ]========================= + status # exit code of the last command + command_execution_time # duration of the last command + background_jobs # presence of background jobs + direnv # direnv status (https://direnv.net/) + asdf # asdf version manager (https://github.com/asdf-vm/asdf) + virtualenv # python virtual environment (https://docs.python.org/3/library/venv.html) + anaconda # conda environment (https://conda.io/) + pyenv # python environment (https://github.com/pyenv/pyenv) + goenv # go environment (https://github.com/syndbg/goenv) + nodenv # node.js version from nodenv (https://github.com/nodenv/nodenv) + nvm # node.js version from nvm (https://github.com/nvm-sh/nvm) + nodeenv # node.js environment (https://github.com/ekalinin/nodeenv) + # node_version # node.js version + # go_version # go version (https://golang.org) + # rust_version # rustc version (https://www.rust-lang.org) + # dotnet_version # .NET version (https://dotnet.microsoft.com) + # php_version # php version (https://www.php.net/) + # laravel_version # laravel php framework version (https://laravel.com/) + # java_version # java version (https://www.java.com/) + # package # name@version from package.json (https://docs.npmjs.com/files/package.json) + rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) + rvm # ruby version from rvm (https://rvm.io) + fvm # flutter version management (https://github.com/leoafarias/fvm) + luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv) + jenv # java version from jenv (https://github.com/jenv/jenv) + plenv # perl version from plenv (https://github.com/tokuhirom/plenv) + perlbrew # perl version from perlbrew (https://github.com/gugod/App-perlbrew) + phpenv # php version from phpenv (https://github.com/phpenv/phpenv) + scalaenv # scala version from scalaenv (https://github.com/scalaenv/scalaenv) + haskell_stack # haskell version from stack (https://haskellstack.org/) + kubecontext # current kubernetes context (https://kubernetes.io/) + terraform # terraform workspace (https://www.terraform.io) + # terraform_version # terraform version (https://www.terraform.io) + aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) + aws_eb_env # aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) + azure # azure account name (https://docs.microsoft.com/en-us/cli/azure) + gcloud # google cloud cli account and project (https://cloud.google.com/) + google_app_cred # google application credentials (https://cloud.google.com/docs/authentication/production) + toolbox # toolbox name (https://github.com/containers/toolbox) + context # user@hostname + nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) + ranger # ranger shell (https://github.com/ranger/ranger) + yazi # yazi shell (https://github.com/sxyazi/yazi) + nnn # nnn shell (https://github.com/jarun/nnn) + lf # lf shell (https://github.com/gokcehan/lf) + xplr # xplr shell (https://github.com/sayanarijit/xplr) + vim_shell # vim shell indicator (:sh) + midnight_commander # midnight commander shell (https://midnight-commander.org/) + nix_shell # nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) + chezmoi_shell # chezmoi shell (https://www.chezmoi.io/) + # vi_mode # vi mode (you don't need this if you've enabled prompt_char) + # vpn_ip # virtual private network indicator + # load # CPU load + # disk_usage # disk usage + # ram # free RAM + # swap # used swap + todo # todo items (https://github.com/todotxt/todo.txt-cli) + timewarrior # timewarrior tracking status (https://timewarrior.net/) + taskwarrior # taskwarrior task count (https://taskwarrior.org/) + per_directory_history # Oh My Zsh per-directory-history local/global indicator + # cpu_arch # CPU architecture + time # current time + # =========================[ Line #2 ]========================= + newline + # ip # ip address and bandwidth usage for a specified network interface + # public_ip # public IP address + # proxy # system-wide http/https/ftp proxy + # battery # internal battery + # wifi # wifi speed + # example # example user-defined segment (see prompt_example function below) + ) + + # Defines character set used by powerlevel10k. It's best to let `p10k configure` set it for you. + typeset -g POWERLEVEL9K_MODE=nerdfont-v3 + # When set to `moderate`, some icons will have an extra space after them. This is meant to avoid + # icon overlap when using non-monospace fonts. When set to `none`, spaces are not added. + typeset -g POWERLEVEL9K_ICON_PADDING=none + + # When set to true, icons appear before content on both sides of the prompt. When set + # to false, icons go after content. If empty or not set, icons go before content in the left + # prompt and after content in the right prompt. + # + # You can also override it for a specific segment: + # + # POWERLEVEL9K_STATUS_ICON_BEFORE_CONTENT=false + # + # Or for a specific segment in specific state: + # + # POWERLEVEL9K_DIR_NOT_WRITABLE_ICON_BEFORE_CONTENT=false + typeset -g POWERLEVEL9K_ICON_BEFORE_CONTENT= + + # Add an empty line before each prompt. + typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=true + + # Connect left prompt lines with these symbols. You'll probably want to use the same color + # as POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND below. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX= + typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_PREFIX= + typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX= + # Connect right prompt lines with these symbols. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_SUFFIX= + typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_SUFFIX= + typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_SUFFIX= + + # Filler between left and right prompt on the first prompt line. You can set it to ' ', '·' or + # '─'. The last two make it easier to see the alignment between left and right prompt and to + # separate prompt from command output. You might want to set POWERLEVEL9K_PROMPT_ADD_NEWLINE=false + # for more compact prompt if using this option. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR='·' + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_BACKGROUND= + typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_GAP_BACKGROUND= + if [[ $POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR != ' ' ]]; then + # The color of the filler. You'll probably want to match the color of POWERLEVEL9K_MULTILINE + # ornaments defined above. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND=244 + # Start filler from the edge of the screen if there are no left segments on the first line. + typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_FIRST_SEGMENT_END_SYMBOL='%{%}' + # End filler on the edge of the screen if there are no right segments on the first line. + typeset -g POWERLEVEL9K_EMPTY_LINE_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='%{%}' + fi + + # Separator between same-color segments on the left. + typeset -g POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR='\u2571' + # Separator between same-color segments on the right. + typeset -g POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR='\u2571' + # Separator between different-color segments on the left. + typeset -g POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR='\uE0BC' + # Separator between different-color segments on the right. + typeset -g POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR='\uE0BA' + # To remove a separator between two segments, add "_joined" to the second segment name. + # For example: POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(os_icon context_joined) + + # The right end of left prompt. + typeset -g POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL='\uE0B0' + # The left end of right prompt. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='\uE0B2' + # The left end of left prompt. + typeset -g POWERLEVEL9K_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL='' + # The right end of right prompt. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL='' + # Left prompt terminator for lines without any segments. + typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL= + + #################################[ os_icon: os identifier ]################################## + # OS identifier color. + typeset -g POWERLEVEL9K_OS_ICON_FOREGROUND=232 + typeset -g POWERLEVEL9K_OS_ICON_BACKGROUND=7 + # Custom icon. + # typeset -g POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='⭐' + + ################################[ prompt_char: prompt symbol ]################################ + # Transparent background. + typeset -g POWERLEVEL9K_PROMPT_CHAR_BACKGROUND= + # Green prompt symbol if the last command succeeded. + typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=76 + # Red prompt symbol if the last command failed. + typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=196 + # Default prompt symbol. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION='❯' + # Prompt symbol in command vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='❮' + # Prompt symbol in visual vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='V' + # Prompt symbol in overwrite vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='▶' + typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true + # No line terminator if prompt_char is the last segment. + typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL= + # No line introducer if prompt_char is the first segment. + typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL= + # No surrounding whitespace. + typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_{LEFT,RIGHT}_WHITESPACE= + + ##################################[ dir: current directory ]################################## + # Current directory background color. + typeset -g POWERLEVEL9K_DIR_BACKGROUND=4 + # Default current directory foreground color. + typeset -g POWERLEVEL9K_DIR_FOREGROUND=254 + # If directory is too long, shorten some of its segments to the shortest possible unique + # prefix. The shortened directory can be tab-completed to the original. + typeset -g POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_unique + # Replace removed segment suffixes with this symbol. + typeset -g POWERLEVEL9K_SHORTEN_DELIMITER= + # Color of the shortened directory segments. + typeset -g POWERLEVEL9K_DIR_SHORTENED_FOREGROUND=250 + # Color of the anchor directory segments. Anchor segments are never shortened. The first + # segment is always an anchor. + typeset -g POWERLEVEL9K_DIR_ANCHOR_FOREGROUND=255 + # Display anchor directory segments in bold. + typeset -g POWERLEVEL9K_DIR_ANCHOR_BOLD=true + # Don't shorten directories that contain any of these files. They are anchors. + local anchor_files=( + .bzr + .citc + .git + .hg + .node-version + .python-version + .go-version + .ruby-version + .lua-version + .java-version + .perl-version + .php-version + .tool-versions + .mise.toml + .shorten_folder_marker + .svn + .terraform + CVS + Cargo.toml + composer.json + go.mod + package.json + stack.yaml + ) + typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})" + # If set to "first" ("last"), remove everything before the first (last) subdirectory that contains + # files matching $POWERLEVEL9K_SHORTEN_FOLDER_MARKER. For example, when the current directory is + # /foo/bar/git_repo/nested_git_repo/baz, prompt will display git_repo/nested_git_repo/baz (first) + # or nested_git_repo/baz (last). This assumes that git_repo and nested_git_repo contain markers + # and other directories don't. + # + # Optionally, "first" and "last" can be followed by ":" where is an integer. + # This moves the truncation point to the right (positive offset) or to the left (negative offset) + # relative to the marker. Plain "first" and "last" are equivalent to "first:0" and "last:0" + # respectively. + typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false + # Don't shorten this many last directory segments. They are anchors. + typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 + # Shorten directory if it's longer than this even if there is space for it. The value can + # be either absolute (e.g., '80') or a percentage of terminal width (e.g, '50%'). If empty, + # directory will be shortened only when prompt doesn't fit or when other parameters demand it + # (see POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS and POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT below). + # If set to `0`, directory will always be shortened to its minimum length. + typeset -g POWERLEVEL9K_DIR_MAX_LENGTH=80 + # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least this + # many columns for typing commands. + typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS=40 + # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least + # COLUMNS * POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT * 0.01 columns for typing commands. + typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT=50 + # If set to true, embed a hyperlink into the directory. Useful for quickly + # opening a directory in the file manager simply by clicking the link. + # Can also be handy when the directory is shortened, as it allows you to see + # the full directory that was used in previous commands. + typeset -g POWERLEVEL9K_DIR_HYPERLINK=false + + # Enable special styling for non-writable and non-existent directories. See POWERLEVEL9K_LOCK_ICON + # and POWERLEVEL9K_DIR_CLASSES below. + typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v3 + + # The default icon shown next to non-writable and non-existent directories when + # POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3. + # typeset -g POWERLEVEL9K_LOCK_ICON='⭐' + + # POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different + # directories. It must be an array with 3 * N elements. Each triplet consists of: + # + # 1. A pattern against which the current directory ($PWD) is matched. Matching is done with + # extended_glob option enabled. + # 2. Directory class for the purpose of styling. + # 3. An empty string. + # + # Triplets are tried in order. The first triplet whose pattern matches $PWD wins. + # + # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3, non-writable and non-existent directories + # acquire class suffix _NOT_WRITABLE and NON_EXISTENT respectively. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_DIR_CLASSES=( + # '~/work(|/*)' WORK '' + # '~(|/*)' HOME '' + # '*' DEFAULT '') + # + # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with one + # of the following classes depending on its writability and existence: WORK, WORK_NOT_WRITABLE or + # WORK_NON_EXISTENT. + # + # Simply assigning classes to directories doesn't have any visible effects. It merely gives you an + # option to define custom colors and icons for different directory classes. + # + # # Styling for WORK. + # typeset -g POWERLEVEL9K_DIR_WORK_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_DIR_WORK_BACKGROUND=4 + # typeset -g POWERLEVEL9K_DIR_WORK_FOREGROUND=254 + # typeset -g POWERLEVEL9K_DIR_WORK_SHORTENED_FOREGROUND=250 + # typeset -g POWERLEVEL9K_DIR_WORK_ANCHOR_FOREGROUND=255 + # + # # Styling for WORK_NOT_WRITABLE. + # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_BACKGROUND=4 + # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND=254 + # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=250 + # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=255 + # + # # Styling for WORK_NON_EXISTENT. + # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_BACKGROUND=4 + # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_FOREGROUND=254 + # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_SHORTENED_FOREGROUND=250 + # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_ANCHOR_FOREGROUND=255 + # + # If a styling parameter isn't explicitly defined for some class, it falls back to the classless + # parameter. For example, if POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND is not set, it falls + # back to POWERLEVEL9K_DIR_FOREGROUND. + # + # typeset -g POWERLEVEL9K_DIR_CLASSES=() + + # Custom prefix. + # typeset -g POWERLEVEL9K_DIR_PREFIX='in ' + + #####################################[ vcs: git status ]###################################### + # Version control background colors. + typeset -g POWERLEVEL9K_VCS_CLEAN_BACKGROUND=2 + typeset -g POWERLEVEL9K_VCS_MODIFIED_BACKGROUND=3 + typeset -g POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND=2 + typeset -g POWERLEVEL9K_VCS_CONFLICTED_BACKGROUND=3 + typeset -g POWERLEVEL9K_VCS_LOADING_BACKGROUND=8 + + # Branch icon. Set this parameter to '\UE0A0 ' for the popular Powerline branch icon. + typeset -g POWERLEVEL9K_VCS_BRANCH_ICON='\uF126 ' + + # Untracked files icon. It's really a question mark, your font isn't broken. + # Change the value of this parameter to show a different icon. + typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' + + # Formatter for Git status. + # + # Example output: master wip ⇣42⇡42 *42 merge ~42 +42 !42 ?42. + # + # You can edit the function to customize how Git status looks. + # + # VCS_STATUS_* parameters are set by gitstatus plugin. See reference: + # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. + function my_git_formatter() { + emulate -L zsh + + if [[ -n $P9K_CONTENT ]]; then + # If P9K_CONTENT is not empty, use it. It's either "loading" or from vcs_info (not from + # gitstatus plugin). VCS_STATUS_* parameters are not available in this case. + typeset -g my_git_format=$P9K_CONTENT + return + fi + + # Styling for different parts of Git status. + local meta='%7F' # white foreground + local clean='%0F' # black foreground + local modified='%0F' # black foreground + local untracked='%0F' # black foreground + local conflicted='%1F' # red foreground + + local res + + if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then + local branch=${(V)VCS_STATUS_LOCAL_BRANCH} + # If local branch name is at most 32 characters long, show it in full. + # Otherwise show the first 12 … the last 12. + # Tip: To always show local branch name in full without truncation, delete the next line. + (( $#branch > 32 )) && branch[13,-13]="…" # <-- this line + res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}" + fi + + if [[ -n $VCS_STATUS_TAG + # Show tag only if not on a branch. + # Tip: To always show tag, delete the next line. + && -z $VCS_STATUS_LOCAL_BRANCH # <-- this line + ]]; then + local tag=${(V)VCS_STATUS_TAG} + # If tag name is at most 32 characters long, show it in full. + # Otherwise show the first 12 … the last 12. + # Tip: To always show tag name in full without truncation, delete the next line. + (( $#tag > 32 )) && tag[13,-13]="…" # <-- this line + res+="${meta}#${clean}${tag//\%/%%}" + fi + + # Display the current Git commit if there is no branch and no tag. + # Tip: To always display the current Git commit, delete the next line. + [[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_TAG ]] && # <-- this line + res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}" + + # Show tracking branch name if it differs from local branch. + if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then + res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" + fi + + # Display "wip" if the latest commit's summary contains "wip" or "WIP". + if [[ $VCS_STATUS_COMMIT_SUMMARY == (|*[^[:alnum:]])(wip|WIP)(|[^[:alnum:]]*) ]]; then + res+=" ${modified}wip" + fi + + if (( VCS_STATUS_COMMITS_AHEAD || VCS_STATUS_COMMITS_BEHIND )); then + # ⇣42 if behind the remote. + (( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}" + # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. + (( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=" " + (( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}⇡${VCS_STATUS_COMMITS_AHEAD}" + elif [[ -n $VCS_STATUS_REMOTE_BRANCH ]]; then + # Tip: Uncomment the next line to display '=' if up to date with the remote. + # res+=" ${clean}=" + fi + + # ⇠42 if behind the push remote. + (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}⇠${VCS_STATUS_PUSH_COMMITS_BEHIND}" + (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" " + # ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42. + (( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="${clean}⇢${VCS_STATUS_PUSH_COMMITS_AHEAD}" + # *42 if have stashes. + (( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}" + # 'merge' if the repo is in an unusual state. + [[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}" + # ~42 if have merge conflicts. + (( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}" + # +42 if have staged changes. + (( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}" + # !42 if have unstaged changes. + (( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}" + # ?42 if have untracked files. It's really a question mark, your font isn't broken. + # See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon. + # Remove the next line if you don't want to see untracked files at all. + (( VCS_STATUS_NUM_UNTRACKED )) && res+=" ${untracked}${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}" + # "─" if the number of unstaged files is unknown. This can happen due to + # POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY (see below) being set to a non-negative number lower + # than the number of files in the Git index, or due to bash.showDirtyState being set to false + # in the repository config. The number of staged and untracked files may also be unknown + # in this case. + (( VCS_STATUS_HAS_UNSTAGED == -1 )) && res+=" ${modified}─" + + typeset -g my_git_format=$res + } + functions -M my_git_formatter 2>/dev/null + + # Don't count the number of unstaged, untracked and conflicted files in Git repositories with + # more than this many files in the index. Negative value means infinity. + # + # If you are working in Git repositories with tens of millions of files and seeing performance + # sagging, try setting POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY to a number lower than the output + # of `git ls-files | wc -l`. Alternatively, add `bash.showDirtyState = false` to the repository's + # config: `git config bash.showDirtyState false`. + typeset -g POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY=-1 + + # Don't show Git status in prompt for repositories whose workdir matches this pattern. + # For example, if set to '~', the Git repository at $HOME/.git will be ignored. + # Multiple patterns can be combined with '|': '~(|/foo)|/bar/baz/*'. + typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~' + + # Disable the default Git status formatting. + typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true + # Install our own Git status formatter. + typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${$((my_git_formatter()))+${my_git_format}}' + # Enable counters for staged, unstaged, etc. + typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 + + # Custom icon. + # typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + # typeset -g POWERLEVEL9K_VCS_PREFIX='on ' + + # Show status of repositories of these types. You can add svn and/or hg if you are + # using them. If you do, your prompt may become slow even when your current directory + # isn't in an svn or hg repository. + typeset -g POWERLEVEL9K_VCS_BACKENDS=(git) + + ##########################[ status: exit code of the last command ]########################### + # Enable OK_PIPE, ERROR_PIPE and ERROR_SIGNAL status states to allow us to enable, disable and + # style them independently from the regular OK and ERROR state. + typeset -g POWERLEVEL9K_STATUS_EXTENDED_STATES=true + + # Status on success. No content, just an icon. No need to show it if prompt_char is enabled as + # it will signify success by turning green. + typeset -g POWERLEVEL9K_STATUS_OK=false + typeset -g POWERLEVEL9K_STATUS_OK_VISUAL_IDENTIFIER_EXPANSION='✔' + typeset -g POWERLEVEL9K_STATUS_OK_FOREGROUND=2 + typeset -g POWERLEVEL9K_STATUS_OK_BACKGROUND=0 + + # Status when some part of a pipe command fails but the overall exit status is zero. It may look + # like this: 1|0. + typeset -g POWERLEVEL9K_STATUS_OK_PIPE=true + typeset -g POWERLEVEL9K_STATUS_OK_PIPE_VISUAL_IDENTIFIER_EXPANSION='✔' + typeset -g POWERLEVEL9K_STATUS_OK_PIPE_FOREGROUND=2 + typeset -g POWERLEVEL9K_STATUS_OK_PIPE_BACKGROUND=0 + + # Status when it's just an error code (e.g., '1'). No need to show it if prompt_char is enabled as + # it will signify error by turning red. + typeset -g POWERLEVEL9K_STATUS_ERROR=false + typeset -g POWERLEVEL9K_STATUS_ERROR_VISUAL_IDENTIFIER_EXPANSION='✘' + typeset -g POWERLEVEL9K_STATUS_ERROR_FOREGROUND=3 + typeset -g POWERLEVEL9K_STATUS_ERROR_BACKGROUND=1 + + # Status when the last command was terminated by a signal. + typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL=true + # Use terse signal names: "INT" instead of "SIGINT(2)". + typeset -g POWERLEVEL9K_STATUS_VERBOSE_SIGNAME=false + typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_VISUAL_IDENTIFIER_EXPANSION='✘' + typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_FOREGROUND=3 + typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_BACKGROUND=1 + + # Status when some part of a pipe command fails and the overall exit status is also non-zero. + # It may look like this: 1|0. + typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE=true + typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_VISUAL_IDENTIFIER_EXPANSION='✘' + typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_FOREGROUND=3 + typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_BACKGROUND=1 + + ###################[ command_execution_time: duration of the last command ]################### + # Execution time color. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=0 + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_BACKGROUND=3 + # Show duration of the last command if takes at least this many seconds. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=3 + # Show this many fractional digits. Zero means round to seconds. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0 + # Duration format: 1d 2h 3m 4s. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s' + # Custom icon. + # typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + # typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PREFIX='took ' + + #######################[ background_jobs: presence of background jobs ]####################### + # Background jobs color. + typeset -g POWERLEVEL9K_BACKGROUND_JOBS_FOREGROUND=6 + typeset -g POWERLEVEL9K_BACKGROUND_JOBS_BACKGROUND=0 + # Don't show the number of background jobs. + typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=false + # Custom icon. + # typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######################[ direnv: direnv status (https://direnv.net/) ]######################## + # Direnv color. + typeset -g POWERLEVEL9K_DIRENV_FOREGROUND=3 + typeset -g POWERLEVEL9K_DIRENV_BACKGROUND=0 + # Custom icon. + # typeset -g POWERLEVEL9K_DIRENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###############[ asdf: asdf version manager (https://github.com/asdf-vm/asdf) ]############### + # Default asdf color. Only used to display tools for which there is no color override (see below). + # Tip: Override these parameters for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_FOREGROUND and + # POWERLEVEL9K_ASDF_${TOOL}_BACKGROUND. + typeset -g POWERLEVEL9K_ASDF_FOREGROUND=0 + typeset -g POWERLEVEL9K_ASDF_BACKGROUND=7 + + # There are four parameters that can be used to hide asdf tools. Each parameter describes + # conditions under which a tool gets hidden. Parameters can hide tools but not unhide them. If at + # least one parameter decides to hide a tool, that tool gets hidden. If no parameter decides to + # hide a tool, it gets shown. + # + # Special note on the difference between POWERLEVEL9K_ASDF_SOURCES and + # POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW. Consider the effect of the following commands: + # + # asdf local python 3.8.1 + # asdf global python 3.8.1 + # + # After running both commands the current python version is 3.8.1 and its source is "local" as + # it takes precedence over "global". If POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW is set to false, + # it'll hide python version in this case because 3.8.1 is the same as the global version. + # POWERLEVEL9K_ASDF_SOURCES will hide python version only if the value of this parameter doesn't + # contain "local". + + # Hide tool versions that don't come from one of these sources. + # + # Available sources: + # + # - shell `asdf current` says "set by ASDF_${TOOL}_VERSION environment variable" + # - local `asdf current` says "set by /some/not/home/directory/file" + # - global `asdf current` says "set by /home/username/file" + # + # Note: If this parameter is set to (shell local global), it won't hide tools. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SOURCES. + typeset -g POWERLEVEL9K_ASDF_SOURCES=(shell local global) + + # If set to false, hide tool versions that are the same as global. + # + # Note: The name of this parameter doesn't reflect its meaning at all. + # Note: If this parameter is set to true, it won't hide tools. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_PROMPT_ALWAYS_SHOW. + typeset -g POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW=false + + # If set to false, hide tool versions that are equal to "system". + # + # Note: If this parameter is set to true, it won't hide tools. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_SYSTEM. + typeset -g POWERLEVEL9K_ASDF_SHOW_SYSTEM=true + + # If set to non-empty value, hide tools unless there is a file matching the specified file pattern + # in the current directory, or its parent directory, or its grandparent directory, and so on. + # + # Note: If this parameter is set to empty value, it won't hide tools. + # Note: SHOW_ON_UPGLOB isn't specific to asdf. It works with all prompt segments. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_ON_UPGLOB. + # + # Example: Hide nodejs version when there is no package.json and no *.js files in the current + # directory, in `..`, in `../..` and so on. + # + # typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='*.js|package.json' + typeset -g POWERLEVEL9K_ASDF_SHOW_ON_UPGLOB= + + # Ruby version from asdf. + typeset -g POWERLEVEL9K_ASDF_RUBY_FOREGROUND=0 + typeset -g POWERLEVEL9K_ASDF_RUBY_BACKGROUND=1 + # typeset -g POWERLEVEL9K_ASDF_RUBY_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_RUBY_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Python version from asdf. + typeset -g POWERLEVEL9K_ASDF_PYTHON_FOREGROUND=0 + typeset -g POWERLEVEL9K_ASDF_PYTHON_BACKGROUND=4 + # typeset -g POWERLEVEL9K_ASDF_PYTHON_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_PYTHON_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Go version from asdf. + typeset -g POWERLEVEL9K_ASDF_GOLANG_FOREGROUND=0 + typeset -g POWERLEVEL9K_ASDF_GOLANG_BACKGROUND=4 + # typeset -g POWERLEVEL9K_ASDF_GOLANG_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_GOLANG_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Node.js version from asdf. + typeset -g POWERLEVEL9K_ASDF_NODEJS_FOREGROUND=0 + typeset -g POWERLEVEL9K_ASDF_NODEJS_BACKGROUND=2 + # typeset -g POWERLEVEL9K_ASDF_NODEJS_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Rust version from asdf. + typeset -g POWERLEVEL9K_ASDF_RUST_FOREGROUND=0 + typeset -g POWERLEVEL9K_ASDF_RUST_BACKGROUND=208 + # typeset -g POWERLEVEL9K_ASDF_RUST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_RUST_SHOW_ON_UPGLOB='*.foo|*.bar' + + # .NET Core version from asdf. + typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_FOREGROUND=0 + typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_BACKGROUND=5 + # typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Flutter version from asdf. + typeset -g POWERLEVEL9K_ASDF_FLUTTER_FOREGROUND=0 + typeset -g POWERLEVEL9K_ASDF_FLUTTER_BACKGROUND=4 + # typeset -g POWERLEVEL9K_ASDF_FLUTTER_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_FLUTTER_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Lua version from asdf. + typeset -g POWERLEVEL9K_ASDF_LUA_FOREGROUND=0 + typeset -g POWERLEVEL9K_ASDF_LUA_BACKGROUND=4 + # typeset -g POWERLEVEL9K_ASDF_LUA_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_LUA_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Java version from asdf. + typeset -g POWERLEVEL9K_ASDF_JAVA_FOREGROUND=1 + typeset -g POWERLEVEL9K_ASDF_JAVA_BACKGROUND=7 + # typeset -g POWERLEVEL9K_ASDF_JAVA_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_JAVA_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Perl version from asdf. + typeset -g POWERLEVEL9K_ASDF_PERL_FOREGROUND=0 + typeset -g POWERLEVEL9K_ASDF_PERL_BACKGROUND=4 + # typeset -g POWERLEVEL9K_ASDF_PERL_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_PERL_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Erlang version from asdf. + typeset -g POWERLEVEL9K_ASDF_ERLANG_FOREGROUND=0 + typeset -g POWERLEVEL9K_ASDF_ERLANG_BACKGROUND=1 + # typeset -g POWERLEVEL9K_ASDF_ERLANG_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_ERLANG_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Elixir version from asdf. + typeset -g POWERLEVEL9K_ASDF_ELIXIR_FOREGROUND=0 + typeset -g POWERLEVEL9K_ASDF_ELIXIR_BACKGROUND=5 + # typeset -g POWERLEVEL9K_ASDF_ELIXIR_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_ELIXIR_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Postgres version from asdf. + typeset -g POWERLEVEL9K_ASDF_POSTGRES_FOREGROUND=0 + typeset -g POWERLEVEL9K_ASDF_POSTGRES_BACKGROUND=6 + # typeset -g POWERLEVEL9K_ASDF_POSTGRES_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_POSTGRES_SHOW_ON_UPGLOB='*.foo|*.bar' + + # PHP version from asdf. + typeset -g POWERLEVEL9K_ASDF_PHP_FOREGROUND=0 + typeset -g POWERLEVEL9K_ASDF_PHP_BACKGROUND=5 + # typeset -g POWERLEVEL9K_ASDF_PHP_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_PHP_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Haskell version from asdf. + typeset -g POWERLEVEL9K_ASDF_HASKELL_FOREGROUND=0 + typeset -g POWERLEVEL9K_ASDF_HASKELL_BACKGROUND=3 + # typeset -g POWERLEVEL9K_ASDF_HASKELL_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_HASKELL_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Julia version from asdf. + typeset -g POWERLEVEL9K_ASDF_JULIA_FOREGROUND=0 + typeset -g POWERLEVEL9K_ASDF_JULIA_BACKGROUND=2 + # typeset -g POWERLEVEL9K_ASDF_JULIA_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_JULIA_SHOW_ON_UPGLOB='*.foo|*.bar' + + ##########[ nordvpn: nordvpn connection status, linux only (https://nordvpn.com/) ]########### + # NordVPN connection indicator color. + typeset -g POWERLEVEL9K_NORDVPN_FOREGROUND=7 + typeset -g POWERLEVEL9K_NORDVPN_BACKGROUND=4 + # Hide NordVPN connection indicator when not connected. + typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_CONTENT_EXPANSION= + typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_VISUAL_IDENTIFIER_EXPANSION= + # Custom icon. + # typeset -g POWERLEVEL9K_NORDVPN_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #################[ ranger: ranger shell (https://github.com/ranger/ranger) ]################## + # Ranger shell color. + typeset -g POWERLEVEL9K_RANGER_FOREGROUND=3 + typeset -g POWERLEVEL9K_RANGER_BACKGROUND=0 + # Custom icon. + # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ####################[ yazi: yazi shell (https://github.com/sxyazi/yazi) ]##################### + # Yazi shell color. + typeset -g POWERLEVEL9K_YAZI_FOREGROUND=3 + typeset -g POWERLEVEL9K_YAZI_BACKGROUND=0 + # Custom icon. + # typeset -g POWERLEVEL9K_YAZI_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################[ nnn: nnn shell (https://github.com/jarun/nnn) ]####################### + # Nnn shell color. + typeset -g POWERLEVEL9K_NNN_FOREGROUND=0 + typeset -g POWERLEVEL9K_NNN_BACKGROUND=6 + # Custom icon. + # typeset -g POWERLEVEL9K_NNN_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################[ lf: lf shell (https://github.com/gokcehan/lf) ]####################### + # lf shell color. + typeset -g POWERLEVEL9K_LF_FOREGROUND=0 + typeset -g POWERLEVEL9K_LF_BACKGROUND=6 + # Custom icon. + # typeset -g POWERLEVEL9K_LF_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##################[ xplr: xplr shell (https://github.com/sayanarijit/xplr) ]################## + # xplr shell color. + typeset -g POWERLEVEL9K_XPLR_FOREGROUND=0 + typeset -g POWERLEVEL9K_XPLR_BACKGROUND=6 + # Custom icon. + # typeset -g POWERLEVEL9K_XPLR_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########################[ vim_shell: vim shell indicator (:sh) ]########################### + # Vim shell indicator color. + typeset -g POWERLEVEL9K_VIM_SHELL_FOREGROUND=0 + typeset -g POWERLEVEL9K_VIM_SHELL_BACKGROUND=2 + # Custom icon. + # typeset -g POWERLEVEL9K_VIM_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######[ midnight_commander: midnight commander shell (https://midnight-commander.org/) ]###### + # Midnight Commander shell color. + typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_FOREGROUND=3 + typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_BACKGROUND=0 + # Custom icon. + # typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #[ nix_shell: nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) ]## + # Nix shell color. + typeset -g POWERLEVEL9K_NIX_SHELL_FOREGROUND=0 + typeset -g POWERLEVEL9K_NIX_SHELL_BACKGROUND=4 + + # Display the icon of nix_shell if PATH contains a subdirectory of /nix/store. + # typeset -g POWERLEVEL9K_NIX_SHELL_INFER_FROM_PATH=false + + # Tip: If you want to see just the icon without "pure" and "impure", uncomment the next line. + # typeset -g POWERLEVEL9K_NIX_SHELL_CONTENT_EXPANSION= + + # Custom icon. + # typeset -g POWERLEVEL9K_NIX_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##################[ chezmoi_shell: chezmoi shell (https://www.chezmoi.io/) ]################## + # chezmoi shell color. + typeset -g POWERLEVEL9K_CHEZMOI_SHELL_FOREGROUND=0 + typeset -g POWERLEVEL9K_CHEZMOI_SHELL_BACKGROUND=4 + # Custom icon. + # typeset -g POWERLEVEL9K_CHEZMOI_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##################################[ disk_usage: disk usage ]################################## + # Colors for different levels of disk usage. + typeset -g POWERLEVEL9K_DISK_USAGE_NORMAL_FOREGROUND=3 + typeset -g POWERLEVEL9K_DISK_USAGE_NORMAL_BACKGROUND=0 + typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_FOREGROUND=0 + typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_BACKGROUND=3 + typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_FOREGROUND=7 + typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_BACKGROUND=1 + # Thresholds for different levels of disk usage (percentage points). + typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL=90 + typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL=95 + # If set to true, hide disk usage when below $POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL percent. + typeset -g POWERLEVEL9K_DISK_USAGE_ONLY_WARNING=false + # Custom icon. + # typeset -g POWERLEVEL9K_DISK_USAGE_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ vi_mode: vi mode (you don't need this if you've enabled prompt_char) ]########### + # Foreground color. + typeset -g POWERLEVEL9K_VI_MODE_FOREGROUND=0 + # Text and color for normal (a.k.a. command) vi mode. + typeset -g POWERLEVEL9K_VI_COMMAND_MODE_STRING=NORMAL + typeset -g POWERLEVEL9K_VI_MODE_NORMAL_BACKGROUND=2 + # Text and color for visual vi mode. + typeset -g POWERLEVEL9K_VI_VISUAL_MODE_STRING=VISUAL + typeset -g POWERLEVEL9K_VI_MODE_VISUAL_BACKGROUND=4 + # Text and color for overtype (a.k.a. overwrite and replace) vi mode. + typeset -g POWERLEVEL9K_VI_OVERWRITE_MODE_STRING=OVERTYPE + typeset -g POWERLEVEL9K_VI_MODE_OVERWRITE_BACKGROUND=3 + # Text and color for insert vi mode. + typeset -g POWERLEVEL9K_VI_INSERT_MODE_STRING= + typeset -g POWERLEVEL9K_VI_MODE_INSERT_FOREGROUND=8 + # Custom icon. + # typeset -g POWERLEVEL9K_VI_MODE_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################################[ ram: free RAM ]####################################### + # RAM color. + typeset -g POWERLEVEL9K_RAM_FOREGROUND=0 + typeset -g POWERLEVEL9K_RAM_BACKGROUND=3 + # Custom icon. + # typeset -g POWERLEVEL9K_RAM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #####################################[ swap: used swap ]###################################### + # Swap color. + typeset -g POWERLEVEL9K_SWAP_FOREGROUND=0 + typeset -g POWERLEVEL9K_SWAP_BACKGROUND=3 + # Custom icon. + # typeset -g POWERLEVEL9K_SWAP_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################################[ load: CPU load ]###################################### + # Show average CPU load over this many last minutes. Valid values are 1, 5 and 15. + typeset -g POWERLEVEL9K_LOAD_WHICH=5 + # Load color when load is under 50%. + typeset -g POWERLEVEL9K_LOAD_NORMAL_FOREGROUND=0 + typeset -g POWERLEVEL9K_LOAD_NORMAL_BACKGROUND=2 + # Load color when load is between 50% and 70%. + typeset -g POWERLEVEL9K_LOAD_WARNING_FOREGROUND=0 + typeset -g POWERLEVEL9K_LOAD_WARNING_BACKGROUND=3 + # Load color when load is over 70%. + typeset -g POWERLEVEL9K_LOAD_CRITICAL_FOREGROUND=0 + typeset -g POWERLEVEL9K_LOAD_CRITICAL_BACKGROUND=1 + # Custom icon. + # typeset -g POWERLEVEL9K_LOAD_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################[ todo: todo items (https://github.com/todotxt/todo.txt-cli) ]################ + # Todo color. + typeset -g POWERLEVEL9K_TODO_FOREGROUND=0 + typeset -g POWERLEVEL9K_TODO_BACKGROUND=8 + # Hide todo when the total number of tasks is zero. + typeset -g POWERLEVEL9K_TODO_HIDE_ZERO_TOTAL=true + # Hide todo when the number of tasks after filtering is zero. + typeset -g POWERLEVEL9K_TODO_HIDE_ZERO_FILTERED=false + + # Todo format. The following parameters are available within the expansion. + # + # - P9K_TODO_TOTAL_TASK_COUNT The total number of tasks. + # - P9K_TODO_FILTERED_TASK_COUNT The number of tasks after filtering. + # + # These variables correspond to the last line of the output of `todo.sh -p ls`: + # + # TODO: 24 of 42 tasks shown + # + # Here 24 is P9K_TODO_FILTERED_TASK_COUNT and 42 is P9K_TODO_TOTAL_TASK_COUNT. + # + # typeset -g POWERLEVEL9K_TODO_CONTENT_EXPANSION='$P9K_TODO_FILTERED_TASK_COUNT' + + # Custom icon. + # typeset -g POWERLEVEL9K_TODO_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ timewarrior: timewarrior tracking status (https://timewarrior.net/) ]############ + # Timewarrior color. + typeset -g POWERLEVEL9K_TIMEWARRIOR_FOREGROUND=255 + typeset -g POWERLEVEL9K_TIMEWARRIOR_BACKGROUND=8 + + # If the tracked task is longer than 24 characters, truncate and append "…". + # Tip: To always display tasks without truncation, delete the following parameter. + # Tip: To hide task names and display just the icon when time tracking is enabled, set the + # value of the following parameter to "". + typeset -g POWERLEVEL9K_TIMEWARRIOR_CONTENT_EXPANSION='${P9K_CONTENT:0:24}${${P9K_CONTENT:24}:+…}' + + # Custom icon. + # typeset -g POWERLEVEL9K_TIMEWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##############[ taskwarrior: taskwarrior task count (https://taskwarrior.org/) ]############## + # Taskwarrior color. + typeset -g POWERLEVEL9K_TASKWARRIOR_FOREGROUND=0 + typeset -g POWERLEVEL9K_TASKWARRIOR_BACKGROUND=6 + + # Taskwarrior segment format. The following parameters are available within the expansion. + # + # - P9K_TASKWARRIOR_PENDING_COUNT The number of pending tasks: `task +PENDING count`. + # - P9K_TASKWARRIOR_OVERDUE_COUNT The number of overdue tasks: `task +OVERDUE count`. + # + # Zero values are represented as empty parameters. + # + # The default format: + # + # '${P9K_TASKWARRIOR_OVERDUE_COUNT:+"!$P9K_TASKWARRIOR_OVERDUE_COUNT/"}$P9K_TASKWARRIOR_PENDING_COUNT' + # + # typeset -g POWERLEVEL9K_TASKWARRIOR_CONTENT_EXPANSION='$P9K_TASKWARRIOR_PENDING_COUNT' + + # Custom icon. + # typeset -g POWERLEVEL9K_TASKWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######[ per_directory_history: Oh My Zsh per-directory-history local/global indicator ]####### + # Color when using local/global history. + typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_FOREGROUND=0 + typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_BACKGROUND=5 + typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_FOREGROUND=0 + typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_BACKGROUND=3 + + # Tip: Uncomment the next two lines to hide "local"/"global" text and leave just the icon. + # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_CONTENT_EXPANSION='' + # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_CONTENT_EXPANSION='' + + # Custom icon. + # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################################[ cpu_arch: CPU architecture ]################################ + # CPU architecture color. + typeset -g POWERLEVEL9K_CPU_ARCH_FOREGROUND=0 + typeset -g POWERLEVEL9K_CPU_ARCH_BACKGROUND=3 + + # Hide the segment when on a specific CPU architecture. + # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_CONTENT_EXPANSION= + # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_VISUAL_IDENTIFIER_EXPANSION= + + # Custom icon. + # typeset -g POWERLEVEL9K_CPU_ARCH_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##################################[ context: user@hostname ]################################## + # Context color when running with privileges. + typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=1 + typeset -g POWERLEVEL9K_CONTEXT_ROOT_BACKGROUND=0 + # Context color in SSH without privileges. + typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_FOREGROUND=3 + typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_BACKGROUND=0 + # Default context color (no privileges, no SSH). + typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=3 + typeset -g POWERLEVEL9K_CONTEXT_BACKGROUND=0 + + # Context format when running with privileges: user@hostname. + typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%n@%m' + # Context format when in SSH without privileges: user@hostname. + typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_TEMPLATE='%n@%m' + # Default context format (no privileges, no SSH): user@hostname. + typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='%n@%m' + + # Don't show context unless running with privileges or in SSH. + # Tip: Remove the next line to always show context. + typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION= + + # Custom icon. + # typeset -g POWERLEVEL9K_CONTEXT_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + # typeset -g POWERLEVEL9K_CONTEXT_PREFIX='with ' + + ###[ virtualenv: python virtual environment (https://docs.python.org/3/library/venv.html) ]### + # Python virtual environment color. + typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=0 + typeset -g POWERLEVEL9K_VIRTUALENV_BACKGROUND=4 + # Don't show Python version next to the virtual environment name. + typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false + # If set to "false", won't show virtualenv if pyenv is already shown. + # If set to "if-different", won't show virtualenv if it's the same as pyenv. + typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV=false + # Separate environment name from Python version only with a space. + typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER= + # Custom icon. + # typeset -g POWERLEVEL9K_VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #####################[ anaconda: conda environment (https://conda.io/) ]###################### + # Anaconda environment color. + typeset -g POWERLEVEL9K_ANACONDA_FOREGROUND=0 + typeset -g POWERLEVEL9K_ANACONDA_BACKGROUND=4 + + # Anaconda segment format. The following parameters are available within the expansion. + # + # - CONDA_PREFIX Absolute path to the active Anaconda/Miniconda environment. + # - CONDA_DEFAULT_ENV Name of the active Anaconda/Miniconda environment. + # - CONDA_PROMPT_MODIFIER Configurable prompt modifier (see below). + # - P9K_ANACONDA_PYTHON_VERSION Current python version (python --version). + # + # CONDA_PROMPT_MODIFIER can be configured with the following command: + # + # conda config --set env_prompt '({default_env}) ' + # + # The last argument is a Python format string that can use the following variables: + # + # - prefix The same as CONDA_PREFIX. + # - default_env The same as CONDA_DEFAULT_ENV. + # - name The last segment of CONDA_PREFIX. + # - stacked_env Comma-separated list of names in the environment stack. The first element is + # always the same as default_env. + # + # Note: '({default_env}) ' is the default value of env_prompt. + # + # The default value of POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION expands to $CONDA_PROMPT_MODIFIER + # without the surrounding parentheses, or to the last path component of CONDA_PREFIX if the former + # is empty. + typeset -g POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION='${${${${CONDA_PROMPT_MODIFIER#\(}% }%\)}:-${CONDA_PREFIX:t}}' + + # Custom icon. + # typeset -g POWERLEVEL9K_ANACONDA_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################[ pyenv: python environment (https://github.com/pyenv/pyenv) ]################ + # Pyenv color. + typeset -g POWERLEVEL9K_PYENV_FOREGROUND=0 + typeset -g POWERLEVEL9K_PYENV_BACKGROUND=4 + # Hide python version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_PYENV_SOURCES=(shell local global) + # If set to false, hide python version if it's the same as global: + # $(pyenv version-name) == $(pyenv global). + typeset -g POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide python version if it's equal to "system". + typeset -g POWERLEVEL9K_PYENV_SHOW_SYSTEM=true + + # Pyenv segment format. The following parameters are available within the expansion. + # + # - P9K_CONTENT Current pyenv environment (pyenv version-name). + # - P9K_PYENV_PYTHON_VERSION Current python version (python --version). + # + # The default format has the following logic: + # + # 1. Display just "$P9K_CONTENT" if it's equal to "$P9K_PYENV_PYTHON_VERSION" or + # starts with "$P9K_PYENV_PYTHON_VERSION/". + # 2. Otherwise display "$P9K_CONTENT $P9K_PYENV_PYTHON_VERSION". + typeset -g POWERLEVEL9K_PYENV_CONTENT_EXPANSION='${P9K_CONTENT}${${P9K_CONTENT:#$P9K_PYENV_PYTHON_VERSION(|/*)}:+ $P9K_PYENV_PYTHON_VERSION}' + + # Custom icon. + # typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################[ goenv: go environment (https://github.com/syndbg/goenv) ]################ + # Goenv color. + typeset -g POWERLEVEL9K_GOENV_FOREGROUND=0 + typeset -g POWERLEVEL9K_GOENV_BACKGROUND=4 + # Hide go version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_GOENV_SOURCES=(shell local global) + # If set to false, hide go version if it's the same as global: + # $(goenv version-name) == $(goenv global). + typeset -g POWERLEVEL9K_GOENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide go version if it's equal to "system". + typeset -g POWERLEVEL9K_GOENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_GOENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ nodenv: node.js version from nodenv (https://github.com/nodenv/nodenv) ]########## + # Nodenv color. + typeset -g POWERLEVEL9K_NODENV_FOREGROUND=2 + typeset -g POWERLEVEL9K_NODENV_BACKGROUND=0 + # Hide node version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_NODENV_SOURCES=(shell local global) + # If set to false, hide node version if it's the same as global: + # $(nodenv version-name) == $(nodenv global). + typeset -g POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide node version if it's equal to "system". + typeset -g POWERLEVEL9K_NODENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_NODENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##############[ nvm: node.js version from nvm (https://github.com/nvm-sh/nvm) ]############### + # Nvm color. + typeset -g POWERLEVEL9K_NVM_FOREGROUND=0 + typeset -g POWERLEVEL9K_NVM_BACKGROUND=5 + # If set to false, hide node version if it's the same as default: + # $(nvm version current) == $(nvm version default). + typeset -g POWERLEVEL9K_NVM_PROMPT_ALWAYS_SHOW=false + # If set to false, hide node version if it's equal to "system". + typeset -g POWERLEVEL9K_NVM_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_NVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ############[ nodeenv: node.js environment (https://github.com/ekalinin/nodeenv) ]############ + # Nodeenv color. + typeset -g POWERLEVEL9K_NODEENV_FOREGROUND=2 + typeset -g POWERLEVEL9K_NODEENV_BACKGROUND=0 + # Don't show Node version next to the environment name. + typeset -g POWERLEVEL9K_NODEENV_SHOW_NODE_VERSION=false + # Separate environment name from Node version only with a space. + typeset -g POWERLEVEL9K_NODEENV_{LEFT,RIGHT}_DELIMITER= + # Custom icon. + # typeset -g POWERLEVEL9K_NODEENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##############################[ node_version: node.js version ]############################### + # Node version color. + typeset -g POWERLEVEL9K_NODE_VERSION_FOREGROUND=7 + typeset -g POWERLEVEL9K_NODE_VERSION_BACKGROUND=2 + # Show node version only when in a directory tree containing package.json. + typeset -g POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_NODE_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######################[ go_version: go version (https://golang.org) ]######################## + # Go version color. + typeset -g POWERLEVEL9K_GO_VERSION_FOREGROUND=255 + typeset -g POWERLEVEL9K_GO_VERSION_BACKGROUND=2 + # Show go version only when in a go project subdirectory. + typeset -g POWERLEVEL9K_GO_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_GO_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #################[ rust_version: rustc version (https://www.rust-lang.org) ]################## + # Rust version color. + typeset -g POWERLEVEL9K_RUST_VERSION_FOREGROUND=0 + typeset -g POWERLEVEL9K_RUST_VERSION_BACKGROUND=208 + # Show rust version only when in a rust project subdirectory. + typeset -g POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###############[ dotnet_version: .NET version (https://dotnet.microsoft.com) ]################ + # .NET version color. + typeset -g POWERLEVEL9K_DOTNET_VERSION_FOREGROUND=7 + typeset -g POWERLEVEL9K_DOTNET_VERSION_BACKGROUND=5 + # Show .NET version only when in a .NET project subdirectory. + typeset -g POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_DOTNET_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #####################[ php_version: php version (https://www.php.net/) ]###################### + # PHP version color. + typeset -g POWERLEVEL9K_PHP_VERSION_FOREGROUND=0 + typeset -g POWERLEVEL9K_PHP_VERSION_BACKGROUND=5 + # Show PHP version only when in a PHP project subdirectory. + typeset -g POWERLEVEL9K_PHP_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_PHP_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ laravel_version: laravel php framework version (https://laravel.com/) ]########### + # Laravel version color. + typeset -g POWERLEVEL9K_LARAVEL_VERSION_FOREGROUND=1 + typeset -g POWERLEVEL9K_LARAVEL_VERSION_BACKGROUND=7 + # Custom icon. + # typeset -g POWERLEVEL9K_LARAVEL_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## + # Rbenv color. + typeset -g POWERLEVEL9K_RBENV_FOREGROUND=0 + typeset -g POWERLEVEL9K_RBENV_BACKGROUND=1 + # Hide ruby version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_RBENV_SOURCES=(shell local global) + # If set to false, hide ruby version if it's the same as global: + # $(rbenv version-name) == $(rbenv global). + typeset -g POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide ruby version if it's equal to "system". + typeset -g POWERLEVEL9K_RBENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_RBENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ####################[ java_version: java version (https://www.java.com/) ]#################### + # Java version color. + typeset -g POWERLEVEL9K_JAVA_VERSION_FOREGROUND=1 + typeset -g POWERLEVEL9K_JAVA_VERSION_BACKGROUND=7 + # Show java version only when in a java project subdirectory. + typeset -g POWERLEVEL9K_JAVA_VERSION_PROJECT_ONLY=true + # Show brief version. + typeset -g POWERLEVEL9K_JAVA_VERSION_FULL=false + # Custom icon. + # typeset -g POWERLEVEL9K_JAVA_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###[ package: name@version from package.json (https://docs.npmjs.com/files/package.json) ]#### + # Package color. + typeset -g POWERLEVEL9K_PACKAGE_FOREGROUND=0 + typeset -g POWERLEVEL9K_PACKAGE_BACKGROUND=6 + + # Package format. The following parameters are available within the expansion. + # + # - P9K_PACKAGE_NAME The value of `name` field in package.json. + # - P9K_PACKAGE_VERSION The value of `version` field in package.json. + # + # typeset -g POWERLEVEL9K_PACKAGE_CONTENT_EXPANSION='${P9K_PACKAGE_NAME//\%/%%}@${P9K_PACKAGE_VERSION//\%/%%}' + + # Custom icon. + # typeset -g POWERLEVEL9K_PACKAGE_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######################[ rvm: ruby version from rvm (https://rvm.io) ]######################## + # Rvm color. + typeset -g POWERLEVEL9K_RVM_FOREGROUND=0 + typeset -g POWERLEVEL9K_RVM_BACKGROUND=240 + # Don't show @gemset at the end. + typeset -g POWERLEVEL9K_RVM_SHOW_GEMSET=false + # Don't show ruby- at the front. + typeset -g POWERLEVEL9K_RVM_SHOW_PREFIX=false + # Custom icon. + # typeset -g POWERLEVEL9K_RVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ fvm: flutter version management (https://github.com/leoafarias/fvm) ]############ + # Fvm color. + typeset -g POWERLEVEL9K_FVM_FOREGROUND=0 + typeset -g POWERLEVEL9K_FVM_BACKGROUND=4 + # Custom icon. + # typeset -g POWERLEVEL9K_FVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ luaenv: lua version from luaenv (https://github.com/cehoffman/luaenv) ]########### + # Lua color. + typeset -g POWERLEVEL9K_LUAENV_FOREGROUND=0 + typeset -g POWERLEVEL9K_LUAENV_BACKGROUND=4 + # Hide lua version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_LUAENV_SOURCES=(shell local global) + # If set to false, hide lua version if it's the same as global: + # $(luaenv version-name) == $(luaenv global). + typeset -g POWERLEVEL9K_LUAENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide lua version if it's equal to "system". + typeset -g POWERLEVEL9K_LUAENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_LUAENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###############[ jenv: java version from jenv (https://github.com/jenv/jenv) ]################ + # Java color. + typeset -g POWERLEVEL9K_JENV_FOREGROUND=1 + typeset -g POWERLEVEL9K_JENV_BACKGROUND=7 + # Hide java version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_JENV_SOURCES=(shell local global) + # If set to false, hide java version if it's the same as global: + # $(jenv version-name) == $(jenv global). + typeset -g POWERLEVEL9K_JENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide java version if it's equal to "system". + typeset -g POWERLEVEL9K_JENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_JENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ plenv: perl version from plenv (https://github.com/tokuhirom/plenv) ]############ + # Perl color. + typeset -g POWERLEVEL9K_PLENV_FOREGROUND=0 + typeset -g POWERLEVEL9K_PLENV_BACKGROUND=4 + # Hide perl version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_PLENV_SOURCES=(shell local global) + # If set to false, hide perl version if it's the same as global: + # $(plenv version-name) == $(plenv global). + typeset -g POWERLEVEL9K_PLENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide perl version if it's equal to "system". + typeset -g POWERLEVEL9K_PLENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ perlbrew: perl version from perlbrew (https://github.com/gugod/App-perlbrew) ]############ + # Perlbrew color. + typeset -g POWERLEVEL9K_PERLBREW_FOREGROUND=67 + # Show perlbrew version only when in a perl project subdirectory. + typeset -g POWERLEVEL9K_PERLBREW_PROJECT_ONLY=true + # Don't show "perl-" at the front. + typeset -g POWERLEVEL9K_PERLBREW_SHOW_PREFIX=false + # Custom icon. + # typeset -g POWERLEVEL9K_PERLBREW_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ############[ phpenv: php version from phpenv (https://github.com/phpenv/phpenv) ]############ + # PHP color. + typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=0 + typeset -g POWERLEVEL9K_PHPENV_BACKGROUND=5 + # Hide php version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_PHPENV_SOURCES=(shell local global) + # If set to false, hide php version if it's the same as global: + # $(phpenv version-name) == $(phpenv global). + typeset -g POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide PHP version if it's equal to "system". + typeset -g POWERLEVEL9K_PHPENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######[ scalaenv: scala version from scalaenv (https://github.com/scalaenv/scalaenv) ]####### + # Scala color. + typeset -g POWERLEVEL9K_SCALAENV_FOREGROUND=0 + typeset -g POWERLEVEL9K_SCALAENV_BACKGROUND=1 + # Hide scala version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_SCALAENV_SOURCES=(shell local global) + # If set to false, hide scala version if it's the same as global: + # $(scalaenv version-name) == $(scalaenv global). + typeset -g POWERLEVEL9K_SCALAENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide scala version if it's equal to "system". + typeset -g POWERLEVEL9K_SCALAENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_SCALAENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ haskell_stack: haskell version from stack (https://haskellstack.org/) ]########### + # Haskell color. + typeset -g POWERLEVEL9K_HASKELL_STACK_FOREGROUND=0 + typeset -g POWERLEVEL9K_HASKELL_STACK_BACKGROUND=3 + + # Hide haskell version if it doesn't come from one of these sources. + # + # shell: version is set by STACK_YAML + # local: version is set by stack.yaml up the directory tree + # global: version is set by the implicit global project (~/.stack/global-project/stack.yaml) + typeset -g POWERLEVEL9K_HASKELL_STACK_SOURCES=(shell local) + # If set to false, hide haskell version if it's the same as in the implicit global project. + typeset -g POWERLEVEL9K_HASKELL_STACK_ALWAYS_SHOW=true + # Custom icon. + # typeset -g POWERLEVEL9K_HASKELL_STACK_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################[ terraform: terraform workspace (https://www.terraform.io) ]################# + # Don't show terraform workspace if it's literally "default". + typeset -g POWERLEVEL9K_TERRAFORM_SHOW_DEFAULT=false + # POWERLEVEL9K_TERRAFORM_CLASSES is an array with even number of elements. The first element + # in each pair defines a pattern against which the current terraform workspace gets matched. + # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) + # that gets matched. If you unset all POWERLEVEL9K_TERRAFORM_*CONTENT_EXPANSION parameters, + # you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_TERRAFORM_CLASSES defines the workspace class. Patterns are tried in order. The + # first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=( + # '*prod*' PROD + # '*test*' TEST + # '*' OTHER) + # + # If your current terraform workspace is "project_test", its class is TEST because "project_test" + # doesn't match the pattern '*prod*' but does match '*test*'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_TERRAFORM_TEST_FOREGROUND=2 + # typeset -g POWERLEVEL9K_TERRAFORM_TEST_BACKGROUND=0 + # typeset -g POWERLEVEL9K_TERRAFORM_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_TERRAFORM_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' + typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=( + # '*prod*' PROD # These values are examples that are unlikely + # '*test*' TEST # to match your needs. Customize them as needed. + '*' OTHER) + typeset -g POWERLEVEL9K_TERRAFORM_OTHER_FOREGROUND=4 + typeset -g POWERLEVEL9K_TERRAFORM_OTHER_BACKGROUND=0 + # typeset -g POWERLEVEL9K_TERRAFORM_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #############[ terraform_version: terraform version (https://www.terraform.io) ]############## + # Terraform version color. + typeset -g POWERLEVEL9K_TERRAFORM_VERSION_FOREGROUND=4 + typeset -g POWERLEVEL9K_TERRAFORM_VERSION_BACKGROUND=0 + # Custom icon. + # typeset -g POWERLEVEL9K_TERRAFORM_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################[ terraform_version: It shows active terraform version (https://www.terraform.io) ]################# + typeset -g POWERLEVEL9K_TERRAFORM_VERSION_SHOW_ON_COMMAND='terraform|tf' + + #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# + # Show kubecontext only when the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show kubecontext. + typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile|flux|fluxctl|stern|kubeseal|skaffold|kubent|kubecolor|cmctl|sparkctl' + + # Kubernetes context classes for the purpose of using different colors, icons and expansions with + # different contexts. + # + # POWERLEVEL9K_KUBECONTEXT_CLASSES is an array with even number of elements. The first element + # in each pair defines a pattern against which the current kubernetes context gets matched. + # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) + # that gets matched. If you unset all POWERLEVEL9K_KUBECONTEXT_*CONTENT_EXPANSION parameters, + # you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_KUBECONTEXT_CLASSES defines the context class. Patterns are tried in order. The + # first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( + # '*prod*' PROD + # '*test*' TEST + # '*' DEFAULT) + # + # If your current kubernetes context is "deathray-testing/default", its class is TEST + # because "deathray-testing/default" doesn't match the pattern '*prod*' but does match '*test*'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_FOREGROUND=0 + # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_BACKGROUND=2 + # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' + typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( + # '*prod*' PROD # These values are examples that are unlikely + # '*test*' TEST # to match your needs. Customize them as needed. + '*' DEFAULT) + typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_FOREGROUND=7 + typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_BACKGROUND=5 + # typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Use POWERLEVEL9K_KUBECONTEXT_CONTENT_EXPANSION to specify the content displayed by kubecontext + # segment. Parameter expansions are very flexible and fast, too. See reference: + # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. + # + # Within the expansion the following parameters are always available: + # + # - P9K_CONTENT The content that would've been displayed if there was no content + # expansion defined. + # - P9K_KUBECONTEXT_NAME The current context's name. Corresponds to column NAME in the + # output of `kubectl config get-contexts`. + # - P9K_KUBECONTEXT_CLUSTER The current context's cluster. Corresponds to column CLUSTER in the + # output of `kubectl config get-contexts`. + # - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE + # in the output of `kubectl config get-contexts`. If there is no + # namespace, the parameter is set to "default". + # - P9K_KUBECONTEXT_USER The current context's user. Corresponds to column AUTHINFO in the + # output of `kubectl config get-contexts`. + # + # If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS), + # the following extra parameters are available: + # + # - P9K_KUBECONTEXT_CLOUD_NAME Either "gke" or "eks". + # - P9K_KUBECONTEXT_CLOUD_ACCOUNT Account/project ID. + # - P9K_KUBECONTEXT_CLOUD_ZONE Availability zone. + # - P9K_KUBECONTEXT_CLOUD_CLUSTER Cluster. + # + # P9K_KUBECONTEXT_CLOUD_* parameters are derived from P9K_KUBECONTEXT_CLUSTER. For example, + # if P9K_KUBECONTEXT_CLUSTER is "gke_my-account_us-east1-a_my-cluster-01": + # + # - P9K_KUBECONTEXT_CLOUD_NAME=gke + # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=my-account + # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east1-a + # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 + # + # If P9K_KUBECONTEXT_CLUSTER is "arn:aws:eks:us-east-1:123456789012:cluster/my-cluster-01": + # + # - P9K_KUBECONTEXT_CLOUD_NAME=eks + # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=123456789012 + # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east-1 + # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 + typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION= + # Show P9K_KUBECONTEXT_CLOUD_CLUSTER if it's not empty and fall back to P9K_KUBECONTEXT_NAME. + POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${P9K_KUBECONTEXT_CLOUD_CLUSTER:-${P9K_KUBECONTEXT_NAME}}' + # Append the current context's namespace if it's not "default". + POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${${:-/$P9K_KUBECONTEXT_NAMESPACE}:#/default}' + + # Custom prefix. + # typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX='at ' + + #[ aws: aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) ]# + # Show aws only when the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show aws. + typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|cdk|terraform|pulumi|terragrunt' + + # POWERLEVEL9K_AWS_CLASSES is an array with even number of elements. The first element + # in each pair defines a pattern against which the current AWS profile gets matched. + # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) + # that gets matched. If you unset all POWERLEVEL9K_AWS_*CONTENT_EXPANSION parameters, + # you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_AWS_CLASSES defines the profile class. Patterns are tried in order. The + # first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_AWS_CLASSES=( + # '*prod*' PROD + # '*test*' TEST + # '*' DEFAULT) + # + # If your current AWS profile is "company_test", its class is TEST + # because "company_test" doesn't match the pattern '*prod*' but does match '*test*'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_AWS_TEST_FOREGROUND=28 + # typeset -g POWERLEVEL9K_AWS_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_AWS_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' + typeset -g POWERLEVEL9K_AWS_CLASSES=( + # '*prod*' PROD # These values are examples that are unlikely + # '*test*' TEST # to match your needs. Customize them as needed. + '*' DEFAULT) + typeset -g POWERLEVEL9K_AWS_DEFAULT_FOREGROUND=7 + typeset -g POWERLEVEL9K_AWS_DEFAULT_BACKGROUND=1 + # typeset -g POWERLEVEL9K_AWS_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # AWS segment format. The following parameters are available within the expansion. + # + # - P9K_AWS_PROFILE The name of the current AWS profile. + # - P9K_AWS_REGION The region associated with the current AWS profile. + typeset -g POWERLEVEL9K_AWS_CONTENT_EXPANSION='${P9K_AWS_PROFILE//\%/%%}${P9K_AWS_REGION:+ ${P9K_AWS_REGION//\%/%%}}' + + #[ aws_eb_env: aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) ]# + # AWS Elastic Beanstalk environment color. + typeset -g POWERLEVEL9K_AWS_EB_ENV_FOREGROUND=2 + typeset -g POWERLEVEL9K_AWS_EB_ENV_BACKGROUND=0 + # Custom icon. + # typeset -g POWERLEVEL9K_AWS_EB_ENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ azure: azure account name (https://docs.microsoft.com/en-us/cli/azure) ]########## + # Show azure only when the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show azure. + typeset -g POWERLEVEL9K_AZURE_SHOW_ON_COMMAND='az|terraform|pulumi|terragrunt' + + # POWERLEVEL9K_AZURE_CLASSES is an array with even number of elements. The first element + # in each pair defines a pattern against which the current azure account name gets matched. + # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) + # that gets matched. If you unset all POWERLEVEL9K_AZURE_*CONTENT_EXPANSION parameters, + # you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_AZURE_CLASSES defines the account class. Patterns are tried in order. The + # first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_AZURE_CLASSES=( + # '*prod*' PROD + # '*test*' TEST + # '*' OTHER) + # + # If your current azure account is "company_test", its class is TEST because "company_test" + # doesn't match the pattern '*prod*' but does match '*test*'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_AZURE_TEST_FOREGROUND=2 + # typeset -g POWERLEVEL9K_AZURE_TEST_BACKGROUND=0 + # typeset -g POWERLEVEL9K_AZURE_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_AZURE_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' + typeset -g POWERLEVEL9K_AZURE_CLASSES=( + # '*prod*' PROD # These values are examples that are unlikely + # '*test*' TEST # to match your needs. Customize them as needed. + '*' OTHER) + + # Azure account name color. + typeset -g POWERLEVEL9K_AZURE_OTHER_FOREGROUND=7 + typeset -g POWERLEVEL9K_AZURE_OTHER_BACKGROUND=4 + # Custom icon. + # typeset -g POWERLEVEL9K_AZURE_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]########### + # Show gcloud only when the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show gcloud. + typeset -g POWERLEVEL9K_GCLOUD_SHOW_ON_COMMAND='gcloud|gcs|gsutil' + # Google cloud color. + typeset -g POWERLEVEL9K_GCLOUD_FOREGROUND=7 + typeset -g POWERLEVEL9K_GCLOUD_BACKGROUND=4 + + # Google cloud format. Change the value of POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION and/or + # POWERLEVEL9K_GCLOUD_COMPLETE_CONTENT_EXPANSION if the default is too verbose or not informative + # enough. You can use the following parameters in the expansions. Each of them corresponds to the + # output of `gcloud` tool. + # + # Parameter | Source + # -------------------------|-------------------------------------------------------------------- + # P9K_GCLOUD_CONFIGURATION | gcloud config configurations list --format='value(name)' + # P9K_GCLOUD_ACCOUNT | gcloud config get-value account + # P9K_GCLOUD_PROJECT_ID | gcloud config get-value project + # P9K_GCLOUD_PROJECT_NAME | gcloud projects describe $P9K_GCLOUD_PROJECT_ID --format='value(name)' + # + # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced with '%%'. + # + # Obtaining project name requires sending a request to Google servers. This can take a long time + # and even fail. When project name is unknown, P9K_GCLOUD_PROJECT_NAME is not set and gcloud + # prompt segment is in state PARTIAL. When project name gets known, P9K_GCLOUD_PROJECT_NAME gets + # set and gcloud prompt segment transitions to state COMPLETE. + # + # You can customize the format, icon and colors of gcloud segment separately for states PARTIAL + # and COMPLETE. You can also hide gcloud in state PARTIAL by setting + # POWERLEVEL9K_GCLOUD_PARTIAL_VISUAL_IDENTIFIER_EXPANSION and + # POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION to empty. + typeset -g POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION='${P9K_GCLOUD_PROJECT_ID//\%/%%}' + typeset -g POWERLEVEL9K_GCLOUD_COMPLETE_CONTENT_EXPANSION='${P9K_GCLOUD_PROJECT_NAME//\%/%%}' + + # Send a request to Google (by means of `gcloud projects describe ...`) to obtain project name + # this often. Negative value disables periodic polling. In this mode project name is retrieved + # only when the current configuration, account or project id changes. + typeset -g POWERLEVEL9K_GCLOUD_REFRESH_PROJECT_NAME_SECONDS=60 + + # Custom icon. + # typeset -g POWERLEVEL9K_GCLOUD_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #[ google_app_cred: google application credentials (https://cloud.google.com/docs/authentication/production) ]# + # Show google_app_cred only when the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show google_app_cred. + typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SHOW_ON_COMMAND='terraform|pulumi|terragrunt' + + # Google application credentials classes for the purpose of using different colors, icons and + # expansions with different credentials. + # + # POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES is an array with even number of elements. The first + # element in each pair defines a pattern against which the current kubernetes context gets + # matched. More specifically, it's P9K_CONTENT prior to the application of context expansion + # (see below) that gets matched. If you unset all POWERLEVEL9K_GOOGLE_APP_CRED_*CONTENT_EXPANSION + # parameters, you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES defines the context class. Patterns are tried in order. + # The first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=( + # '*:*prod*:*' PROD + # '*:*test*:*' TEST + # '*' DEFAULT) + # + # If your current Google application credentials is "service_account deathray-testing x@y.com", + # its class is TEST because it doesn't match the pattern '* *prod* *' but does match '* *test* *'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_FOREGROUND=28 + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_CONTENT_EXPANSION='$P9K_GOOGLE_APP_CRED_PROJECT_ID' + typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=( + # '*:*prod*:*' PROD # These values are examples that are unlikely + # '*:*test*:*' TEST # to match your needs. Customize them as needed. + '*' DEFAULT) + typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_FOREGROUND=7 + typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_BACKGROUND=4 + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Use POWERLEVEL9K_GOOGLE_APP_CRED_CONTENT_EXPANSION to specify the content displayed by + # google_app_cred segment. Parameter expansions are very flexible and fast, too. See reference: + # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. + # + # You can use the following parameters in the expansion. Each of them corresponds to one of the + # fields in the JSON file pointed to by GOOGLE_APPLICATION_CREDENTIALS. + # + # Parameter | JSON key file field + # ---------------------------------+--------------- + # P9K_GOOGLE_APP_CRED_TYPE | type + # P9K_GOOGLE_APP_CRED_PROJECT_ID | project_id + # P9K_GOOGLE_APP_CRED_CLIENT_EMAIL | client_email + # + # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced by '%%'. + typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_CONTENT_EXPANSION='${P9K_GOOGLE_APP_CRED_PROJECT_ID//\%/%%}' + + ##############[ toolbox: toolbox name (https://github.com/containers/toolbox) ]############### + # Toolbox color. + typeset -g POWERLEVEL9K_TOOLBOX_FOREGROUND=0 + typeset -g POWERLEVEL9K_TOOLBOX_BACKGROUND=3 + # Don't display the name of the toolbox if it matches fedora-toolbox-*. + typeset -g POWERLEVEL9K_TOOLBOX_CONTENT_EXPANSION='${P9K_TOOLBOX_NAME:#fedora-toolbox-*}' + # Custom icon. + # typeset -g POWERLEVEL9K_TOOLBOX_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + # typeset -g POWERLEVEL9K_TOOLBOX_PREFIX='in ' + + ###############################[ public_ip: public IP address ]############################### + # Public IP color. + typeset -g POWERLEVEL9K_PUBLIC_IP_FOREGROUND=7 + typeset -g POWERLEVEL9K_PUBLIC_IP_BACKGROUND=0 + # Custom icon. + # typeset -g POWERLEVEL9K_PUBLIC_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ########################[ vpn_ip: virtual private network indicator ]######################### + # VPN IP color. + typeset -g POWERLEVEL9K_VPN_IP_FOREGROUND=0 + typeset -g POWERLEVEL9K_VPN_IP_BACKGROUND=6 + # When on VPN, show just an icon without the IP address. + # Tip: To display the private IP address when on VPN, remove the next line. + typeset -g POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION= + # Regular expression for the VPN network interface. Run `ifconfig` or `ip -4 a show` while on VPN + # to see the name of the interface. + typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(gpd|wg|(.*tun)|tailscale)[0-9]*|(zt.*)' + # If set to true, show one segment per matching network interface. If set to false, show only + # one segment corresponding to the first matching network interface. + # Tip: If you set it to true, you'll probably want to unset POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION. + typeset -g POWERLEVEL9K_VPN_IP_SHOW_ALL=false + # Custom icon. + # typeset -g POWERLEVEL9K_VPN_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ ip: ip address and bandwidth usage for a specified network interface ]########### + # IP color. + typeset -g POWERLEVEL9K_IP_BACKGROUND=4 + typeset -g POWERLEVEL9K_IP_FOREGROUND=0 + # The following parameters are accessible within the expansion: + # + # Parameter | Meaning + # ----------------------+------------------------------------------- + # P9K_IP_IP | IP address + # P9K_IP_INTERFACE | network interface + # P9K_IP_RX_BYTES | total number of bytes received + # P9K_IP_TX_BYTES | total number of bytes sent + # P9K_IP_RX_BYTES_DELTA | number of bytes received since last prompt + # P9K_IP_TX_BYTES_DELTA | number of bytes sent since last prompt + # P9K_IP_RX_RATE | receive rate (since last prompt) + # P9K_IP_TX_RATE | send rate (since last prompt) + typeset -g POWERLEVEL9K_IP_CONTENT_EXPANSION='${P9K_IP_RX_RATE:+⇣$P9K_IP_RX_RATE }${P9K_IP_TX_RATE:+⇡$P9K_IP_TX_RATE }$P9K_IP_IP' + # Show information for the first network interface whose name matches this regular expression. + # Run `ifconfig` or `ip -4 a show` to see the names of all network interfaces. + typeset -g POWERLEVEL9K_IP_INTERFACE='[ew].*' + # Custom icon. + # typeset -g POWERLEVEL9K_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #########################[ proxy: system-wide http/https/ftp proxy ]########################## + # Proxy color. + typeset -g POWERLEVEL9K_PROXY_FOREGROUND=4 + typeset -g POWERLEVEL9K_PROXY_BACKGROUND=0 + # Custom icon. + # typeset -g POWERLEVEL9K_PROXY_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################################[ battery: internal battery ]################################# + # Show battery in red when it's below this level and not connected to power supply. + typeset -g POWERLEVEL9K_BATTERY_LOW_THRESHOLD=20 + typeset -g POWERLEVEL9K_BATTERY_LOW_FOREGROUND=1 + # Show battery in green when it's charging or fully charged. + typeset -g POWERLEVEL9K_BATTERY_{CHARGING,CHARGED}_FOREGROUND=2 + # Show battery in yellow when it's discharging. + typeset -g POWERLEVEL9K_BATTERY_DISCONNECTED_FOREGROUND=3 + # Battery pictograms going from low to high level of charge. + typeset -g POWERLEVEL9K_BATTERY_STAGES='\UF008E\UF007A\UF007B\UF007C\UF007D\UF007E\UF007F\UF0080\UF0081\UF0082\UF0079' + # Don't show the remaining time to charge/discharge. + typeset -g POWERLEVEL9K_BATTERY_VERBOSE=false + typeset -g POWERLEVEL9K_BATTERY_BACKGROUND=0 + + #####################################[ wifi: wifi speed ]##################################### + # WiFi color. + typeset -g POWERLEVEL9K_WIFI_FOREGROUND=0 + typeset -g POWERLEVEL9K_WIFI_BACKGROUND=4 + # Custom icon. + # typeset -g POWERLEVEL9K_WIFI_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Use different colors and icons depending on signal strength ($P9K_WIFI_BARS). + # + # # Wifi colors and icons for different signal strength levels (low to high). + # typeset -g my_wifi_fg=(0 0 0 0 0) # <-- change these values + # typeset -g my_wifi_icon=('WiFi' 'WiFi' 'WiFi' 'WiFi' 'WiFi') # <-- change these values + # + # typeset -g POWERLEVEL9K_WIFI_CONTENT_EXPANSION='%F{${my_wifi_fg[P9K_WIFI_BARS+1]}}$P9K_WIFI_LAST_TX_RATE Mbps' + # typeset -g POWERLEVEL9K_WIFI_VISUAL_IDENTIFIER_EXPANSION='%F{${my_wifi_fg[P9K_WIFI_BARS+1]}}${my_wifi_icon[P9K_WIFI_BARS+1]}' + # + # The following parameters are accessible within the expansions: + # + # Parameter | Meaning + # ----------------------+--------------- + # P9K_WIFI_SSID | service set identifier, a.k.a. network name + # P9K_WIFI_LINK_AUTH | authentication protocol such as "wpa2-psk" or "none"; empty if unknown + # P9K_WIFI_LAST_TX_RATE | wireless transmit rate in megabits per second + # P9K_WIFI_RSSI | signal strength in dBm, from -120 to 0 + # P9K_WIFI_NOISE | noise in dBm, from -120 to 0 + # P9K_WIFI_BARS | signal strength in bars, from 0 to 4 (derived from P9K_WIFI_RSSI and P9K_WIFI_NOISE) + + ####################################[ time: current time ]#################################### + # Current time color. + typeset -g POWERLEVEL9K_TIME_FOREGROUND=0 + typeset -g POWERLEVEL9K_TIME_BACKGROUND=7 + # Format for the current time: 09:51:02. See `man 3 strftime`. + typeset -g POWERLEVEL9K_TIME_FORMAT='%D{%H:%M:%S}' + # If set to true, time will update when you hit enter. This way prompts for the past + # commands will contain the start times of their commands as opposed to the default + # behavior where they contain the end times of their preceding commands. + typeset -g POWERLEVEL9K_TIME_UPDATE_ON_COMMAND=false + # Custom icon. + # typeset -g POWERLEVEL9K_TIME_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + # typeset -g POWERLEVEL9K_TIME_PREFIX='at ' + + # Example of a user-defined prompt segment. Function prompt_example will be called on every + # prompt if `example` prompt segment is added to POWERLEVEL9K_LEFT_PROMPT_ELEMENTS or + # POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS. It displays an icon and yellow text on red background + # greeting the user. + # + # Type `p10k help segment` for documentation and a more sophisticated example. + function prompt_example() { + p10k segment -b 1 -f 3 -i '⭐' -t 'hello, %n' + } + + # User-defined prompt segments may optionally provide an instant_prompt_* function. Its job + # is to generate the prompt segment for display in instant prompt. See + # https://github.com/romkatv/powerlevel10k#instant-prompt. + # + # Powerlevel10k will call instant_prompt_* at the same time as the regular prompt_* function + # and will record all `p10k segment` calls it makes. When displaying instant prompt, Powerlevel10k + # will replay these calls without actually calling instant_prompt_*. It is imperative that + # instant_prompt_* always makes the same `p10k segment` calls regardless of environment. If this + # rule is not observed, the content of instant prompt will be incorrect. + # + # Usually, you should either not define instant_prompt_* or simply call prompt_* from it. If + # instant_prompt_* is not defined for a segment, the segment won't be shown in instant prompt. + function instant_prompt_example() { + # Since prompt_example always makes the same `p10k segment` calls, we can call it from + # instant_prompt_example. This will give us the same `example` prompt segment in the instant + # and regular prompts. + prompt_example + } + + # User-defined prompt segments can be customized the same way as built-in segments. + typeset -g POWERLEVEL9K_EXAMPLE_FOREGROUND=3 + typeset -g POWERLEVEL9K_EXAMPLE_BACKGROUND=1 + # typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Transient prompt works similarly to the builtin transient_rprompt option. It trims down prompt + # when accepting a command line. Supported values: + # + # - off: Don't change prompt when accepting a command line. + # - always: Trim down prompt when accepting a command line. + # - same-dir: Trim down prompt when accepting a command line unless this is the first command + # typed after changing current working directory. + typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=always + + # Instant prompt mode. + # + # - off: Disable instant prompt. Choose this if you've tried instant prompt and found + # it incompatible with your zsh configuration files. + # - quiet: Enable instant prompt and don't print warnings when detecting console output + # during zsh initialization. Choose this if you've read and understood + # https://github.com/romkatv/powerlevel10k#instant-prompt. + # - verbose: Enable instant prompt and print a warning when detecting console output during + # zsh initialization. Choose this if you've never tried instant prompt, haven't + # seen the warning, or if you are unsure what this all means. + typeset -g POWERLEVEL9K_INSTANT_PROMPT=verbose + + # Hot reload allows you to change POWERLEVEL9K options after Powerlevel10k has been initialized. + # For example, you can type POWERLEVEL9K_BACKGROUND=red and see your prompt turn red. Hot reload + # can slow down prompt by 1-2 milliseconds, so it's better to keep it turned off unless you + # really need it. + typeset -g POWERLEVEL9K_DISABLE_HOT_RELOAD=true + + # If p10k is already loaded, reload configuration. + # This works even with POWERLEVEL9K_DISABLE_HOT_RELOAD=true. + (( ! $+functions[p10k] )) || p10k reload +} + +# Tell `p10k configure` which file it should overwrite. +typeset -g POWERLEVEL9K_CONFIG_FILE=${${(%):-%x}:a} + +(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]} +'builtin' 'unset' 'p10k_config_opts' 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/audio.nix b/modules/nixos/audio.nix new file mode 100644 index 0000000..9141e14 --- /dev/null +++ b/modules/nixos/audio.nix @@ -0,0 +1,26 @@ +{ pkgs, ... }: { + services = { + pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + # If you want to use JACK applications, uncomment this + #jack.enable = true; + + wireplumber.extraConfig.bluetoothEnhancements = { + "monitor.bluez.properties" = { + "bluez5.enable-sbc-xq" = true; + "bluez5.enable-msbc" = true; + "bluez5.enable-hw-volume" = true; + "bluez5.roles" = [ "hsp_hs" "hsp_ag" "hfp_hf" "hfp_ag" ]; + }; + }; + }; + }; + + environment.systemPackages = with pkgs;[ + # audio control software + pamixer + ]; +} diff --git a/modules/nixos/core/boot.nix b/modules/nixos/core/boot.nix new file mode 100644 index 0000000..f061f4e --- /dev/null +++ b/modules/nixos/core/boot.nix @@ -0,0 +1,22 @@ +# 引导配置 +{ config, lib, pkgs, ... }: + +{ + boot = { + loader = { + efi = { + canTouchEfiVariables = true; + efiSysMountPoint = "/boot"; + }; + + grub = { + enable = true; + efiSupport = true; + device = "nodev"; + }; + }; + + # Allow to modify store. It's dangerous!! + readOnlyNixStore = lib.mkDefault true; + }; +} \ No newline at end of file diff --git a/modules/nixos/core/default.nix b/modules/nixos/core/default.nix new file mode 100644 index 0000000..48525c0 --- /dev/null +++ b/modules/nixos/core/default.nix @@ -0,0 +1,41 @@ +{ lib, ... }: +{ + imports = [ + ./boot.nix + ./system.nix + ]; + + programs = { + git.enable = true; + dconf.enable = true; + nix-ld.enable = true; + }; + + # Configure firewall + networking.firewall = lib.mkDefault { + enable = true; + allowedTCPPorts = [ 22 80 443 ]; # 根据需要调整 + allowedUDPPorts = [ 53 ]; # 根据需要调整 + # 如果需要,可以添加特定服务的规则 + allowedTCPPortRanges = [ + { from = 1714; to = 1764; } # KDE Connect + ]; + }; + + # 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"; +} diff --git a/modules/nixos/core/system.nix b/modules/nixos/core/system.nix new file mode 100644 index 0000000..e108a45 --- /dev/null +++ b/modules/nixos/core/system.nix @@ -0,0 +1,104 @@ +{ outputs, config, lib, ... }: + +{ + security = { + sudo.enable = true; + polkit.enable = true; + }; + + services = { + printing.enable = true; + acpid.enable = true; + upower.enable = true; + + 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; + KbdInteractiveAuthentication = false; + X11Forwarding = false; + }; + }; + + avahi = { + enable = true; + nssmdns4 = true; # 非常重要,允许系统解析 .local 地址 + openFirewall = true; + }; + + journald.extraConfig = '' + SystemMaxUse=500M + MaxFileSec=7day + ''; + }; + + nix = { + settings = { + # Enable flakes and new 'nix' command + experimental-features = "nix-command flakes"; + substituters = [ + "https://mirrors.ustc.edu.cn/nix-channels/store" + "https://nix-community.cachix.org" + "https://cache.nixos.org/" + ]; + trusted-public-keys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; + trusted-users = [ "root" ]; + + # Enable local binary cache + keep-outputs = true; + keep-derivations = true; + + max-jobs = "auto"; + cores = 0; # Use all available cores + + # Deduplicate and optimize nix store during build + # auto-optimise-store = true; + }; + + gc = { + automatic = true; # Enable automatic garbage collection + dates = "weekly"; # Execute garbage collection weekly + persistent = true; # Keep settings after reboot + randomizedDelaySec = "15min"; # Add up to 15 minutes of random delay + options = "--delete-older-than 30d"; # Delete files older than 30 days + }; + + # Automatically run garbage collection whenever there is not enough space left + # Free up to 5GiB whenever there is less than 1GiB left: + extraOptions = '' + min-free = ${toString (1 * 1024 * 1024 * 1024)} + max-free = ${toString (5 * 1024 * 1024 * 1024)} + ''; + }; + + 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 + # 只有在没有使用外部创建的nixpkgs实例时才设置config + config = { + # Disable if you don't want unfree packages + allowUnfree = true; + }; + }; +} diff --git a/modules/nixos/fonts/default.nix b/modules/nixos/fonts/default.nix new file mode 100644 index 0000000..14e2d1c --- /dev/null +++ b/modules/nixos/fonts/default.nix @@ -0,0 +1,43 @@ +{ config, lib, pkgs, ... }: + +{ + imports = [ + ./fhs-fonts.nix + ]; + + environment.systemPackages = with pkgs; [ + ]; + + # all fonts are linked to /nix/var/nix/profiles/system/sw/share/X11/fonts + fonts = { + # use fonts specified by user rather than default ones + enableDefaultPackages = false; + fontDir.enable = true; + + packages = with pkgs; [ + # Noto 系列字体是 Google 主导的,名字的含义是「没有豆腐」q(no tofu),因为缺字时显示的方框或者方框被叫作 tofu + # Noto 系列字族名只支持英文,命名规则是 Noto + Sans 或 Serif + 文字名称。 + # 其中汉字部分叫 Noto Sans/Serif CJK SC/TC/HK/JP/KR,最后一个词是地区变种。 + noto-fonts # 大部分文字的常见样式,不包含汉字 + noto-fonts-cjk-sans # 汉字部分 + noto-fonts-color-emoji # 彩色的表情符号字体 + + # 思源系列字体是 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 + nerd-fonts.jetbrains-mono + # (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..813ec53 --- /dev/null +++ b/modules/nixos/fonts/fhs-fonts.nix @@ -0,0 +1,25 @@ +{ config, lib, pkgs, ... }: + +{ + system.fsPackages = [ pkgs.bindfs ]; + fileSystems = let + mkRoSymBind = path: { + device = path; + fsType = "fuse.bindfs"; + options = [ "ro" "resolve-symlinks" "x-gvfs-hide" ]; + }; + aggregatedIcons = pkgs.buildEnv { + name = "system-icons"; + paths = config.fonts.packages; + pathsToLink = [ "/share/icons" ]; + }; + aggregatedFonts = pkgs.buildEnv { + name = "system-fonts"; + paths = config.fonts.packages; + pathsToLink = [ "/share/fonts" ]; + }; + in { + "/usr/share/icons" = mkRoSymBind "${aggregatedIcons}/share/icons"; + "/usr/local/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/nvidia.nix b/modules/nixos/nvidia.nix new file mode 100644 index 0000000..d54404a --- /dev/null +++ b/modules/nixos/nvidia.nix @@ -0,0 +1,28 @@ +{ config, ... }: +{ + # Tell Xorg to use the nvidia driver (also valid for Wayland) + services.xserver.videoDrivers = [ "nvidia" ]; + + hardware = { + # Make sure opengl is enabled + graphics.enable = true; + 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..8f94ed8 --- /dev/null +++ b/modules/nixos/samba.nix @@ -0,0 +1,39 @@ +{ 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; + settings = { + global = { + "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"; + }; + tmp = { + path = "/home/${username}/tmp"; + browseable = "yes"; + "read only" = "no"; + "guest ok" = "yes"; + "create mask" = "0644"; + "directory mask" = "0755"; + "force user" = "${username}"; + "force group" = "users"; + }; + }; + }; +} diff --git a/modules/nixos/sysatomic.nix b/modules/nixos/sysatomic.nix new file mode 100644 index 0000000..59ab175 --- /dev/null +++ b/modules/nixos/sysatomic.nix @@ -0,0 +1,61 @@ +# 配置原子系统, 使用 tmpfs 作为根文件系统, 并配置持久化存储 +{ inputs, config, pkgs, username, lib, ... }: +{ + imports = [ + inputs.impermanence.nixosModules.impermanence + ]; + + # 启用 tmpfs 作为根文件系统 + fileSystems."/" = lib.mkForce { + device = "tmpfs"; + fsType = "tmpfs"; + options = [ "relatime" "mode=755" ]; + }; + + # 将 /nix 目录绑定到持久化存储 + fileSystems."/nix" = lib.mkForce { + device = "/dev/disk/by-label/nixos"; # 需要根据实际情况修改 + fsType = "btrfs"; + options = [ "compress-force=zstd" ]; + + }; + + # 配置持久化存储 + environment.persistence."/nix/persistent" = { + hideMounts = true; + directories = [ + "/etc/nixos" + "/etc/NetworkManager/system-connections" + "/var/log" + "/var/lib" + "/root" + ]; + + files = [ + "/etc/machine-id" + "/etc/ssh/ssh_host_ed25519_key" + "/etc/ssh/ssh_host_ed25519_key.pub" + "/etc/ssh/ssh_host_rsa_key" + "/etc/ssh/ssh_host_rsa_key.pub" + ]; + + users.${username} = { + directories = [ + ".config" + ".cache" + ".local" + ".ssh" + ".vscode" + ".npm" + ".nix" + "data" + "doc" + ]; + + files = [ + ".zsh_history" + ".gitconfig" + ]; + }; + }; +} diff --git a/modules/nixos/user.nix b/modules/nixos/user.nix new file mode 100644 index 0000000..26fa278 --- /dev/null +++ b/modules/nixos/user.nix @@ -0,0 +1,70 @@ +{ pkgs, username, ... }: + +let + binPath = "/run/current-system/sw/bin/"; +in +{ + nix.settings.trusted-users = [ username ]; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users = { + 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 AAAAB3NzaC1yc2EAAAADAQABAAABgQCc62MxAVqX8LDFAiDiXlc8d3JU1S3xYVO8WpfgoVYPyrd2fkK2Dr1tSedJyGWc3ADOxzUbsTic8b1BOdmbx4ZPwI+a3nJrVVkmIRSAs5haEZqG8NXDv1kl4xL+J9tVA2jwScl6MRzqyVMgtIAvnsVW9+DrL2Y2b20NvuWz3XndZ8vEUFZLLCQJQRpGrY2ZnTvNXZo12GrD5daiMii52ZuhfNBx17oFnf70sj+phZbp5m2mKL9jfKaDSG+E7Pa/IbB/iivD/QSm0SueYXbsdtMBhtsxvH/i0pJogUlVpa42CRIDUVoHOvfk0Hk83xyIIl2b78xfGEyCQBBU6sSk726xXpqzfxJJ7FiYqhLMKKDFmD28EOs4BUveyZudWNcP0a1+uBBcrefNAwU6EOSg65BOxxvZFbNG1I7YDTiKvYFy965+WkN5QKbBVSy08ziS1MQt224ZooAdxCKESGRr9IqKvq9ONnb0MtmC4ht/n8U9VaeLVq3XDXZZHEUq0cw748k= alex@gaea" + ]; + }; + }; + + # 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 = "${pkgs.systemd}/systemctl"; + options = [ "NOPASSWD" ]; + } + { + command = "${binPath}/nix-store"; + options = [ "NOPASSWD" ]; + } + { + command = "${binPath}/nixos-rebuild"; + options = [ "NOPASSWD" "SETENV" ]; + } + { + command = "${binPath}/reboot"; + options = [ "NOPASSWD" ]; + } + { + command = "${binPath}/poweroff"; + options = [ "NOPASSWD" ]; + } + { + command = "/run/wrappers/bin/mount"; + options = [ "NOPASSWD" ]; + } + { + command = "/run/wrappers/bin/umount"; + 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..56cc2d9 --- /dev/null +++ b/modules/nixos/virtualize/docker.nix @@ -0,0 +1,14 @@ +{ config, pkgs, lib, username, ... }: +{ + # Enable Docker + virtualisation.docker = { + enable = true; + storageDriver = "btrfs"; + }; + + # 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..9a37d23 --- /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-amd" "kvm-intel" "vfio" "vfio_iommu_type1" "vfio_pci" "vfio_virqfd" ]; + kernelParams = [ "amd_iommu=on" "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..0122ed5 --- /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..acb5b68 --- /dev/null +++ b/overlays/default.nix @@ -0,0 +1,41 @@ +# 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; + }; + }; + + home-manager-unstable = final: _prev: { + hmunstable = import inputs.home-manager-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..1833712 --- /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/apollo/configuration.nix b/profiles/apollo/configuration.nix new file mode 100644 index 0000000..d2ee4c9 --- /dev/null +++ b/profiles/apollo/configuration.nix @@ -0,0 +1,67 @@ +args@{ inputs, outputs, lib, pkgs, home-manager, self, username, useremail, hostname, sysversion, ... }: { + + # 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 + ./mount.nix + ./network.nix + ./hardware-configuration.nix + + "${self}/modules/nixos/core" + "${self}/modules/nixos/fonts" + "${self}/modules/nixos/user.nix" + "${self}/modules/nixos/audio.nix" + "${self}/modules/nixos/samba.nix" + "${self}/modules/nixos/virtualize/appimage.nix" + "${self}/modules/nixos/virtualize/docker.nix" + + home-manager.nixosModules.home-manager + { + # home-manager.useGlobalPkgs = true; + # home-manager.useUserPackages = true; + home-manager.extraSpecialArgs = { + inherit inputs outputs hostname username useremail sysversion; + }; + home-manager.users."${username}" = { ... }: { + imports = [ + ./hm + "${self}/home/desktop.nix" + "${self}/modules/home/develop.nix" + ]; + }; + } + ]; + + hardware.graphics = { + enable = true; + extraPackages = with pkgs; [ + vaapiIntel + intel-media-driver + ]; + }; + + services = { + gnome.gnome-keyring.enable = true; + }; + + security.pam.services.swaylock = { }; + + programs.zsh = { + enable = true; + }; + + users.users."${username}".shell = pkgs.zsh; + + # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion + system.stateVersion = sysversion; +} diff --git a/profiles/apollo/default.nix b/profiles/apollo/default.nix new file mode 100644 index 0000000..f040d02 --- /dev/null +++ b/profiles/apollo/default.nix @@ -0,0 +1,14 @@ +args@{ libs, inputs, ... }: +let + # 这里可以选择使用稳定版或不稳定版的nixpkgs + # nixpkgs = inputs.nixpkgs; + nixpkgs = inputs.nixpkgs-unstable; # 如果需要使用unstable版本,取消这行注释并注释上一行 + home-manager = inputs.home-manager-unstable; + sysArgs = args // { inherit home-manager; }; +in +# 使用libs.mkNixosSystem创建nixosSystem +libs.mkNixosSystem { + inherit nixpkgs; + args = sysArgs; + path = ./.; +} diff --git a/profiles/apollo/hardware-configuration.nix b/profiles/apollo/hardware-configuration.nix new file mode 100644 index 0000000..ec90096 --- /dev/null +++ b/profiles/apollo/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, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "usbhid" "sd_mod" ]; + boot.initrd.kernelModules = [ "dm-snapshot" ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/9d79b1dc-da5a-456c-a691-9bda5aebcea3"; + fsType = "btrfs"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/FE53-DFFA"; + fsType = "vfat"; + options = [ "fmask=0022" "dmask=0022" ]; + }; + + fileSystems."/nix" = + { device = "/dev/disk/by-uuid/9d79b1dc-da5a-456c-a691-9bda5aebcea3"; + fsType = "btrfs"; + options = [ "subvol=nix" ]; + }; + + fileSystems."/swap" = + { device = "/dev/disk/by-uuid/9d79b1dc-da5a-456c-a691-9bda5aebcea3"; + fsType = "btrfs"; + options = [ "subvol=swap" ]; + }; + + fileSystems."/home" = + { device = "/dev/disk/by-uuid/9d79b1dc-da5a-456c-a691-9bda5aebcea3"; + fsType = "btrfs"; + options = [ "subvol=home" ]; + }; + + 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.eno1.useDHCP = lib.mkDefault true; + # networking.interfaces.enp2s0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp3s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/profiles/apollo/hm/default.nix b/profiles/apollo/hm/default.nix new file mode 100644 index 0000000..2af7fe8 --- /dev/null +++ b/profiles/apollo/hm/default.nix @@ -0,0 +1,6 @@ +{ ... }: { + imports = [ + ./ssh + ./hyprland.nix + ]; +} diff --git a/profiles/apollo/hm/hyprland.nix b/profiles/apollo/hm/hyprland.nix new file mode 100644 index 0000000..4da7a2b --- /dev/null +++ b/profiles/apollo/hm/hyprland.nix @@ -0,0 +1,11 @@ +{ ... }: + +{ + home = { + sessionVariables = { + # for hyprland with nvidia gpu, ref https://wiki.hyprland.org/Nvidia/ + # 启用注释部分会导致NVIDIA下无法启动hyprland + WLR_DRM_DEVICES = "/dev/dri/card1:/dev/dri/card0"; + }; + }; +} diff --git a/profiles/apollo/hm/ssh/config b/profiles/apollo/hm/ssh/config new file mode 100644 index 0000000..872786c --- /dev/null +++ b/profiles/apollo/hm/ssh/config @@ -0,0 +1,66 @@ + + +Host * + ForwardAgent no + AddKeysToAgent no + Compression no + ServerAliveInterval 0 + ServerAliveCountMax 3 + HashKnownHosts no + UserKnownHostsFile ~/.ssh/known_hosts + ControlMaster no + ControlPath ~/.ssh/master-%r@%n:%p + ControlPersist no + + Host gaea + HostName 10.7.43.20 + + Host zion + HostName 10.7.43.1 + User root + + Host themis + HostName 10.7.43.30 + + Host armor + HostName armor.synebula.com + + Host server.company + HostName file.xzdcbj.com.cn + User xzdc + Port 57982 + + Host server.info + HostName info.xzdcbj.com.cn + User info + + Host server.file + HostName file.xzdcbj.com.cn + User file + + Host server.armor + HostName armor.synebula.com + + Host ems.hc + Port 57991 + User root + + Host ems.cx + Port 57996 + + Host ems.ph + Port 57996 + + Host ems.yt + Port 57996 + User xzdc + + Host ems.* + HostName file.xzdcbj.com.cn + User ems + + Host * + Port 22 + User alex + IdentityFile ~/.ssh/id_rsa + diff --git a/profiles/apollo/hm/ssh/default.nix b/profiles/apollo/hm/ssh/default.nix new file mode 100644 index 0000000..7a1e40e --- /dev/null +++ b/profiles/apollo/hm/ssh/default.nix @@ -0,0 +1,10 @@ +{ config, ... }: +{ + programs.ssh = { + enable = true; + }; + + home.file.".ssh/config" = { + source = ./config; + }; +} diff --git a/profiles/apollo/mount.nix b/profiles/apollo/mount.nix new file mode 100644 index 0000000..9abc36d --- /dev/null +++ b/profiles/apollo/mount.nix @@ -0,0 +1,91 @@ +# 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. +{ lib, username, ... }: { + swapDevices = [{ + device = "/swap/swapfile"; + size = 16 * 1024; + }]; + + fileSystems = { + "/" = { + options = lib.mkOptionDefault [ "compress=zstd" ]; + }; + + "/nix" = { + options = lib.mkOptionDefault [ "compress=zstd" "noatime" ]; + }; + + "/home" = { + options = lib.mkOptionDefault [ "compress=zstd" ]; + }; + + "/swap" = { + options = lib.mkOptionDefault [ "compress=no" ]; + }; + + "/tmp" = + { + device = "tmpfs"; + fsType = "tmpfs"; + }; + + + # data目录 + "/data/cache" = + { + device = "/dev/mapper/vcache-data"; + fsType = "ext4"; + }; + "/data/arch" = + { + device = "/dev/mapper/varch-data"; + fsType = "ext4"; + }; + + # 用户目录 + "/home/${username}/tmp" = + { + device = "tmpfs"; + fsType = "tmpfs"; + options = [ "uid=1000" "gid=100" "defaults" "size=16G" "mode=755" ]; + }; + + "/home/${username}/data" = + { + device = "/dev/disk/by-uuid/c52805e6-7d25-4930-806d-585f303b5572"; + fsType = "btrfs"; + options = [ "compress=zstd" "subvol=data" ]; + }; + + "/home/${username}/srv" = + { + device = "/dev/disk/by-uuid/c52805e6-7d25-4930-806d-585f303b5572"; + fsType = "btrfs"; + options = [ "compress=zstd" "subvol=srv" ]; + }; + + "/home/${username}/priv" = + { + device = "/dev/disk/by-uuid/c52805e6-7d25-4930-806d-585f303b5572"; + fsType = "btrfs"; + options = [ "compress=zstd" "subvol=priv" ]; + }; + + + # 微信相关 + "/home/${username}/.local/WeChat/xwechat_files/zerociqher_516a/temp/ImageUtils" = + { + device = "tmpfs"; + fsType = "tmpfs"; + options = [ "uid=1000" "gid=100" "defaults" "size=4G" "mode=755" ]; + }; + + "/home/${username}/.local/WeChat/xwechat_files/zerociqher_516a/temp/InputTemp" = + { + device = "tmpfs"; + fsType = "tmpfs"; + options = [ "uid=1000" "gid=100" "defaults" "size=4G" "mode=755" ]; + }; + }; +} diff --git a/profiles/apollo/network.nix b/profiles/apollo/network.nix new file mode 100644 index 0000000..34405d6 --- /dev/null +++ b/profiles/apollo/network.nix @@ -0,0 +1,42 @@ +{ config, pkgs, hostname, ... }: { + networking = { + hostId = "6fa8b74d"; + 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.10"; + prefixLength = 24; + } + ]; + }; + defaultGateway = { + address = "10.7.43.30"; + interface = "br0"; + }; + nameservers = [ "10.7.43.1" ]; + }; +} diff --git a/profiles/gaea/configuration.nix b/profiles/gaea/configuration.nix new file mode 100644 index 0000000..780af7b --- /dev/null +++ b/profiles/gaea/configuration.nix @@ -0,0 +1,52 @@ +args@{ inputs, outputs, lib, pkgs, home-manager, self, username, useremail, hostname, sysversion, ... }: { + # 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 + + # Import your generated (nixos-generate-config) hardware configuration + ./mount.nix + ./network.nix + ./hardware-configuration.nix + + "${self}/modules/nixos/core" + "${self}/modules/nixos/fonts" + "${self}/modules/nixos/user.nix" + "${self}/modules/nixos/audio.nix" + "${self}/modules/nixos/nvidia.nix" + "${self}/modules/nixos/samba.nix" + "${self}/modules/nixos/zfs.nix" + "${self}/modules/nixos/sysatomic.nix" + + "${self}/modules/nixos/virtualize/libvirtd" + "${self}/modules/nixos/virtualize/docker.nix" + + home-manager.nixosModules.home-manager + { + # home-manager.useGlobalPkgs = true; + # home-manager.useUserPackages = true; + home-manager = { + extraSpecialArgs = { + inherit inputs outputs hostname username useremail sysversion; + }; + users."${username}" = { ... }: { + imports = [ + ./hm + "${self}/home/desktop.nix" + "${self}/modules/home/develop.nix" + ]; + }; + }; + } + ]; + + # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion + system.stateVersion = sysversion; +} diff --git a/profiles/gaea/default.nix b/profiles/gaea/default.nix new file mode 100644 index 0000000..f040d02 --- /dev/null +++ b/profiles/gaea/default.nix @@ -0,0 +1,14 @@ +args@{ libs, inputs, ... }: +let + # 这里可以选择使用稳定版或不稳定版的nixpkgs + # nixpkgs = inputs.nixpkgs; + nixpkgs = inputs.nixpkgs-unstable; # 如果需要使用unstable版本,取消这行注释并注释上一行 + home-manager = inputs.home-manager-unstable; + sysArgs = args // { inherit home-manager; }; +in +# 使用libs.mkNixosSystem创建nixosSystem +libs.mkNixosSystem { + inherit nixpkgs; + args = sysArgs; + path = ./.; +} diff --git a/profiles/gaea/hardware-configuration.nix b/profiles/gaea/hardware-configuration.nix new file mode 100644 index 0000000..ec90096 --- /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, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "usbhid" "sd_mod" ]; + boot.initrd.kernelModules = [ "dm-snapshot" ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/9d79b1dc-da5a-456c-a691-9bda5aebcea3"; + fsType = "btrfs"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/FE53-DFFA"; + fsType = "vfat"; + options = [ "fmask=0022" "dmask=0022" ]; + }; + + fileSystems."/nix" = + { device = "/dev/disk/by-uuid/9d79b1dc-da5a-456c-a691-9bda5aebcea3"; + fsType = "btrfs"; + options = [ "subvol=nix" ]; + }; + + fileSystems."/swap" = + { device = "/dev/disk/by-uuid/9d79b1dc-da5a-456c-a691-9bda5aebcea3"; + fsType = "btrfs"; + options = [ "subvol=swap" ]; + }; + + fileSystems."/home" = + { device = "/dev/disk/by-uuid/9d79b1dc-da5a-456c-a691-9bda5aebcea3"; + fsType = "btrfs"; + options = [ "subvol=home" ]; + }; + + 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.eno1.useDHCP = lib.mkDefault true; + # networking.interfaces.enp2s0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp3s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/profiles/gaea/hm/default.nix b/profiles/gaea/hm/default.nix new file mode 100644 index 0000000..6e2ed2b --- /dev/null +++ b/profiles/gaea/hm/default.nix @@ -0,0 +1,6 @@ +{ ... }: { + imports = [ + ./ssh.nix + ./hyprland.nix + ]; +} diff --git a/profiles/gaea/hm/hyprland.nix b/profiles/gaea/hm/hyprland.nix new file mode 100644 index 0000000..19fa642 --- /dev/null +++ b/profiles/gaea/hm/hyprland.nix @@ -0,0 +1,15 @@ +{ ... }: + +{ + home = { + sessionVariables = { + # for hyprland with nvidia gpu, ref https://wiki.hyprland.org/Nvidia/ + # 启用注释部分会导致NVIDIA下无法启动hyprland + LIBVA_DRIVER_NAME = "nvidia"; + __GLX_VENDOR_LIBRARY_NAME = "nvidia"; + + # WLR_RENDERER = "vulkan"; + # GBM_BACKEND = "nvidia-drm"; + }; + }; +} diff --git a/profiles/gaea/hm/ssh.nix b/profiles/gaea/hm/ssh.nix new file mode 100644 index 0000000..1e706a8 --- /dev/null +++ b/profiles/gaea/hm/ssh.nix @@ -0,0 +1,61 @@ +{ config, ... }: +{ + programs.ssh = { + enable = true; + + # 全局 SSH 配置 + extraConfig = '' + Host apollo + HostName 10.7.43.10 + + Host zion + HostName 10.7.43.1 + User root + + Host themis + HostName 10.7.43.30 + + Host armor + HostName armor.synebula.com + + Host server.company + HostName file.xzdcbj.com.cn + User xzdc + Port 57982 + + Host server.info + HostName info.xzdcbj.com.cn + User info + + Host server.file + HostName file.xzdcbj.com.cn + User file + + Host server.armor + HostName armor.synebula.com + + Host ems.hc + Port 57991 + User root + + Host ems.cx + Port 57996 + + Host ems.ph + Port 57996 + + Host ems.yt + Port 57996 + User xzdc + + Host ems.* + HostName file.xzdcbj.com.cn + User ems + + Host * + Port 22 + User alex + IdentityFile ~/.ssh/id_rsa + ''; + }; +} diff --git a/profiles/gaea/mount.nix b/profiles/gaea/mount.nix new file mode 100644 index 0000000..3e5abf6 --- /dev/null +++ b/profiles/gaea/mount.nix @@ -0,0 +1,26 @@ +# 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, ... }: + +{ + + + 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 = 16 * 1024; + }]; +} diff --git a/profiles/gaea/network.nix b/profiles/gaea/network.nix new file mode 100644 index 0000000..c29ecee --- /dev/null +++ b/profiles/gaea/network.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 = 24; + } + ]; + }; + defaultGateway = { + address = "10.7.43.1"; + interface = "br0"; + }; + nameservers = [ "119.29.29.29" "223.5.5.5" ]; + }; +} diff --git a/profiles/luna/configuration.nix b/profiles/luna/configuration.nix new file mode 100644 index 0000000..90fc85c --- /dev/null +++ b/profiles/luna/configuration.nix @@ -0,0 +1,42 @@ +args@{ inputs, outputs, lib, pkgs, home-manager, self, username, useremail, hostname, sysversion, ... }: { + + # 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 + ./network.nix + ./hardware-configuration.nix + + "${self}/modules/nixos/core" + "${self}/modules/nixos/user.nix" + "${self}/modules/nixos/sysatomic.nix" + + home-manager.nixosModules.home-manager + { + # home-manager.useGlobalPkgs = true; + # home-manager.useUserPackages = true; + home-manager = { + extraSpecialArgs = { + inherit inputs outputs hostname username useremail sysversion; + }; + users."${username}" = { ... }: { + imports = [ + "${self}/home/desktop.nix" + ]; + }; + }; + } + ]; + + # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion + system.stateVersion = sysversion; +} diff --git a/profiles/luna/default.nix b/profiles/luna/default.nix new file mode 100644 index 0000000..f040d02 --- /dev/null +++ b/profiles/luna/default.nix @@ -0,0 +1,14 @@ +args@{ libs, inputs, ... }: +let + # 这里可以选择使用稳定版或不稳定版的nixpkgs + # nixpkgs = inputs.nixpkgs; + nixpkgs = inputs.nixpkgs-unstable; # 如果需要使用unstable版本,取消这行注释并注释上一行 + home-manager = inputs.home-manager-unstable; + sysArgs = args // { inherit home-manager; }; +in +# 使用libs.mkNixosSystem创建nixosSystem +libs.mkNixosSystem { + inherit nixpkgs; + args = sysArgs; + path = ./.; +} diff --git a/profiles/luna/hardware-configuration.nix b/profiles/luna/hardware-configuration.nix new file mode 100644 index 0000000..ec90096 --- /dev/null +++ b/profiles/luna/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, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "usbhid" "sd_mod" ]; + boot.initrd.kernelModules = [ "dm-snapshot" ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/9d79b1dc-da5a-456c-a691-9bda5aebcea3"; + fsType = "btrfs"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/FE53-DFFA"; + fsType = "vfat"; + options = [ "fmask=0022" "dmask=0022" ]; + }; + + fileSystems."/nix" = + { device = "/dev/disk/by-uuid/9d79b1dc-da5a-456c-a691-9bda5aebcea3"; + fsType = "btrfs"; + options = [ "subvol=nix" ]; + }; + + fileSystems."/swap" = + { device = "/dev/disk/by-uuid/9d79b1dc-da5a-456c-a691-9bda5aebcea3"; + fsType = "btrfs"; + options = [ "subvol=swap" ]; + }; + + fileSystems."/home" = + { device = "/dev/disk/by-uuid/9d79b1dc-da5a-456c-a691-9bda5aebcea3"; + fsType = "btrfs"; + options = [ "subvol=home" ]; + }; + + 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.eno1.useDHCP = lib.mkDefault true; + # networking.interfaces.enp2s0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp3s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/profiles/luna/network.nix b/profiles/luna/network.nix new file mode 100644 index 0000000..9018628 --- /dev/null +++ b/profiles/luna/network.nix @@ -0,0 +1,30 @@ +# 网络配置 +{ config, lib, pkgs, ... }: + +{ + networking = { + 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 = 24; + } + ]; + }; + defaultGateway = "10.7.45.1"; + nameservers = [ + "119.29.29.29" # DNSPod + "223.5.5.5" # AliDNS + ]; + }; +}