请帮忙,fcitx5 出了一些问题。

我尝试让我的 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

如果要在wayland下用sddm,你得加上services.displayManager.sddm.wayland.enable = true;

具体的可以在官方wiki的KDE页面找到。

  i18n.inputMethod = {
    enabled = "fcitx5";
    fcitx5.addons = with pkgs; [
      fcitx5-rime
      qt6Packages.fcitx5-configtool
      qt6Packages.fcitx5-chinese-addons
      fcitx5-gtk # 为GTK程序提供支持
    ];
  };

fcitx5也需要手动开启wayland支持i18n.inputMethod.fcitx5.waylandFrontend = true;

不要用enabled,这个选项已经被弃用了,改成i18n.inputMethod.type

可以看看wikiFcitx5

  # GPU / OpenGL (driver selection depends on hardware)
  hardware.opengl = { enable = true; extraPackages = with pkgs; [ ]; };

也是旧的弃用选项,改成hardware.graphics

  environment.systemPackages = with pkgs; [
    ...

    # 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
    
    ...
  ];

hyprland不要直接加到environment.systemPackages里面,你已经通过programs.hyprland添加hyprland包了,这个模块会自动安装hyprland,如果再手动添加可能会把开启了xwayland的包顶掉。pipewire同理。

xdg-desktop-portal不要这么安装,用xdg.portal.enablexdg.portal.extraPortals

  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";
  };

LANG删了,i18n.defaultLocale已经自动处理了。

MOZ_ENABLE_WAYLAND删了,firefox已经默认wayland了。

QT_QPA_PLATFORMTHEME改成qt.platformTheme = “qt5ct”;

xdg相关的设置删了,programs.hyprland模块已经帮你处理完了,要修改用programs.hyprland.portalPackage

1 Like

qt.platformTheme = “qt5ct”;过不了系统编译,所以我暂时注释掉了,现在waybar上已经可显示出图标,但是不显示搜字框,而且直接使用拼音加数字选字时没有效果,请问时什么问题

没事,qt.platformTheme = “qt5ct”我放错了位置,通过了nixos重构,但是依旧不显示选字框,也无法正常打字,请指正

这是我最新的配置

{ 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";
  # user account
  users.users.wen = {
    isNormalUser = true;
    description = "wen";
    home = "/home/wen";
    extraGroups = [ "wheel" "networkmanager" "audio" "video" ];
    initialPassword = "3014";
  };
  # 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
  services.xserver.enable = true;
  services.displayManager.sddm.enable = true;
  services.displayManager.defaultSession = "hyprland";
  xdg.portal = { enable = true; wlr.enable = true; };
  # GPU
  hardware.graphics = { enable = true; extraPackages = with pkgs; [ ]; };
  # Allow unfree packages
  nixpkgs.config = { allowUnfree = true; };
  hardware.enableRedistributableFirmware = true;
  # Hyprland
  programs.hyprland = {
    enable = true;
    xwayland = {
      enable = true;
    };
  };
  # Sound (PipeWire)
  services.pipewire.enable = true;
  services.pulseaudio = { enable = false; };
  # Power for laptops
  services.tlp.enable = true;
  # Firewall
  networking.firewall.enable = true;
  # Bootloader
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;
  # System packages
  environment.systemPackages = with pkgs; [
    # Core
    vim git wget curl htop neofetch
    # Terminal + launcher
    alacritty rofi
    # Wayland desktop
    waybar mako swww copyq nautilus gedit qt6.qtwayland qt5.qtwayland
    # Clipboard / screenshot
    wl-clipboard grim slurp
    # Multimedia - 完全保留PipeWire
    wireplumber mpv ffmpeg vlc
    # Browsers & packaging
    firefox google-chrome flatpak wechat-uos qq wpsoffice
    # Utilities
    pavucontrol imagemagick obs-studio btop
  ];
  # fcitx5 Rime
  i18n.inputMethod = {
    enable = true;
    type = "fcitx5";
    fcitx5.addons = with pkgs; [
      fcitx5-rime
      qt6Packages.fcitx5-configtool
      qt6Packages.fcitx5-chinese-addons
      fcitx5-gtk
    ];
  };
  i18n.inputMethod.fcitx5.waylandFrontend = true;

  # Input method environment variables
  environment.sessionVariables = {
    GTK_IM_MODULE = "fcitx";
    QT_IM_MODULE = "fcitx";
    XMODIFIERS = "@im=fcitx";
    SDL_IM_MODULE = "fcitx";
  };
  qt.platformTheme = "qt5ct";
  # Fonts
  fonts.packages = with pkgs; [ noto-fonts-cjk-sans noto-fonts-cjk-serif sarasa-gothic font-awesome nerd-fonts.fira-code material-design-icons ];
  # Disable automatic system upgrades
  system.autoUpgrade.enable = false;
  # Autostart
  xdg.autostart.enable = true;
  services.displayManager.sddm.wayland.enable = true;
}
########################################################################################
# HYPRLAND CONFIGURATION FOR NIXOS (user: wen)
# 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
env = GTK_IM_MODULE,fcitx
env = QT_IM_MODULE,fcitx
env = XMODIFIERS,@im=fcitx
env = XDG_SESSION_TYPE,wayland
env = XDG_CURRENT_DESKTOP,Hyprland

########################################################################################
# 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 --systemd --all
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

我不用hyprland,所以我能确定的问题就这么多了。下面是一些猜测,不一定准确,需要你自己判断和测试:

首先既然fcitx5跑起来了,那没法输入我猜是环境变量的问题。按照fcitx5wiki的说法,wayland不应该设置GTK_IM_MODULE和QT_IM_MODULE,但这俩环境变量确实有的时候可以解决一些问题。我不确定你是不是需要这俩变量。25.11打包的qt包版本是6.10,而text-input-v3在qt6.8就已经实现了,理论上是不需要的。SDL_IM_MODULE会由fcitx5模块自动导入,当然留着也无所谓。我自己的配置是这样的,相当简单:


  i18n.inputMethod = {
    enable = true;
    type = "fcitx5";
    fcitx5 = {
      waylandFrontend = true;
      addons = with pkgs; [
        fcitx5-rime
      ];
    };
  };

另外nixos wiki的hyprland页面建议是使用UWSM

{
  programs.hyprland = {
    enable = true;
    withUWSM = true; # recommended for most users
    xwayland.enable = true; # Xwayland can be disabled.
  };
}

我不知道对不对,但既然建议,那也可以试试,反正能回滚。

编辑:补充一下,别忘了把hyprland配置文件里面的环境变量也一起移除。我猜这有可能会破坏一些东西

对不起,好像直接使用UWSM无法编译,还要引入一些新的参数吗,请示范一下 :face_with_monocle:

你先在nixos-rebuild命令加上--show-trace,然后报错复制上来。啥都没有我可能只能给你算一卦了。我这里一样的配置是正常的,复现不了啊。另外我说了我不用hyprland,我自己机器上测出来的和你的环境也不一样,你先把不该有的环境变量删了试一试。

我找到了这个问题

# 将这一行
services.displayManager.defaultSession = "hyprland";

# 改为
services.displayManager.defaultSession = "hyprland-uwsm";

就可以通过编译

我注释掉了

environment.sessionVariables = {
    GTK_IM_MODULE = "fcitx";
    QT_IM_MODULE = "fcitx";
    XMODIFIERS = "@im=fcitx";
    SDL_IM_MODULE = "fcitx";
  };

通过了编译,系统功能没有变化,但是问题还是一样 :face_with_raised_eyebrow:

你把hyprland设置文件里面这两行注释掉了吗?

env = XCURSOR_SIZE,24
env = XCURSOR_THEME,Adwaita
env = QT_QPA_PLATFORMTHEME,qt5ct
# Input Method
env = GTK_IM_MODULE,fcitx
env = QT_IM_MODULE,fcitx
env = XMODIFIERS,@im=fcitx
env = XDG_SESSION_TYPE,wayland
env = XDG_CURRENT_DESKTOP,Hyprland