Jump to content

用於桌面的NixOS

From NixOS Wiki
Revision as of 12:16, 8 October 2025 by Ardenet (talk | contribs) (Created page with "分类:桌面 分类:指南 分类:NixOS")

NixOS 是一款功能多樣的作業系統,適用於各種用例。本文面向希望將 NixOS 作為主要桌面環境(無論是在物理硬體還是虛擬機中)的用戶。此外,計劃在 雲端 環境或專用伺服器基礎架構上部署 NixOS 的用戶,可能會發現從這裡介紹的概念和實踐開始會很有幫助,因為它們為在更廣泛的 Nix 生態系統 中工作奠定了有益的基礎。

安裝

如果你傾向於閱讀, 請從NixOS安裝指南開始. 如果你想選擇一個精良的視頻教程, 請見下一條. 請記住, 為了安裝一個桌面, 你需要確定一開始有至少30GiB的可用硬碟空間來容納桌面環境(比如說, GNOME, KDE, 或者是XFCE), 瀏覽器(比如Firefox), 以及其他帶有圖形界面的典型日用軟體(如VSCode). 對於相對簡陋的配置, 15GiB可能夠用.

管理你的配置

你可以使用NixOS官方手冊中記錄的方式來管理你的所有配置. 然而, 大部分在桌面上使用NixOS的社區成員更喜歡使用Home Manager來管理他們的配置(比如"點文件")(citation needed). Home Manager是一個面向用戶的工具, 用於聲明你想安裝什麼, 以及你想如何配置它. 對於大部分設置, 如果你不使用Home Manager的話, 你就要把它們放入configuration.nix, 或者使用nix-env.

The process for managing your configuration is documented in the NixOS official manual.

System Configuration

The primary configuration file, /etc/nixos/configuration.nix, defines system-wide settings. This includes options like enabling services, managing system users, setting hardware options, and specifying installed packages. Changes are applied with:

# nixos-rebuild switch

User configuration with Home Manager

For managing per-user configurations such as application preferences, command-line tools, and dotfiles, Home Manager provides a convenient, declarative approach. It allows users to define which programs should be installed and how they should be configured, without needing to include those settings in the system-wide configuration.nix.

Home Manager can be used independently of the system configuration and works with both traditional setups and newer Flakes-based configurations.

通過Flakes

如果你想要可組合性[citation needed]更強的NixOS配置設定, 仍在實驗階段的Flakes特性正在使社區感到十分興奮. 管理flakes需要對Nix生態有良好的基本理解和一些已有的實踐經驗.

Refer to NixOS system configuration#Defining NixOS as a flake for details on getting started.

在初始設置之外

在你熟悉了Nix生態並安裝了一個功能性的NixOS桌面後, 你可能會想了解定製化和更細化的設置.

Common configuration areas include:

Desktop Environments

Install and configure full-featured environments such as GNOME, KDE Plasma, or Xfce.

See Category:Desktop environment for a full list.

Window Managers

Set up lightweight or tiling window managers like i3, Sway, Hyprland, or xmonad.

See Category:Window managers for a full list.

Display Managers (Login Managers)

Configure graphical session managers such as GDM, SDDM, or LightDM.

Audio Setup

Enable and configure audio systems like PipeWire, PulseAudio, or ALSA.

Network Management

Use tools such as NetworkManager or systemd-networkd for managing network connections.

Bluetooth Support

Set up Bluetooth with blueman or other management tools.

Power Management

Configure laptop battery management, suspend, and hibernation with tools like tlp or systemd services.

Printing and Scanning

Enable Cups for printer support and tools like Sane for scanning devices.

提示和技巧

通過 NixOS 模塊機制模塊化你的配置

Main article: NixOS system configuration#Modularizing your configuration with modules

另見

對NixOS設置的比較中可查看一個對常見選擇進行比較的表格.