NixOS as a desktop/zh: Difference between revisions

Mayer (talk | contribs)
Created page with "只要你为任何你想在模块之间共享的值声明了选项, 你就可以按照你的喜好, 把你的配置分开放入文件, 这些文件直接地或间接地从你的根文件configuration.nix导入. 你也可以使用<code>builtins.fetchTarball</code>这样的函数从远程源导入模块. 查看wiki页面或者[https://nixos.org/manual/nixos/stable/#sec-writing-modules NixOS手册]来获取更多信息."
Ardenet (talk | contribs)
No edit summary
 
(19 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<languages/>
<languages/>
NixOS可以用于许多目的. 如果你想把它用你的日常主要桌面操作系统(实体机上或者作为副虚拟机), 那么你应该看看这个页面. 即使你是想把NixOS用在云端或者是经过特殊配置的服务器上, 你也可能会从这里概述的课程开始, 以便从整体上对Nix生态有更好了解.
[[Special:MyLanguage/NixOS|NixOS]] 是一款功能多样的操作系统,适用于各种用例。本文面向希望将 NixOS 主要桌面环境(无论是物理硬件还是虚拟机中)的户。此外,计划[[NixOS friendly hosters|云端]] 环境专用服务器基础架构部署 NixOS 的用户,可能会发现从这里介绍的念和实践开始会很有帮助,因为它们为在更广泛的 [[Special:MyLanguage/Nix ecosystem|Nix 生态系统]] 中工作奠定了基础。


<span id="Installation"></span>
<span id="Installation"></span>
== 安装 ==
== 安装 ==


<span id="Wiki_method"></span>
<div class="mw-translate-fuzzy">
=== Wiki(维基百科)上的方法 ===
 
如果你倾向于阅读, 请从[[NixOS Installation Guide|NixOS安装指南]]开始. 如果你想选择一个精良的视频教程, 请见下一条. 请记住, 为了安装一个桌面, 你需要确定一开始有至少30GiB的可用硬盘空间来容纳桌面环境(比如说, GNOME, KDE, 或者是XFCE), 浏览器(比如Firefox), 以及其他带有图形界面的典型日用软件(如VSCode). 对于相对简陋的配置, 15GiB可能够用.
如果你倾向于阅读, 请从[[NixOS Installation Guide|NixOS安装指南]]开始. 如果你想选择一个精良的视频教程, 请见下一条. 请记住, 为了安装一个桌面, 你需要确定一开始有至少30GiB的可用硬盘空间来容纳桌面环境(比如说, GNOME, KDE, 或者是XFCE), 浏览器(比如Firefox), 以及其他带有图形界面的典型日用软件(如VSCode). 对于相对简陋的配置, 15GiB可能够用.
 
</div>
<span id="Video_guide"></span>
=== 视频指南 ===
 
如果想要一个可视化指南, 请看[[Wil T Nix Guides]]. 其中[[Wil_T_Nix_Guides#NixOS_Installation_Guide|第二个视频]]是一个简洁的安装指南. 这个8期视频系列于2021年初制作, 也涵盖了从把NixOS用作桌面到根据你的喜好来配置它的所有基本内容.


<span id="Managing_your_configuration"></span>
<span id="Managing_your_configuration"></span>
== 管理你的配置 ==
== 管理你的配置 ==


<div class="mw-translate-fuzzy">
你可以使用[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]].
你可以使用[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]].
</div>


<span id="Video_guide"></span>
<div lang="en" dir="ltr" class="mw-content-ltr">
=== 视频指南 ===
The process for managing your configuration is documented in the {{NixOS Manual|name=NixOS official manual|anchor=#ch-configuration}}.
</div>


Wil T的指南是下列内容的均衡组合:
<div lang="en" dir="ltr" class="mw-content-ltr">
# 动手实践的引导, 让你逐步学会使用Home Manager, git版本控制,以及最后的Flakes来掌握你的系统
=== System Configuration ===
# Nix生态, 社区, 以及可用资源的概念总览和总体介绍
</div>


其中[[Wil_T_Nix_Guides#NixOS_Installation_Guide|第二个视频]], 从大概27分钟开始, 也是对Home Manager的介绍和设置指南.
<div lang="en" dir="ltr" class="mw-content-ltr">
{{main|NixOS system configuration}}
</div>


<span id="Modularizing_your_configuration"></span>
<div lang="en" dir="ltr" class="mw-content-ltr">
== 模块化你的配置 ==
The primary configuration file, <code>/etc/nixos/configuration.nix</code>, defines system-wide settings. This includes options like enabling services, managing system users, setting hardware options, and specifying installed packages. Changes are applied with:
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
=== With NixOS Modules ===
<syntaxhighlight lang="console">
# nixos-rebuild switch
</syntaxhighlight>
</div>
</div>


configuration.nix是[[NixOS modules|NixOS模块]]的一个实例, 因此把你的配置分开放入若干文件中很容易.
<div lang="en" dir="ltr" class="mw-content-ltr">
模块可以:
=== User configuration with Home Manager ===
</div>


* 导入其他模块
<div lang="en" dir="ltr" class="mw-content-ltr">
* 声明新的选项
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 [https://nixos.org/manual/nixos/stable/#sec-changing-config configuration.nix].
* 为选项设定值(这就是你的默认configuration.nix主要做的事情)
</div>
* 从其他模块引用选项的值(通过传给所有模块的<code>config</code>属性)
 
<div lang="en" dir="ltr" class="mw-content-ltr">
Home Manager can be used independently of the system configuration and works with both traditional setups and newer [[Flakes]]-based configurations.
</div>
 
<span id="With_Flakes"></span>
=== 通过Flakes ===


只要你为任何你想在模块之间共享的值声明了选项, 你就可以按照你的喜好, 把你的配置分开放入文件, 这些文件直接地或间接地从你的根文件configuration.nix导入. 你也以使用<code>builtins.fetchTarball</code>这样函数从远程源导入模块. 查看[[NixOS modules|wiki页面]]或者[https://nixos.org/manual/nixos/stable/#sec-writing-modules NixOS手册]来获取更多信息.
<div class="mw-translate-fuzzy">
如果你想组合性<sup>[citation needed]</sup>更强的NixOS配置设定, 仍在实验阶段的[[Flakes]]特性正在使社区感到十分兴奋. 管理flakes需要对Nix生态有良好的基本理解和一些已有的实践经验.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
=== With Flakes ===
Refer to [[NixOS system configuration#Defining NixOS as a flake]] for details on getting started.
</div>
 
<span id="Beyond_initial_setup"></span>
== 在初始设置之外 ==
 
<div class="mw-translate-fuzzy">
在你熟悉了Nix生态并安装了一个功能性的NixOS桌面后, 你可能会想了解定制化和更细化的设置.
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
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.
Common configuration areas include:
</div>
</div>


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


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
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.
Install and configure full-featured environments such as [[GNOME]], [[KDE Plasma]], or [[Xfce]].
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
== Beyond initial setup ==
See [[:Category:Desktop environment]] for a full list.
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
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.
==== Window Managers ====
</div>
</div>


<span id="Learn_by_example"></span>
<div lang="en" dir="ltr" class="mw-content-ltr">
=== 通过示例来学习 ===
Set up lightweight or tiling window managers like [[i3]], [[Sway]], [[Hyprland]], or [[xmonad]].
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
See [[:Category:Window managers]] for a full list.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
If you are comfortable managing your system through a git repo using flakes, then there are many repositories you can learn from now!
==== Display Managers (Login Managers) ====
</div>  
</div>  


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Check out [[Comparison of NixOS setups]] for a table comparing some popular choices.
Configure graphical session managers such as [[Gnome|GDM]], [[KDE|SDDM]], or [[LightDM]].
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
==== Audio Setup ====
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
Enable and configure [[:Category:Audio|audio]] systems like [[PipeWire]], [[PulseAudio]], or [[ALSA]].
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
==== Network Management ====
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
Use tools such as [[NetworkManager]] or [[systemd-networkd]] for managing [[Networking|network]] connections.
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
==== Bluetooth Support ====
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
See [[Configuration Collection]] for a long list within the wiki.
Set up [[Bluetooth]] with blueman or other management tools.
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Additionally, the following topic searches on Github should uncover many useful examples.
==== Power Management ====
* [https://github.com/topics/nix-flake nix-flake]
</div>
* [https://github.com/topics/nixos-configuration nixos-configuration]
 
* [https://github.com/topics/nixos-dotfiles nixos-dotfiles]
<div lang="en" dir="ltr" class="mw-content-ltr">
Configure [[laptop]] [[Power Management|battery management]], suspend, and hibernation with tools like [[Laptop#tlp|tlp]] or [[systemd]] services.
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
==== Printing and Scanning ====
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
Enable [[Cups]] for printer support and tools like Sane for [[Scanners|scanning]] devices.
</div>
 
<span id="Tips_and_tricks"></span>
== 提示和技巧 ==
 
<span id="Modularizing_your_configuration_with_modules"></span>
=== 通过 NixOS 模块机制模块化你的配置 ===
 
{{main|NixOS system configuration#Modularizing your configuration with modules}}
 
<span id="See_also"></span>
== 另见 ==
 
<div class="mw-translate-fuzzy">
在[[Comparison of NixOS setups|对NixOS设置的比较]]中可查看一个对常见选择进行比较的表格.
</div>
</div>


[[Category:Desktop]]
[[Category:Desktop|分类:桌面]]
[[Category:Guide]]
[[Category:Guide|分类:指南]]
[[Category:NixOS|分类:NixOS]]