用於桌面的NixOS

Revision as of 11:16, 8 October 2025 by Ardenet (talk | contribs)

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模塊

另見

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