
{ config, pkgs, ... }:
{
imports = [ ./hardware-configuration.nix ]; # 导入硬件配置模块,用于加载硬件扫描结果
# 引导加载器配置
boot.loader.systemd-boot.enable = true; # 启用systemd-boot引导程序
boot.loader.efi.canTouchEfiVariables = true; # 允许修改EFI变量,支持UEFI引导
# 网络配置
networking.hostName = "nixos"; # 设置主机名
networking.networkmanager.enable = true; # 启用NetworkManager,支持无线网络管理
# 时区设置
time.timeZone = "Asia/Shanghai"; # 设置时区为上海(中国标准时间)
# Nix包管理器配置
nix.settings = {
substituters = [
"https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store?priority=10" # 添加清华大学镜像源,提高下载速度
"https://mirrors.ustc.edu.cn/nix-channels/store?priority=5" # 添加中科大镜像源
"https://cache.nixos.org/" # 默认官方缓存
];
experimental-features = [ "nix-command" "flakes" ]; # 启用实验性功能:nix命令增强和flakes支持
};
# X11服务器和桌面环境配置
services.xserver.enable = true; # 启用X11窗口系统
services.desktopManager.gnome.enable = true; # 启用GNOME桌面环境
services.displayManager.gdm.enable = true; # 启用GDM显示管理器(GNOME登录界面)
programs.niri.enable = true; # 启用Niri Wayland合成器(作为GNOME的替代或补充)
# 键盘布局配置
services.xserver.xkb.layout = "us"; # 设置X11键盘布局为美式
# 打印服务
services.printing.enable = true; # 启用CUPS打印系统
# 音频配置
services.pulseaudio.enable = false; # 禁用PulseAudio(使用PipeWire替代)
security.rtkit.enable = true; # 启用RTKit实时内核支持(用于音频权限)
services.pipewire = {
enable = true; # 启用PipeWire多媒体框架
alsa.enable = true; # 启用PipeWire的ALSA兼容层
alsa.support32Bit = true; # 支持32位ALSA应用
pulse.enable = true; # 启用PulseAudio兼容层
};
# 用户账户配置
users.users.<你的用户名> = {
isNormalUser = true; # 创建普通用户
description = "<你的用户名>"; # 用户描述
extraGroups = [ "networkmanager" "wheel" ]; # 添加用户到额外组(网络管理和sudo权限)
packages = with pkgs; [ ]; # 用户专属包列表(当前为空)
};
# 应用程序配置
programs.firefox.enable = true; # 启用Firefox浏览器(系统级安装)
services.flatpak.enable = true; # 启用Flatpak包管理器,支持第三方应用
# Nixpkgs配置
nixpkgs.config.allowUnfree = true; # 允许安装非自由软件包
# 系统级包列表
environment.systemPackages = with pkgs; [
vim # 文本编辑器
wget # 文件下载工具
alacritty # 终端模拟器
];
# 服务配置
services.openssh.enable = true; # 启用OpenSSH服务器,支持远程登录
# 系统版本
system.stateVersion = "25.05"; # 指定NixOS状态版本(保持为首次安装版本)
}{
description = "NixOS flake-configuration with Noctalia";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
quickshell = {
url = "github:outfoxxed/quickshell";
inputs.nixpkgs.follows = "nixpkgs";
};
noctalia = {
url = "github:noctalia-dev/noctalia-shell";
inputs.nixpkgs.follows = "nixpkgs";
inputs.quickshell.follows = "quickshell";
};
};
outputs = inputs@{ self, nixpkgs, ... }: {
nixosConfigurations.nixos = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { inherit inputs; };
modules = [
./configuration.nix
./noctalia.nix
./chinese.nix
];
};
};
}{ pkgs, inputs, ... }: {
environment.systemPackages = with pkgs; [
inputs.noctalia.packages.${system}.default
fuzzel
vesktop
# webcord
kitty
fastfetch
# ... 其他软件包
];
}{ config, pkgs, lib, ... }: {
# 设置系统的中文环境
i18n = {
defaultLocale = "zh_CN.UTF-8";
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";
};
supportedLocales = [ "zh_CN.UTF-8/UTF-8" "en_US.UTF-8/UTF-8" ];
};
# 输入法配置(Fcitx5)
i18n.inputMethod = {
enable = true;
type = "fcitx5";
fcitx5.addons = with pkgs; [
fcitx5-chinese-addons
];
fcitx5.waylandFrontend = true;
};
# 中文字体优化
fonts = {
packages = with pkgs; [
noto-fonts
noto-fonts-cjk-sans # 思源黑体 (无衬线)
noto-fonts-cjk-serif # 思源宋体 (衬线)
];
fontconfig = {
defaultFonts = {
sansSerif = [ "Noto Sans CJK SC" ];
serif = [ "Noto Serif CJK SC" ];
};
};
};
}// 基础输入设置
input {
keyboard {
xkb.layout "us"
repeat-delay 300
repeat-rate 30
}
touchpad {
tap
natural-scroll
}
mouse {
accel-profile "flat"
}
focus-follows-mouse
}
// 窗口布局设置
layout {
gaps 4
center-focused-column "never"
preset-column-widths {
0.33333 // 1/3
0.5 // 1/2
0.66667 // 2/3
1.0 // 全宽
}
default-column-width proportion=0.66667
border width=2
background-color "transparent"
}
// 启动程序
spawn-at-startup "noctalia-shell"
// 环境变量
environment {
MOZ_ENABLE_WAYLAND "1"
XDG_SESSION_TYPE "wayland"
GDK_BACKEND "wayland"
TERM "kitty"
TERMINAL "kitty"
QT_QPA_PLATFORMTHEME "qt6ct"
}
// 窗口规则
window-rule {
match app-id="^(steam_app_.*)$"
open-fullscreen true
}
// 快捷键
binds {
Mod+Return { spawn "kitty"; }
Mod+D { spawn "fuzzel"; }
Mod+Q { close-window; }
Mod+F { fullscreen-window; }
// 工作区切换
Mod+1-9 { focus-workspace 1-9; }
Mod+Ctrl+1-9 { move-column-to-workspace 1-9; }
// 音量控制
XF86AudioRaiseVolume { spawn-sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1+"; }
XF86AudioLowerVolume { spawn-sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1-"; }
XF86AudioMute { spawn-sh "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"; }
// 其他
Mod+Shift+E { quit; }
Mod+C { center-column; }
Mod+R { switch-preset-column-width; }
}sudo nix flake update
sudo nixos-rebuild switch --flake .#nixos原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。