User:芭樂哥/尼克斯操作系统

维基百科,自由的百科全书
NixOS
开发者NixOS contributors
NixOS Foundation[1][2]
编程语言Nix expression language[note 1]
作業系統家族Linux (Unix-like)
運作狀態Current
源码模式Open source
首次发布0.1 / 2003年6月3日,​20年前​(2003-June-03
市場取向General purpose
软件包管理系统Nix
支援平台i686, x86-64, AArch64
内核类别Monolithic (Linux kernel)
许可证MIT[3][note 2]
官方網站nixos.org

NixOS是一个基于纯功能性Nix 包管理器的自由开源Linux 发行版。 NixOS 使用nixpkgs项目中定义的模块和包组成。

NixOS 使用不可变设计和原子更新模型。 [4]它使用宣告式編程配置允许再现性和可移植性。 [5]

历史[编辑]

2003 年,Eelco Dolstra 启动了 NixOS 作为一个研究项目。 [6] [7] Dolstra 表示,该项目的目的是实现一个正确软件部署的系统。 [8] 2015年,NixOS基金会在荷兰成立,旨在支持像NixOS这样实现纯功能部署模型的项目。 [9]

版本[编辑]

发布版本历史记录[编辑]

Name Date
NixOS 13.10 "Aardvark" 2013年10月
NixOS 14.04 "Baboon" 2014年4月
NixOS 14.12 "Caterpillar" 2014年12月
NixOS 15.09 "Dingo" 2015年9月
NixOS 16.03 "Emu" 2016年3月
NixOS 16.09 "Flounder" 2016年9月
NixOS 17.03 "Gorilla" 2017年3月
NixOS 17.09 "Hummingbird" 2017年9月
NixOS 18.03 "Impala" 2018年3月
NixOS 18.09 "Jellyfish" 2018年9月
NixOS 19.03 "Koi" 2019年3月
NixOS 19.09 "Loris" 2019年9月
NixOS 20.03 "Markhor" 2020年3月
NixOS 20.09 "Nightingale" 2020年9月
NixOS 21.05 "Okapi" 2021年5月
NixOS 21.11 "Porcupine" 2021年11月
NixOS 22.05 "Quokka" 2022年5月
NixOS 22.11 "Raccoon" 2022年11月
NixOS 23.05 "Stoat" 2023年5月
NixOS 23.11 "Tapir" 2023年11月

NixOS 一年發布兩次新版本, 通常在五和十一月底.[10][11][12]

特色[编辑]

NixOS 图形化安装程式

声明式配置模型[编辑]

在 NixOS 中,整个操作系统(包括内核、应用程序、系统包和配置文件)由 Nix 包管理器根据Nix 语言的描述构建。构建新版本不会覆盖以前的版本。 [13]

NixOS 系统是通过在全局配置文件(通常位于/etc/nixos )中编写用户想要在其计算机上使用的功能规范来配置的。以下是运行 SSH 守护程序的机器的最低规格: [14]

{
  boot.loader.grub.device = "/dev/sda";
  fileSystems."/".device = "/dev/sda1";
  services.sshd.enable = true;
}

更改规范文件后,可以使用 nixos-rebuild 命令更新系统。这会执行创建新版本系统所需的一切,包括下载和安装软件包以及生成配置文件。

可靠的原子升级[编辑]

由于 Nix 文件是纯函数式编程宣告式編程文件,因此无论系统上有什么包或配置文件,它们总是会产生相同的结果。

NixOS 采用事务性方法进行配置管理,使升级等配置更改成为原子操作。例如,如果升级到新配置因电源故障而中断,系统仍将处于一致状态:它将以旧配置或新配置启动。 [15]

回滚[编辑]

在系统更新后,可以使用特殊命令( nixos-rebuild switch --rollback )进行回滚。每个系统配置版本都会自动显示在系统启动菜单中。如果新配置崩溃或无法正常启动,则可以选择旧版本。回滚是轻量级操作,不涉及从副本恢复文件。 [16]

可重复的系统配置[编辑]

NixOS 的宣告式編程配置模型可以轻松地在另一台机器上重现系统配置。将配置文件复制到目标计算机并运行系统更新命令会生成相同的系统配置(内核、应用程序、系统服务等),但系统中不由包管理器管理的部分(例如用户数据)除外。

具有二进制缓存的基于源始碼的模型[编辑]

NixOS 使用的 Nix 构建语言指定了如何从源代码构建包。这使得系统可以轻松地适应用户需求。然而,从源代码构建是一个缓慢的过程,套件管理器会在预构建的二进制文件可用时自动从缓存服务器下载它们。可以通过使用--option substitute false作为参数来禁用二进制缓存并强制从源代碼构建。这提供了基于源代碼的套件管理模型的灵活性和二进制模型的效率。 [17]

一致性[编辑]

Nix包管理器确保正在运行的系统与系统的逻辑规范一致,这意味着它将重建所有需要重建的包。例如,如果内核发生更改,则包管理器将确保重建外部内核模块。同样,当库更新时,它确保所有系统包都使用新版本,甚至静态链接到它的包。

多用户套件管理[编辑]

在 NixOS 中安裝軟體不需要特殊權限。除了系統範圍的設定檔之外,每個使用者還有一個可以在其中安裝軟體包的專用設定檔。 Nix 還允許套件的多個版本共存,因此不同的使用者可以在各自的設定檔中安裝相同套件的不同版本。如果兩個使用者安裝相同版本的軟體包,則只會建置或下載一份副本。 Nix 的安全模型確保這是安全的,因為只有系統配置明確信任的使用者才被允許使用建置參數,這些參數允許他們控制派生輸出的內容(例如在沙箱中添加雜質,或使用不受信任的替代者)。 如果沒有這些參數,則只能從系統信任的替代者或隱式信任的本地沙盒建構中替換路徑。

执行[编辑]

NixOS 基于Nix 包管理器,它将所有包相互隔离地存储在包存储中。 安裝的包由用於其構建的所有輸入的加密雜湊值來標識。更改套件的建置指令會修改其雜湊值,這將導致在套件儲存中安裝不同的套件。該系統還用於管理配置文件,確保新的配置不會覆蓋舊的配置。 这意味着 NixOS 不遵循文件系统层次结构标准。唯一的例外是/bin/sh符号链接被创建到 Nix 存储中的bash版本(例如/nix/store/s/5rnfzla9kcx4mj5zdc7nlnv8na1najvg-bash-4.3.43/ ),而 NixOS 确实有一个/etc目录为了保留系统范围的配置文件,该目录中的大多数文件都是/nix/store中生成的文件的符号链接,例如/nix/store/s2sjbl85xnrc18rl4fhn56irkxqxyk4p-sshd_config 。不使用/bin等全局目录是允许包的多个版本共存的一部分。

評論[编辑]

Jesse Smith 在 2015 年为 DistroWatch Weekly 评论 NixOS 15.09, [18]写道:

I very much like the way NixOS takes the worry out of upgrading packages by placing each change in its own "generation" and I found, from the end user's point of view, NixOS worked just the same as any other Linux distribution. Setting up NixOS is not for beginners, and I do not think NixOS is intended to be used as a general purpose desktop operating system. But what NixOS does do is give us a useful playground in which to examine the Nix package manager and I think this is very interesting technology which deserves further exploration and adoption by additional distributions.

《Full Circle》杂志2022 年对 NixOS 21.11“Porcupine”的评论是:

Overall NixOS Gnome 21.11 impresses as serious, neat and elegant. If you are a fan of the unmodified Gnome desktop, then you will find a lot to like here. The downside of this distribution is the steep learning curve for package management, including updates and the like. No matter which distribution you come from, you will have much to learn to be able to make Nix work well for you on the command-line.[19]

NixOS 22.11“Raccoon”由 Liam 在The Register上評論:

Compared to reports of NixOS from just two or three years ago, we found it was very simple to get it installed and working. This suggests that the tools are maturing well and reaching a certain level of polish, but from a first-time perspective we have no prior baseline to compare against. This is very much not a traditional distro, or even a traditional Unix, but it works and we can see the appeal.[20]

註解[编辑]

  1. ^ Various other programming languages are used throughout NixOS (as of December 2023).
  2. ^ Various other licenses are used for software included with NixOS, for example the Linux kernel is licensed under the GNU GPL version 2.0 (as of December 2023)

其他[编辑]

  • GNU Guix System – 一个基于GNU Guix构建的操作系统,灵感来自 Nix
  • Eelco Visser - 没有他,Eelco Dolstra 可能永远不会开始 有關 Nix 包管理器的工作[21]

参考資料[编辑]

  1. ^ Community - nixos.org. [2022-09-23]. (原始内容存档于2022-09-23). 
  2. ^ NixOS/nixos-foundation - Github. GitHub. [2022-09-23]. (原始内容存档于2022-09-23). 
  3. ^ nixpkgs/COPYING at master · NixOS/nixpkgs · GitHub. Github.com. [2015-09-19]. 
  4. ^ What Is an Immutable Linux Distro, and Should You Use One?. HowToGeek.com. [2023-12-07]. (原始内容存档于2023-12-07). 
  5. ^ DistroWatch.com: NixOS. Distrowatch.com. [2015-09-19]. 
  6. ^ Dolstra, Eelco. https://web.archive.org/web/20190421081837/https://nixos.org/~eelco/pubs/iscsd-scm11-final.pdf |archiveurl=缺少标题 (帮助) (PDF). Integrating Software Construction and Software Deployment. Lecture Notes in Computer Science 2649. 2003: 102–117. ISBN 978-3-540-14036-8. doi:10.1007/3-540-39195-9_8. (原始内容 (PDF)存档于2019-04-21). 
  7. ^ Dolstra, Eelco. The Purely Functional Software Deployment Model (PDF) (Ph.D.论文). 2006. 
  8. ^ Jonatha Lorimer. The Nix Thesis. 
  9. ^ Stichting NixOS Foundation. Nixos.org. [2015-09-19]. 
  10. ^ Governance. Nixos.org. [2020-08-28]. (原始内容存档于2020-08-16). 
  11. ^ Nix RFCS (Request for Comments). GitHub. 17 December 2021. 
  12. ^ Release Announcements. Nixos.org. [2023-12-09]. 
  13. ^ Dolstra, Eelco; Hemel, Armijn. Purely Functional System Configuration Management (PDF). 11th USENIX workshop on Hot topics in operating systems. San Diego, California, USA: USENIX Association. 2007-05-07 [2023-07-19]. (原始内容 (PDF)存档于2020-07-10). 
  14. ^ About NixOS. Nixos.org. [2015-09-19]. 
  15. ^ van der Burg, Sander; Dolstra, Eelco; de Jonge, Merijn. Atomic Upgrading of Distributed Systems (PDF). 1st International Workshop on Hot Topics in Software Upgrades. Nashville, Tennessee, USA: Association for Computing Machinery. 2008-10-20 [2023-07-19]. ISBN 978-1-60558-304-4. doi:10.1145/1490283.1490294. (原始内容 (PDF)存档于2021-11-13). 
  16. ^ NixOS Manual - Rolling Back Configuration Changes, Nixos.org 
  17. ^ Dolstra, Eelco. Secure Sharing Between Untrusted Users in a Transparent Source/Binary Deployment Model (PDF). 20th IEEE/ACM International Conference on Automated Software Engineering. Long Beach, California, USA: Association for Computing Machinery. 2005-11-07 [2023-07-19]. ISBN 978-1-58113-993-8. doi:10.1145/1101908.1101933. (原始内容 (PDF)存档于2021-11-13). 
  18. ^ DistroWatch Weekly, Issue 637, 23 November 2015
  19. ^ Hunt, Adam. Review - NixOS (PDF). Full Circle magazine. 28 October 2022 [28 October 2022]. (原始内容存档 (PDF)于28 October 2022). 
  20. ^ Proven, Liam. NixOS 22.11 'Raccoon': Like a proof of concept you can do things with OSes. 
  21. ^ In memoriam: Eelco Visser (1966-2022). 

[[Category:操作系统安全]] [[Category:Linux發行版]]