|
|
| (55 intermediate revisions by 4 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> | | <span id="Managing_your_configuration"></span> |
| === 视频指南 ===
| | == 管理你的配置 == |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <div class="mw-translate-fuzzy"> |
| 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.
| | 你可以使用[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> | | </div> |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | 关于如何管理配置,请参阅 {{NixOS Manual|name=NixOS 官方手册|anchor=#ch-configuration}}。 |
| == Managing your configuration == | | |
| | <span id="System_Configuration"></span> |
| | === 系统配置 === |
| | |
| | {{main|NixOS 系统配置}} |
| | |
| | <code>/etc/nixos/configuration.nix</code>是主配置文件,用于定义系统级设置。其中包括启用服务、管理系统用户、配置硬件选项以及指定安装的软件包。 |
| | 若要使更改生效,请运行: |
| | |
| | <syntaxhighlight lang="console"> |
| | # nixos-rebuild switch |
| | </syntaxhighlight> |
| | |
| | <span id="User_configuration_with_Home_Manager"></span> |
| | === 使用 Home Manager 管理用户配置 === |
| | |
| | 针对应用程序偏好设置、命令行工具以及 dotfiles 等用户级配置的管理,[[Home Manager]] 提供了一种便捷的声明式方案。 |
| | |
| | 它允许用户自行定义需要安装的程序及其具体配置方式,而无需将这些设置写入系统级的 [https://nixos.org/manual/nixos/stable/#sec-changing-config configuration.nix] 中。 |
| | |
| | Home Manager 可以独立于系统配置使用,既支持传统设置,也支持基于 [[Flakes]] 的新式配置。 |
| | |
| | <span id="With_Flakes"></span> |
| | === 通过Flakes === |
| | |
| | <div class="mw-translate-fuzzy"> |
| | 如果你想要可组合性<sup>[citation needed]</sup>更强的NixOS配置设定, 仍在实验阶段的[[Flakes]]特性正在使社区感到十分兴奋. 管理flakes需要对Nix生态有良好的基本理解和一些已有的实践经验. |
| </div> | | </div> |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | 关于如何开始的详细信息,请参考 [[NixOS system configuration#Defining NixOS as a flake]]。 |
| 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]]
| | |
| | <span id="Beyond_initial_setup"></span> |
| | == 在初始设置之外 == |
| | |
| | <div class="mw-translate-fuzzy"> |
| | 在你熟悉了Nix生态并安装了一个功能性的NixOS桌面后, 你可能会想了解定制化和更细化的设置. |
| </div> | | </div> |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | 常见配置项包含: |
| === Video guide === | | |
| </div>
| | <span id="Desktop_Environments"></span> |
| | ==== 桌面环境 ==== |
| | |
| | 安装并配置功能完备的桌面环境,如 [[GNOME]]、[[KDE Plasma]] 或 [[Xfce]]。 |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | 完整列表请参阅 [[:Category:Desktop environment]]。 |
| Wil T's guides are about an even mix of:
| |
| # Hands-on bootstrapping to get to being able to very capably manage your system using Home Manager, git versioning, and eventually Flakes.
| |
| # Conceptual overviews and general exposition of the Nix ecosystem, community, and available resources.
| |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <span id="Window_Managers"></span> |
| 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">
| | 设置 [[i3]]、[[Sway]]、[[Hyprland]] 或 [[xmonad]] 等轻量级或平铺式窗口管理器。 |
| == Modularizing your configuration ==
| |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr">
| | 完整列表请参阅 [[:Category:Window managers]]。 |
| === With NixOS Modules ===
| |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <span id="Display_Managers_(Login_Managers)"></span> |
| 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">
| | 配置图形会话管理器,例如 [[Gnome|GDM]]、[[KDE|SDDM]] 或 [[LightDM]]。 |
| * 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 <code>config</code> attribute passed to all modules)
| |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <span id="Audio_Setup"></span> |
| 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">
| | 启用并配置 [[:Category:Audio|音频]] 系统,例如 [[PipeWire]]、[[PulseAudio]] 或 [[ALSA]]。 |
| === With Flakes ===
| |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <span id="Network_Management"></span> |
| 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">
| | 使用诸如 [[NetworkManager]] 或 [[systemd-networkd]] 的工具来管理 [[Networking|网络]] 连接。 |
| ==== Video guide ====
| |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <span id="Bluetooth_Support"></span> |
| 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">
| | 使用 blueman 或其他工具配置与管理[[Bluetooth|蓝牙]]。 |
| == Beyond initial setup ==
| |
| </div>
| |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <span id="Power_Management"></span> |
| 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">
| | 使用诸如 [[Laptop#tlp|tlp]] 或 [[systemd]] 服务等工具配置 [[laptop|笔记本]] 的 [[Power Management|电池管理]]、挂起与休眠。 |
| === Learn by example ===
| |
| </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!
| | ==== Printing and Scanning ==== |
| </div> | | </div> |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | 启用 [[Cups]] 以支持打印机,并使用诸如 Sane 的工具来支持 [[Scanners|扫描]] 设备。 |
| Check out [[Comparison of NixOS setups]] for a table comparing some popular choices.
| | |
| </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}} |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <span id="See_also"></span> |
| See [[Configuration Collection]] for a long list within the wiki.
| | == 另见 == |
| </div> | |
|
| |
|
| <div lang="en" dir="ltr" class="mw-content-ltr"> | | <div class="mw-translate-fuzzy"> |
| Additionally, the following topic searches on Github should uncover many useful examples.
| | 在[[Comparison of NixOS setups|对NixOS设置的比较]]中可查看一个对常见选择进行比较的表格. |
| * [https://github.com/topics/nix-flake nix-flake]
| |
| * [https://github.com/topics/nixos-configuration nixos-configuration]
| |
| * [https://github.com/topics/nixos-dotfiles nixos-dotfiles]
| |
| </div> | | </div> |
|
| |
|
| [[Category:Desktop]] | | [[Category:Desktop|分类:桌面]] |
| [[Category:Guide]] | | [[Category:Guide|分类:指南]] |
| | [[Category:NixOS|分类:NixOS]] |