Jump to content

用於桌面的NixOS

From NixOS Wiki
Revision as of 10:34, 25 February 2025 by Mayer (talk | contribs) (Created page with "其中第二个视频, 从大概27分钟开始, 也是对Home Manager的介绍和设置指南.")

NixOS可以用於許多目的. 如果你想把它用作你的日常主要桌面作業系統(在實體機上或者作為副虛擬機), 那麼你應該看看這個頁面. 即使你是想把NixOS用在雲端或者是經過特殊配置的伺服器上, 你也可能會想從這裏概述的課程開始, 以便從整體上對Nix生態有更好的了解.

安裝

Wiki(維基百科)上的方法

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

視頻指南

如果想要一個可視化指南, 請看Wil T Nix Guides. 其中第二個視頻是一個簡潔的安裝指南. 這個8期視頻系列於2021年初製作, 也涵蓋了從把NixOS用作桌面到根據你的喜好來配置它的所有基本內容.

管理你的配置

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

視頻指南

Wil T的指南是下列內容的均衡組合:

  1. 動手實踐的引導, 讓你逐步學會使用Home Manager, git版本控制,以及最後的Flakes來掌握你的系統
  2. Nix生態, 社區, 以及可用資源的概念總覽和總體介紹

其中第二個視頻, 從大概27分鐘開始, 也是對Home Manager的介紹和設置指南.

Modularizing your configuration

With NixOS Modules

configuration.nix is an instance of a NixOS module, which makes it easy to break your configuration into several files. Modules can:

  • Import other modules
  • Declare new options
  • Provide values for options (this is what most of your default configuration.nix does)
  • Reference option values from other modules (via the config attribute passed to all modules)

As long as you declare options for any values you want to share between modules, you can divide your configuration however you like into files that get imported, directly or transitively, by your root configuration.nix file. You can also import modules from remote sources, using functions like builtins.fetchTarball. See the wiki page or the NixOS manual for more information.

With Flakes

If you want a more composable[citation needed] NixOS configuration setup, the still-experimental Flakes feature is causing a lot of excitement in the community. Managing flakes requires a good basic understanding and some existing hands on experience with the Nix ecosystem.

視頻指南

Videos seven and eight of Wil T's original 8-part series are a good overview of what Flakes enable and how to get started with them.

Beyond initial setup

After you are familiar with the Nix ecosystem and have a functional desktop install of NixOS, you will likely be interested in customizations and more detailed setup.

通過示例來學習

If you are comfortable managing your system through a git repo using flakes, then there are many repositories you can learn from now!

Check out Comparison of NixOS setups for a table comparing some popular choices.

See Configuration Collection for a long list within the wiki.

Additionally, the following topic searches on Github should uncover many useful examples.