我尝试让我的 fcitx5-rime(中州韵)在我的 nixos25.11(hyprland0.52 ,wayland)上运行。
但是在我的最新构建中,它无法工作,只显示黑屏(似乎 sddm 有一些问题,我在 configuration.nix 和 hyprland.conf 中设置了一些关于环境的设置。
这是我的 configuration.nix 和 hyprland.conf 文件。抱歉我的英语不太好,您能用英语和中文回答吗?请尽量用简单易懂的方式告诉我,因为我刚开始用 NixOS QwQ
非常感谢,祝您度过美好的一天.
-- Source - https://stackoverflow.com/q/79842500
-- Posted by ziming wen
-- Retrieved 2025-12-10, License - CC BY-SA 4.0
###configuration.nix###
{ config, pkgs,lib, ... }:
{
imports = [ ./hardware-configuration.nix ];
# Basic system
networking.hostName = "nixos-laptop";
time.timeZone = "Asia/Shanghai";
i18n.defaultLocale = "zh_CN.UTF-8";
system.stateVersion = "25.11"; # set to your NixOS version
# 用户帐户
users.users.wen = {
isNormalUser = true;
description = "xxx";
home = "/home/wen";
extraGroups = [ "wheel" "networkmanager" "audio" "video" ];
initialPassword = "yyy";
};
# Sudo
security.sudo = {
enable = true;
wheelNeedsPassword = true;
};
# Networking
networking.networkmanager.enable = true;
services.openssh.enable = true;
services.openssh.settings = {
PasswordAuthentication = true; # 需要时在本机关闭以提高安全
};
# Desktop: Hyprland with SDDM on physical machine
services.xserver.enable = true;
services.displayManager.sddm.enable = true;
services.displayManager.defaultSession = "hyprland";
# GPU / OpenGL (driver selection depends on hardware)
hardware.opengl = { enable = true; extraPackages = with pkgs; [ ]; };
# Allow unfree packages if you want Chrome/WPS
nixpkgs.config = { allowUnfree = true; };
hardware.enableRedistributableFirmware = true;
#hyprland
programs.hyprland = {
enable = true;
#enableNvidiaPatches = false; # 如果你不是Nvidia显卡,保持false
xwayland = {
enable = true;
#hidpi = true; # 如果你的显示器是高DPI屏幕,可以取消注释这行
};
};
# Sound (PipeWire)
services.pipewire.enable = true;
hardware.pulseaudio = { enable = false; };
# Power for laptops
services.tlp.enable = true;
# Firewall
networking.firewall.enable = true;
# Bootloader (do not change this lightly on a running system)
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
# System packages (desktop-focused). After WSL validation you can tune this list.
environment.systemPackages = with pkgs; [
# Core
vim git wget curl htop neofetch
# Terminal + launcher
alacritty rofi
# Wayland desktop
hyprland waybar mako swww copyq nautilus gedit
# Clipboard / screenshot
wl-clipboard grim slurp
# Desktop portal (for Flatpak and Wayland features)
xdg-desktop-portal xdg-desktop-portal-wlr
# Multimedia
pipewire wireplumber mpv ffmpeg vlc
# Input
# fcitx5 fcitx5-rime qt6Packages.fcitx5-chinese-addons qt6Packages.fcitx5-configtool
# Fonts
noto-fonts-cjk-sans noto-fonts-cjk-serif sarasa-gothic
# Browsers & packaging
firefox google-chrome flatpak
# Utilities
pavucontrol imagemagick obs-studio btop
];
# Minimal root filesystem placeholder for WSL testing; on a real machine keep the generated hardware-configuration.nix
#fileSystems = {
# "/" = {
# device = "/dev/root";
# fsType = "auto";
# };
#};
#fcitx5
i18n.inputMethod = {
enabled = "fcitx5";
fcitx5.addons = with pkgs; [
fcitx5-rime
qt6Packages.fcitx5-configtool
qt6Packages.fcitx5-chinese-addons
fcitx5-gtk # 为GTK程序提供支持
];
};
# Input method environment variables
environment.sessionVariables = {
GTK_IM_MODULE = "fcitx";
QT_IM_MODULE = "fcitx";
XMODIFIERS = "@im=fcitx";
SDL_IM_MODULE = "fcitx";
LANG = "zh_CN.UTF-8";
QT_QPA_PLATFORMTHEME = "qt5ct";
XDG_CURRENT_DESKTOP = "Hyprland";
XDG_SESSION_TYPE = "wayland";
QT_QPA_PLATFORM = "wayland";
MOZ_ENABLE_WAYLAND = "1";
SDL_VIDEODRIVER = "wayalnd";
};
# Fonts (also available in environment.systemPackages)
fonts.fonts = with pkgs; [ noto-fonts-cjk-sans noto-fonts-cjk-serif sarasa-gothic ];
# Flatpak service
#services.flatpak.enable = true;
# Disable automatic system upgrades by default
system.autoUpgrade.enable = false;
# Notes for deploy: do not hardcode substituters/trusted-keys here if you plan to pass them via the deploy script.
}
-- Source - https://stackoverflow.com/q/79842500
-- Posted by ziming wen
-- Retrieved 2025-12-10, License - CC BY-SA 4.0
###hyprland.conf###
########################################################################################
# HYPRLAND CONFIGURATION FOR NIXOS (user: xxx)
# Location: ~/.config/hypr/hyprland.conf
# Compatible with: Hyprland 0.36+
########################################################################################
########################################################################################
# MONITORS
########################################################################################
monitor=,preferred,auto,1
########################################################################################
# ENVIRONMENT VARIABLES
########################################################################################
env = XCURSOR_SIZE,24
env = XCURSOR_THEME,Adwaita
env = QT_QPA_PLATFORMTHEME,qt5ct
# Input Method (Fcitx5)
env = GTK_IM_MODULE,fcitx5
env = QT_IM_MODULE,fcitx5
env = XMODIFIERS,@im=fcitx5
env = XDG_SESSION_TYPE,wayland
env = XDG_CURRENT_DESKTOP,Hyprland
env = QT_QPA_PLATFORM,wayland
env = MOZ_ENABLE_WAYLAND,1
env = GDK_BACKEND,wayland
env = XIM_SERVER,1 # 重要:启用 XIM 服务器
env = SDL_VIDEODRIVER,wayland
########################################################################################
# INPUT
########################################################################################
input {
kb_layout = us,cn
kb_variant = ,
kb_options = grp:alt_shift_toggle
follow_mouse = 1
mouse_refocus = true
touchpad {
natural_scroll = false
disable_while_typing = true
tap-to-click = true
}
sensitivity = 0.0
}
########################################################################################
# GENERAL
########################################################################################
general {
gaps_in = 5
gaps_out = 10
border_size = 2
# Color scheme (Catppuccin Mocha inspired)
col.active_border = rgb(a6e3a1)
col.inactive_border = rgb(45475a)
layout = dwindle
allow_tearing = false
no_border_on_floating = false
}
########################################################################################
# DECORATION
########################################################################################
decoration {
# Rounding
rounding = 10
# Blur
blur {
enabled = true
size = 3
passes = 1
noise = 0.0117
}
# Shadow
shadow {
enabled = true
range = 4
render_power = 3
color = rgba(000000aa)
}
# Opacity
active_opacity = 1.0
inactive_opacity = 0.95
}
########################################################################################
# ANIMATIONS
########################################################################################
animations {
enabled = true
# Bezier curves
bezier = easeOutQuad, 0.25, 0.46, 0.45, 0.94
bezier = easeInOutCubic, 0.42, 0.0, 0.58, 1.0
bezier = linear, 0.0, 0.0, 1.0, 1.0
# Window animations (0.5.2版本新语法)
animation = windows, 1, 7, default, slide
animation = border, 1, 10, default
animation = fade, 1, 7, default
animation = workspaces, 1, 6, default, slide
}
########################################################################################
# DWINDLE LAYOUT
########################################################################################
dwindle {
pseudotile = true
preserve_split = true
}
########################################################################################
# MASTER LAYOUT
########################################################################################
master {
orientation = left
}
########################################################################################
# GESTURES (Hyprland 0.5.2 新语法)
########################################################################################
# 3指左滑:切换到上一个工作区
gesture = 3, l, workspace, e-1
# 3指右滑:切换到下一个工作区
gesture = 3, r, workspace, e+1
# 可选:3指上滑/下滑(例如切换窗口)
#gesture = 3, u, movefocus, u
#gesture = 3, d, movefocus, d
########################################################################################
# MISC
########################################################################################
misc {
disable_hyprland_logo = false
#disable_splash_text = false
font_family = Sarasa Gothic
focus_on_activate = false
mouse_move_focuses_monitor = true
vfr = true
}
########################################################################################
# WINDOW RULES
########################################################################################
# Floating windows
windowrulev2 = float, class:^(pavucontrol)$
windowrulev2 = float, class:^(grim)$
windowrulev2 = float, class:^(slurp)$
windowrulev2 = float, class:^(obs)$
windowrulev2 = float, title:^(Open File)$
windowrulev2 = float, title:^(Save File)$
windowrulev2 = float, title:^(Choose Files)$
# Size and position for floating
windowrulev2 = size 800 600, class:^(pavucontrol)$, floating:1
windowrulev2 = center, class:^(pavucontrol)$, floating:1
# Chat applications
windowrule = workspace 4, class:^(wechat|WeChat)$
windowrulev2 = float, class:^(wechat|WeChat)$
# Media
windowrulev2 = float, class:^(mpv|vlc)$
windowrulev2 = size 1280 720, class:^(mpv)$
windowrulev2 = center, class:^(mpv)$
# Workspace assignment
windowrulev2 = workspace 1, class:^(firefox|google-chrome)$
windowrulev2 = workspace 2, class:^(alacritty|kitty)$
windowrulev2 = workspace 3, class:^(code|VSCodium)$
########################################################################################
# KEYBINDINGS
########################################################################################
# Main modifier
$mainMod = SUPER
# Applications
bind = $mainMod, Return, exec, alacritty
bind = $mainMod, d, exec, rofi -show drun
bind = $mainMod SHIFT, e, exec, rofi -show run
bind = $mainMod, e, exec, nautilus
bind = $mainMod, b, exec, firefox
bind = $mainMod, c, exec, code
# Window management
bind = $mainMod, w, killactive,
bind = $mainMod SHIFT, q, exit,
bind = $mainMod, f, fullscreen, 0
bind = $mainMod SHIFT, f, fullscreen, 1
bind = $mainMod, p, pseudo,
bind = $mainMod, m, togglefloating,
bind = $mainMod, s, togglesplit,
# Focus movement (Arrow keys)
bind = $mainMod, Left, movefocus, l
bind = $mainMod, Right, movefocus, r
bind = $mainMod, Up, movefocus, u
bind = $mainMod, Down, movefocus, d
# Focus movement (Vim-style)
bind = $mainMod, h, movefocus, l
bind = $mainMod, l, movefocus, r
bind = $mainMod, k, movefocus, u
bind = $mainMod, j, movefocus, d
# Move windows
bind = $mainMod SHIFT, h, movewindow, l
bind = $mainMod SHIFT, l, movewindow, r
bind = $mainMod SHIFT, k, movewindow, u
bind = $mainMod SHIFT, j, movewindow, d
# Resize windows
bind = $mainMod CTRL, h, resizeactive, -30 0
bind = $mainMod CTRL, l, resizeactive, 30 0
bind = $mainMod CTRL, k, resizeactive, 0 -30
bind = $mainMod CTRL, j, resizeactive, 0 30
# Workspace switching
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
# Workspace navigation
bind = $mainMod ALT, Right, workspace, e+1
bind = $mainMod ALT, Left, workspace, e-1
# Move window to workspace
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
# Screenshots
bind = , Print, exec, grim /tmp/screenshot-$(date +%s).png && notify-send "Screenshot saved"
bind = $mainMod SHIFT, s, exec, grim -g "$(slurp)" - | wl-copy && notify-send "Screenshot copied"
# Brightness control
bindl = , XF86MonBrightnessUp, exec, brightnessctl set +10%
bindl = , XF86MonBrightnessDown, exec, brightnessctl set 10%-
# Volume control
bindl = , XF86AudioRaiseVolume, exec, pactl set-sink-volume @DEFAULT_SINK@ +5%
bindl = , XF86AudioLowerVolume, exec, pactl set-sink-volume @DEFAULT_SINK@ -5%
bindl = , XF86AudioMute, exec, pactl set-sink-mute @DEFAULT_SINK@ toggle
# Media control
bindl = , XF86AudioPlay, exec, playerctl play-pause
bindl = , XF86AudioNext, exec, playerctl next
bindl = , XF86AudioPrev, exec, playerctl previous
# Mouse bindings
bindm = $mainMod, mouse:272, movewindow
bindm = $mainMod, mouse:273, resizewindow
########################################################################################
# AUTOSTART APPLICATIONS
########################################################################################
exec-once = dbus-update-activation-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP
exec-once = swww init
exec-once = swww img /home/wen/.config/hypr/wallpaper1.png --transition-type=fade --transition-duration=300
exec-once = waybar
exec-once = mako
exec-once = fcitx5 -d
# Optional: XDG Desktop Portal
# exec-once = /usr/lib/xdg-desktop-portal-wlr
