-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfiguration.nix
392 lines (361 loc) · 11.7 KB
/
configuration.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
# ---- METADATA ----
# Target: /etc/nixos/configuration.nix
# Author: Hentioe (绅士喵)
# CreatedAt: 2020-12-15
# UpdatedAt: 2024-11-10
# ---- METADATA ----
# 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, ... }:
{
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
];
boot.kernelPackages = pkgs.linuxPackages_latest;
boot.supportedFilesystems = [ "bcachefs" ];
# Use the systemd-boot EFI boot loader.
# boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.loader.timeout = 10;
# Use the GRUB boot loader.
boot.loader.grub = {
enable = true;
device = "nodev";
efiSupport = true;
useOSProber = true;
gfxmodeEfi = "1024x768";
};
# 修改 systemd 的终止任务的超时时间。
systemd.extraConfig = ''
DefaultTimeoutStopSec=10s
'';
systemd.user.extraConfig = ''
DefaultTimeoutStopSec=10s
'';
# networking.hostName = "nixos"; # Define your hostname.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
networking.enableIPv6 = true;
# Set your time zone.
time.timeZone = "Asia/Shanghai";
# The global useDHCP flag is deprecated, therefore explicitly set to false here.
# Per-interface useDHCP will be mandatory in the future, so this generated config
# replicates the default behaviour.
# networking.useDHCP = true;
# networking.interfaces.enp3s0.useDHCP = true;
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Select internationalisation properties.
i18n.defaultLocale = "zh_CN.UTF-8";
# console = {
# font = "Lat2-Terminus16";
# keyMap = "us";
# };
i18n.inputMethod = {
enable = true;
type = "fcitx5";
fcitx5.addons = with pkgs; [
fcitx5-chinese-addons
fcitx5-rime
];
};
# Configure keymap/X11/Wayland
services.xserver.enable = true;
services.xserver.xkb.layout = "us";
# services.xserver.xkbOptions = "eurosign:e";
services.xserver.videoDrivers = [ "amdgpu" ];
# 避免 NVIDIA GPU 画面撕裂(无需在应用层开启垂直同步)。
# TODO: 构建以后将此配置输出为独立的 .conf 文件(如果可能)。
# services.xserver.screenSection = ''
# Option "metamodes" "nvidia-auto-select +0+0 {ForceCompositionPipeline=On, ForceFullCompositionPipeline=On}"
# '';
services.libinput = {
enable = true;
mouse.accelProfile = "flat"; # 禁用鼠标加速
};
# 设置 DPI 值 (仅适用 X.org,4k 分辨率),在 KDE Plasma 6 下不生效(被 KDE 设置覆盖)。
services.xserver.dpi = 144; # 96 * 1.5
services.displayManager.sddm = {
enable = true;
wayland.enable = true;
settings = {
General = {
DisplayServer = "x11";
# 设置缩放和字体 DPI(对 X11 和 Wayland 都起作用)
GreeterEnvironment = "QT_SCREEN_SCALE_FACTORS=1.5,QT_FONT_DPI=144";
};
X11 = {
# 设置 X11 下的 DPI 值,KDE Plasma 6 疑似已不起作用。
#ServerArguments = "-nolisten tcp -dpi 144";
};
};
};
services.desktopManager.plasma6.enable = true;
# XRDP server
services.xrdp.enable = true;
services.xrdp.defaultWindowManager = "startplasma-x11";
# networking.firewall.allowedTCPPorts = [ 3389 ];
# 启用 GNOME 密钥环。
services.gnome.gnome-keyring.enable = true;
# 登录以后自动解锁 GNOME 密钥环。
security.pam.services.login.enableGnomeKeyring = true;
security.pam.services.sddm.enableGnomeKeyring = true;
# 登录后自动解锁 KDE 钱包。
security.pam.services.sddm.enableKwallet = true;
# Gconf service (GNOME 2 era)
# services.dbus.packages = with pkgs; [ gnome2.GConf ];
# Enable CUPS to print documents.
# services.printing.enable = true;
# Enable Flatpak.
services.flatpak.enable = true;
# Enable sound.
# sound.enable = true;
# hardware.pulseaudio.enable = true;
# hardware.pulseaudio.support32Bit = true; # # If compatibility with 32-bit applications is desired.
hardware.graphics.extraPackages = with pkgs; [ amdvlk ];
hardware.graphics.extraPackages32 = with pkgs; [ driversi686Linux.amdvlk ];
hardware.amdgpu.amdvlk.enable = true;
# Enable touchpad support (enabled default in most desktopManager).
# services.xserver.libinput.enable = true;
# 虚拟化配置
virtualisation = {
# 启用虚拟化服务
libvirtd.enable = true;
docker = {
enable = true;
daemon.settings = {
experimental = true;
};
};
incus.enable = true;
};
# Define a user account. Don't forget to set a password with ‘passwd’.
users.users.hentioe = {
isNormalUser = true;
extraGroups = [
"adbusers"
"wheel"
"libvirtd"
"docker"
"dialout"
"incus-admin"
];
};
# 启用 Zsh
programs.zsh.enable = true;
# 为用户配置默认 Shell。
users.extraUsers.hentioe = {
shell = pkgs.zsh;
};
# Neovim
programs.neovim = {
enable = true;
viAlias = true;
configure = {
customRC = ''
" 语法高亮
syntax on
" 显示行号
set number
" 显示光标所在行
set cursorline
" 高亮显示匹配的括号
set showmatch
" 自动读取外部更改
set autoread
" 始终显示状态栏
set laststatus=2
" 显示光标的当前位置
set ruler
" 设置缩进
set expandtab " 使用空格代替制表符
set tabstop=2 " 制表符宽度
set shiftwidth=2 " 缩进宽度
set softtabstop=2 " 退格键宽度
" 命令行补全
set wildmenu
" 搜索时忽略大小写,但在有大写字母时敏感
set ignorecase
set smartcase
" 高亮搜索结果
set hlsearch
" 增量搜索
set incsearch
" 允许在未保存的缓冲区间切换
set hidden
" 使用空格键作为 leader 键
let mapleader=" "
" 快速保存
nnoremap <leader>w :w<CR>
" 快速退出
nnoremap <leader>q :q<CR>
" 启用鼠标
set mouse=a
" 启用基于文件类型的插件和缩进
filetype plugin indent on
" 共享系统剪切板
set clipboard+=unnamedplus
" 设置主题
color dracula
" 自动保存
lua require'auto-save'.setup{}
" 记住上次编辑位置
lua require'nvim-lastplace'.setup{}
" 加载用户的 lua 配置
if filereadable(expand("~/.nvim.lua"))
luafile ~/.nvim.lua
endif
'';
packages.myVimPackage = with pkgs.vimPlugins; {
start = [
dracula-vim
nvim-lastplace
auto-save-nvim
];
};
};
};
# Allow unfree
nixpkgs.config.allowUnfree = true;
# 启用 dconf(Peek 需要)
programs.dconf.enable = true;
# Steam 配置
programs.steam = {
package = pkgs.steam.override {
extraEnv = {
STEAM_FORCE_DESKTOPUI_SCALING = 1.5; # 配置缩放
};
};
enable = true;
remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play
dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server
};
programs.coolercontrol.enable = true;
# List packages installed in system profile. To search, run:
# $ nix search wget
# 注意:此处仅添加系统的基础包,额外软件通过 home-manager 管理。
environment.systemPackages = with pkgs; [
#home-manager # 用户环境 Nix 包管理器
direnv # 自动加载/卸载 Shell 环境
bash-completion # Bash 补全合集
wezterm # GPU 加速的跨平台终端
parted # 分区工具
bind # DNS 工具集
lshw # 查看硬件
usbutils # USB 工具集
nvme-cli # NVMe 用户空间工具
git # Git
nixfmt-rfc-style # Nix 代码格式化工具
nix-tree # 依赖树查看
gnupg # PGP 签名和加密
latte-dock # 独立的 Dock 栏
desktop-file-utils # 桌面条目相关的工具
zsh # Zsh
file # 查看文件信息
smartmontools # 查看硬盘的 SMART 统计
neovide # Neovim 编辑器的 GUI
xclip # 命令行操作剪切板(Neovim 需要)
killall # 按名称杀进程
libva-utils # vainfo 命令,验证 VA-API 设置
zip
#xsettingsd # X 设置的守护进程(KDE Plasma 6 疑似已不需要)
kdePackages.qtstyleplugin-kvantum # Kvantum 主题引擎
kdePackages.kde-gtk-config # KDE 的 GTK 设置
kdePackages.kcolorpicker # KDE 的颜色选择器
kdePackages.qtbase # 包含 update-desktop-database
];
# 排除的 KDE 包
environment.plasma6.excludePackages = with pkgs.kdePackages; [
konsole # 被 wezterm 替代
kate # 被 Neovide 替代
akonadi-contacts # 管理联系人,不需要
];
# 配置字体
fonts = {
enableDefaultPackages = true;
fontDir.enable = true;
packages = with pkgs; [
# Noto 系列字体
noto-fonts
noto-fonts-lgc-plus
noto-fonts-cjk-sans
noto-fonts-cjk-serif
noto-fonts-emoji
noto-fonts-emoji-blob-bin
noto-fonts-monochrome-emoji
mononoki # Neovide 字体
nerdfonts
];
fontconfig = {
# 配置默认字体。
defaultFonts = {
serif = [
"Noto Serif"
"Noto Serif CJK SC"
];
sansSerif = [
"Noto Sans"
"Noto Sans CJK SC"
];
monospace = [
"Noto Sans Mono"
"Noto Sans Mono CJK SC"
];
};
};
};
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# 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;
# adb/fastboot 无需 sudo。
services.udev.packages = [ pkgs.android-udev-rules ];
# rtkit is optional but recommended
security.rtkit.enable = true;
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;
};
networking.firewall.enable = false;
# Open ports in the firewall.
networking.firewall.allowedTCPPorts = [
1313 # Hugo default
4000 # Phoenix default
3389 # RDP
];
#networking.firewall.allowedUDPPorts = [];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
networking.nftables.enable = true;
# 将 LXD 桥接接口加入信任列表,避免 LXC 容器和虚拟机获取不到 IPv4 地址。
networking.firewall.trustedInterfaces = [ "incusbr0" ];
# Hosts
#networking.extraHosts = '''';
# services.octoprint.enable = true;
# systemd.services.octoprint.path = [ pkgs.python3Packages.pip ];
#systemd.user.services.xsettingsd = {
# wantedBy = [ "graphical-session.target" ];
# serviceConfig = {
# ExecStart = "${pkgs.xsettingsd}/bin/xsettingsd";
# };
#};
# 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. It‘s 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 = "20.09"; # Did you read the comment?
}