Jump to content

NixOS as a desktop/zh: Difference between revisions

From NixOS Wiki
Mayer (talk | contribs)
Failed submission with URL
Tags: Mobile edit Mobile web edit
Mayer (talk | contribs)
No edit summary
 
(28 intermediate revisions by the same user not shown)
Line 2: Line 2:
NixOS可以用于许多目的. 如果你想把它用作你的日常主要桌面操作系统(在实体机上或者作为副虚拟机), 那么你应该看看这个页面. 即使你是想把NixOS用在云端或者是经过特殊配置的服务器上, 你也可能会想从这里概述的课程开始, 以便从整体上对Nix生态有更好的了解.
NixOS可以用于许多目的. 如果你想把它用作你的日常主要桌面操作系统(在实体机上或者作为副虚拟机), 那么你应该看看这个页面. 即使你是想把NixOS用在云端或者是经过特殊配置的服务器上, 你也可能会想从这里概述的课程开始, 以便从整体上对Nix生态有更好的了解.


<div lang="en" dir="ltr" class="mw-content-ltr">
<span id="Installation"></span>
== Installation ==
== 安装 ==
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<span id="Wiki_method"></span>
=== Wiki method ===
=== Wiki上的方法 ===
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
如果你倾向于阅读, 请从[[NixOS Installation Guide|NixOS安装指南]]开始. 如果你想选择一个精良的视频教程, 请见下一条. 请记住, 为了安装一个桌面, 你需要确定一开始有至少30GiB的可用硬盘空间来容纳桌面环境(比如说, GNOME, KDE, 或者是XFCE), 浏览器(比如Firefox), 以及其他带有图形界面的典型日用软件(如VSCode). 对于相对简陋的配置, 15GiB可能够用.
If you prefer reading, see [[NixOS Installation Guide]] to get started. For a well presented video option, see video guide section immediately below. Keep in mind that, for a desktop installation, you will probably want to make sure you start with at least 30 GiB of available disk space to allow for the desktop environments (e.g. GNOME, KDE, or XFCE), browsers (e.g. Firefox), and other graphical applications (e.g. VSCode) that would be typical of daily use. 15 GiB might be enough in a pinch for a fairly bare-bones setup.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<span id="Video_guide"></span>
=== Video guide ===
=== 视频指南 ===
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
如果想要一个可视化指南, 请看[[Wil T Nix Guides]]. 其中[[Wil_T_Nix_Guides#NixOS_Installation_Guide|第二个视频]]是一个简洁的安装指南. 这个8期视频系列于2021年初制作, 也涵盖了从把NixOS用作桌面到根据你的喜好来配置它的所有基本内容.
For a visual guide, see [[Wil T Nix Guides]]. The [[Wil_T_Nix_Guides#NixOS_Installation_Guide|second video]] is a concise installation guide. This 8-part series, produced in early 2021, also covers all the basics of using NixOS as a desktop and configuring it to your liking.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<span id="Managing_your_configuration"></span>
== Managing your configuration ==
== 管理你的配置 ==
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
你可以使用[https://nixos.org/manual/nixos/stable/index.html NixOS官方手册]中记录的方式来管理你的所有配置. 然而, 大部分在桌面上使用NixOS的社区成员更喜欢使用[[Home Manager]]来管理他们的配置(比如"点文件")(citation needed). Home Manager是一个面向用户的工具, 用于声明你想安装什么, 以及你想如何配置它. 对于大部分设置, 如果你不使用Home Manager的话, 你就要把它们放入[https://nixos.org/manual/nixos/stable/#sec-changing-config configuration.nix], 或者使用[[FAQ#How_can_I_manage_software_with_nix-env_like_with_configuration.nix.3F|nix-env]].
It is possible to manage your entire configuration using the methods documented in the [https://nixos.org/manual/nixos/stable/index.html NixOS official manual]. However, most community members who use NixOS on the desktop prefer to manage their user configurations (e.g. "dotfiles") using [[Home Manager]] (citation needed). Home Manager is a user oriented tool for declaring what you want installed and how you want it configured, and thus would be used in lieu of most settings you would otherwise put into a [https://nixos.org/manual/nixos/stable/#sec-changing-config configuration.nix] or through [[FAQ#How_can_I_manage_software_with_nix-env_like_with_configuration.nix.3F|nix-env]]
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<span id="Video_guide"></span>
=== Video guide ===
=== 视频指南 ===
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
Wil T的指南是下列内容的均衡组合:
Wil T's guides are about an even mix of:
# 动手实践的引导, 让你逐步学会使用Home Manager, git版本控制,以及最后的Flakes来掌握你的系统
# Hands-on bootstrapping to get to being able to very capably manage your system using Home Manager, git versioning, and eventually Flakes.
# Nix生态, 社区, 以及可用资源的概念总览和总体介绍
# Conceptual overviews and general exposition of the Nix ecosystem, community, and available resources.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
其中[[Wil_T_Nix_Guides#NixOS_Installation_Guide|第二个视频]], 从大概27分钟开始, 也是对Home Manager的介绍和设置指南.
The [[Wil_T_Nix_Guides#NixOS_Installation_Guide|second video]], starting from about 27 minutes in, is also an introduction to and guide to setting up Home Manager.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<span id="Modularizing_your_configuration"></span>
== Modularizing your configuration ==
== 模块化你的配置 ==
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<span id="With_NixOS_Modules"></span>
=== With NixOS Modules ===
=== 通过NixOS模块 ===
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
configuration.nix[[NixOS modules|NixOS模块]]的一个实例, 因此把你的配置分开放入若干文件中很容易.
configuration.nix is an instance of a [[NixOS modules|NixOS module]], which makes it easy to break your configuration into several files. Modules can:
模块可以:
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
* 导入其他模块
* Import other modules
* 声明新的选项
* Declare new options
* 为选项设定值(这就是你的默认configuration.nix主要做的事情)
* Provide values for options (this is what most of your default configuration.nix does)
* 从其他模块引用选项的值(通过传给所有模块的<code>config</code>属性)
* Reference option values from other modules (via the <code>config</code> attribute passed to all modules)
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
只要你为任何你想在模块之间共享的值声明了选项, 你就可以按照你的喜好, 把你的配置分开放入文件, 这些文件直接地或间接地从你的根文件configuration.nix导入. 你也可以使用<code>builtins.fetchTarball</code>这样的函数从远程源导入模块. 查看[[NixOS modules|wiki页面]]或者[https://nixos.org/manual/nixos/stable/#sec-writing-modules NixOS手册]来获取更多信息.
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 <code>builtins.fetchTarball</code>. See the [[NixOS modules|wiki page]] or the [https://nixos.org/manual/nixos/stable/#sec-writing-modules NixOS manual] for more information.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<span id="With_Flakes"></span>
=== With Flakes ===
=== 通过Flakes ===
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
如果你想要可组合性<sup>[citation needed]</sup>更强的NixOS配置设定, 仍在实验阶段的[[Flakes]]特性正在使社区感到十分兴奋. 管理flakes需要对Nix生态有良好的基本理解和一些已有的实践经验.
If you want a more composable<sup>[citation needed]</sup> 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.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<span id="Video_guide"></span>
==== Video guide ====
==== 视频指南 ====
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
Wil T的原始8期视频系列的[[Wil_T_Nix_Guides#Intro_to_Flakes|第七集]][[Wil_T_Nix_Guides#Moving_NixOS_System_Configuration_into_a_Flake|第八集]]是对Flakes能做什么以及如何上手Flakes的很好的总览.
Videos [[Wil_T_Nix_Guides#Intro_to_Flakes|seven]] and [[Wil_T_Nix_Guides#Moving_NixOS_System_Configuration_into_a_Flake|eight]] of Wil T's original 8-part series are a good overview of what Flakes enable and how to get started with them.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<span id="Beyond_initial_setup"></span>
== Beyond initial setup ==
== 在初始设置之外 ==
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
在你熟悉了Nix生态并安装了一个功能性的NixOS桌面后, 你可能会想了解定制化和更细化的设置.
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.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<span id="Learn_by_example"></span>
=== Learn by example ===
=== 通过示例来学习 ===
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
如果你喜欢使用flakes通过一个git仓库来管理你的系统, 那么现在就有很多可供你学习的仓库!  
If you are comfortable managing your system through a git repo using flakes, then there are many repositories you can learn from now!
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
[[Comparison of NixOS setups|对NixOS设置的比较]]中可查看一个对常见选择进行比较的表格.
Check out [[Comparison of NixOS setups]] for a table comparing some popular choices.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
[[Configuration Collection|配置集合]]中可看到wiki内部的一个长列表.
See [[Configuration Collection]] for a long list within the wiki.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
此外, 在Github上进行如下的主题搜索应该可以发现许多有用的示例.
Additionally, the following topic searches on Github should uncover many useful examples.
* nix-flake
* [https://github.com/topics/nix-flake nix-flake]
* nixos-configuration
* [https://github.com/topics/nixos-configuration nixos-configuration]
* nixos-dotfiles
* [https://github.com/topics/nixos-dotfiles nixos-dotfiles]
</div>


[[Category:Desktop]]
[[Category:Desktop]]
[[Category:Guide]]
[[Category:Guide]]

Latest revision as of 12:17, 25 February 2025

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的介绍和设置指南.

模块化你的配置

通过NixOS模块

configuration.nix是NixOS模块的一个实例, 因此把你的配置分开放入若干文件中很容易. 模块可以:

  • 导入其他模块
  • 声明新的选项
  • 为选项设定值(这就是你的默认configuration.nix主要做的事情)
  • 从其他模块引用选项的值(通过传给所有模块的config属性)

只要你为任何你想在模块之间共享的值声明了选项, 你就可以按照你的喜好, 把你的配置分开放入文件, 这些文件直接地或间接地从你的根文件configuration.nix导入. 你也可以使用builtins.fetchTarball这样的函数从远程源导入模块. 查看wiki页面或者NixOS手册来获取更多信息.

通过Flakes

如果你想要可组合性[citation needed]更强的NixOS配置设定, 仍在实验阶段的Flakes特性正在使社区感到十分兴奋. 管理flakes需要对Nix生态有良好的基本理解和一些已有的实践经验.

视频指南

Wil T的原始8期视频系列的第七集第八集是对Flakes能做什么以及如何上手Flakes的很好的总览.

在初始设置之外

在你熟悉了Nix生态并安装了一个功能性的NixOS桌面后, 你可能会想了解定制化和更细化的设置.

通过示例来学习

如果你喜欢使用flakes通过一个git仓库来管理你的系统, 那么现在就有很多可供你学习的仓库!

对NixOS设置的比较中可查看一个对常见选择进行比较的表格.

配置集合中可看到wiki内部的一个长列表.

此外, 在Github上进行如下的主题搜索应该可以发现许多有用的示例.

  • nix-flake
  • nixos-configuration
  • nixos-dotfiles