refactor: reorganize config order, clean up comments, restore xdg.configFile for nix-shell unfree support

This commit is contained in:
2026-05-29 23:11:56 +08:00
parent 055e13848c
commit 8c4af495b4
2 changed files with 54 additions and 122 deletions
+47 -115
View File
@@ -1,17 +1,12 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, ... }: { config, pkgs, ... }:
{ {
imports = imports = [
[ # Include the results of the hardware scan.
./hardware-configuration.nix ./hardware-configuration.nix
./programs/clash.nix ./programs/clash.nix
]; ];
# ── Nix 自身设置 ────────────────────────────────────────────
nix.settings.experimental-features = [ "nix-command" "flakes" ]; nix.settings.experimental-features = [ "nix-command" "flakes" ];
nix.settings.auto-optimise-store = true; nix.settings.auto-optimise-store = true;
nix.gc = { nix.gc = {
@@ -19,63 +14,23 @@
dates = "weekly"; dates = "weekly";
options = "--delete-older-than 7d"; options = "--delete-older-than 7d";
}; };
# Bootloader. nixpkgs.config.allowUnfree = true;
# ── 引导 ────────────────────────────────────────────────────
boot.loader.systemd-boot.enable = true; boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true; boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "nixos"; # Define your hostname. # ── 网络 ────────────────────────────────────────────────────
programs.nix-ld.enable = true; networking.hostName = "nixos";
services.flatpak.enable = true;
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
fonts.enableDefaultPackages = true;
fonts.packages = with pkgs; [
noto-fonts
noto-fonts-cjk-sans
noto-fonts-cjk-serif
sarasa-gothic # 更纱黑体,包含优秀的中英文等宽字体,极其适合终端和编程
wqy_microhei
wqy_zenhei
];
fonts.fontconfig = {
enable = true;
# 设置全局默认字体,防止系统回退到显示效果不佳的字体
defaultFonts = {
serif = [ "Noto Serif CJK SC" "Noto Serif" ];
sansSerif = [ "Noto Sans CJK SC" "Noto Sans" ];
monospace = [ "Sarasa Term SC" "Noto Sans Mono CJK SC" ];
};
# 解决锯齿问题的核心:开启抗锯齿、微调和次像素渲染
antialias = true;
hinting = {
enable = true;
style = "slight"; # 若在高分屏 (HiDPI) 下,"slight" 通常表现最好
};
subpixel = {
rgba = "rgb"; # 针对 LCD 屏幕的次像素排列优化
lcdfilter = "default";
};
};
# Enable networking
networking.networkmanager.enable = true; networking.networkmanager.enable = true;
services.tailscale.enable = true;
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Set your time zone. # ── 时区与本地化 ────────────────────────────────────────────
time.timeZone = "Asia/Shanghai"; time.timeZone = "Asia/Shanghai";
# Select internationalisation properties.
i18n.defaultLocale = "zh_CN.UTF-8"; i18n.defaultLocale = "zh_CN.UTF-8";
i18n.extraLocaleSettings = { i18n.extraLocaleSettings = {
LC_ADDRESS = "zh_CN.UTF-8"; LC_ADDRESS = "zh_CN.UTF-8";
LC_IDENTIFICATION = "zh_CN.UTF-8"; LC_IDENTIFICATION = "zh_CN.UTF-8";
@@ -93,7 +48,7 @@
type = "fcitx5"; type = "fcitx5";
fcitx5.waylandFrontend = true; fcitx5.waylandFrontend = true;
fcitx5.addons = with pkgs; [ fcitx5.addons = with pkgs; [
# 使用 Fcitx5 拼音(由 fcitx5-chinese-addons 提供),并补齐 KDE/Qt 集成组件。 # 拼音输入 + KDE/Qt 集成
qt6Packages.fcitx5-chinese-addons qt6Packages.fcitx5-chinese-addons
fcitx5-gtk fcitx5-gtk
kdePackages.fcitx5-qt kdePackages.fcitx5-qt
@@ -101,24 +56,37 @@
]; ];
}; };
# Enable the X11 windowing system. # ── 桌面环境 (KDE Plasma 6 / Wayland) ───────────────────────
# You can disable this if you're only using the Wayland session.
services.xserver.enable = true; services.xserver.enable = true;
# Enable the KDE Plasma Desktop Environment.
services.displayManager.sddm.enable = true; services.displayManager.sddm.enable = true;
services.desktopManager.plasma6.enable = true; services.desktopManager.plasma6.enable = true;
services.xserver.xkb.layout = "us";
# Configure keymap in X11 # 字体
services.xserver.xkb = { fonts.enableDefaultPackages = true;
layout = "us"; fonts.packages = with pkgs; [
variant = ""; noto-fonts
noto-fonts-cjk-sans
noto-fonts-cjk-serif
sarasa-gothic # 更纱黑体,极其适合终端和编程
wqy_microhei
wqy_zenhei
];
fonts.fontconfig = {
enable = true;
defaultFonts = {
serif = [ "Noto Serif CJK SC" "Noto Serif" ];
sansSerif = [ "Noto Sans CJK SC" "Noto Sans" ];
monospace = [ "Sarasa Term SC" "Noto Sans Mono CJK SC" ];
};
antialias = true;
hinting.enable = true;
hinting.style = "slight";
subpixel.rgba = "rgb";
subpixel.lcdfilter = "default";
}; };
# Enable CUPS to print documents. # 音频 (PipeWire)
services.printing.enable = true;
# Enable sound with pipewire.
services.pulseaudio.enable = false; services.pulseaudio.enable = false;
security.rtkit.enable = true; security.rtkit.enable = true;
services.pipewire = { services.pipewire = {
@@ -126,18 +94,12 @@
alsa.enable = true; alsa.enable = true;
alsa.support32Bit = true; alsa.support32Bit = true;
pulse.enable = true; pulse.enable = true;
# If you want to use JACK applications, uncomment this
#jack.enable = true;
# use the example session manager (no others are packaged yet so this is enabled by default,
# no need to redefine it in your config for now)
#media-session.enable = true;
}; };
# Enable touchpad support (enabled default in most desktopManager). services.printing.enable = true;
# services.xserver.libinput.enable = true; services.flatpak.enable = true;
# Define a user account. Don't forget to set a password with passwd. # ── 用户 ────────────────────────────────────────────────────
users.users.test = { users.users.test = {
isNormalUser = true; isNormalUser = true;
description = "test"; description = "test";
@@ -145,50 +107,20 @@
packages = with pkgs; [ packages = with pkgs; [
kdePackages.kate kdePackages.kate
nodejs nodejs
# thunderbird bubblewrap
]; ];
}; };
# Install firefox. # ── 程序与服务 ──────────────────────────────────────────────
programs.firefox.enable = true; programs.firefox.enable = true;
programs.steam.enable = true; programs.steam.enable = true;
programs.nix-ld.enable = true;
virtualisation.docker.enable = true; virtualisation.docker.enable = true;
services.tailscale.enable = true;
services.gnome.gnome-keyring.enable = true; services.gnome.gnome-keyring.enable = true;
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
# vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
# wget
];
# Some programs need SUID wrappers, can be configured further or are # ── 系统级软件包 ────────────────────────────────────────────
# started in user sessions. environment.systemPackages = with pkgs; [ ];
# programs.mtr.enable = true;
# programs.gnupg.agent = {
# enable = true;
# enableSSHSupport = true;
# };
# List services that you want to enable:
# Enable the OpenSSH daemon.
# services.openssh.enable = true;
# Open ports in the firewall.
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "25.11"; # Did you read the comment?
# ── 系统状态版本(请勿修改) ────────────────────────────────
system.stateVersion = "25.11";
} }
+3 -3
View File
@@ -20,9 +20,6 @@
gpu-screen-recorder-gtk gpu-screen-recorder-gtk
]; ];
# 让 nix-shell 等传统命令也能安装 unfree 软件
xdg.configFile."nixpkgs/config.nix".text = "{ allowUnfree = true; }";
# 用 Home Manager 固定 Fcitx5 输入法配置,仅保留拼音 # 用 Home Manager 固定 Fcitx5 输入法配置,仅保留拼音
home.file.".config/fcitx5/profile".text = '' home.file.".config/fcitx5/profile".text = ''
[Groups/0] [Groups/0]
@@ -46,6 +43,9 @@
"$HOME/.npm-global/bin" "$HOME/.npm-global/bin"
]; ];
# 让 nix-shell 等传统命令也能安装 unfree 软件
xdg.configFile."nixpkgs/config.nix".text = "{ allowUnfree = true; }";
programs.bash = { programs.bash = {
enable = true; enable = true;
initExtra = '' initExtra = ''