FAQ/zh: Difference between revisions
No edit summary |
Updating to match new version of source page |
||
| Line 1: | Line 1: | ||
<languages/> | <languages/> | ||
<div class="mw-translate-fuzzy"> | |||
为了避免重复回答那些经常被问到的问题以及处理新手常遇到的麻烦,这些问题被收录在这里。 | 为了避免重复回答那些经常被问到的问题以及处理新手常遇到的麻烦,这些问题被收录在这里。 | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
| Line 7: | Line 9: | ||
<span id="Why_is_there_a_new_wiki?_What_is_with_nixos.wiki?"></span> | <span id="Why_is_there_a_new_wiki?_What_is_with_nixos.wiki?"></span> | ||
<div class="mw-translate-fuzzy"> | |||
== 为什么创建了一个新的维基?nixos.wiki 怎么了? == | == 为什么创建了一个新的维基?nixos.wiki 怎么了? == | ||
</div> | |||
旧的 wiki(nixos.wiki)存在以下几个问题: | 旧的 wiki(nixos.wiki)存在以下几个问题: | ||
| Line 19: | Line 23: | ||
* 维基的基础设施本应在上线后公开,但最终未能公开。 | * 维基的基础设施本应在上线后公开,但最终未能公开。 | ||
<div class="mw-translate-fuzzy"> | |||
我们曾通过多种渠道(电子邮件、Matrix)多次尝试解决这些问题,历时多年,但始终未能得到直接答复。最后一次联系是由 zimbatm 代表 NixOS 基金会与维护者沟通,询问关于新维基合作的可能性。答案是否定的。随着旧维基不断恶化且维护者未作回应,将内容分叉到一个新维基成为了唯一的解决方法。 | 我们曾通过多种渠道(电子邮件、Matrix)多次尝试解决这些问题,历时多年,但始终未能得到直接答复。最后一次联系是由 zimbatm 代表 NixOS 基金会与维护者沟通,询问关于新维基合作的可能性。答案是否定的。随着旧维基不断恶化且维护者未作回应,将内容分叉到一个新维基成为了唯一的解决方法。 | ||
</div> | |||
另请参阅: | 另请参阅: | ||
| Line 26: | Line 32: | ||
<span id="Why_is_Nix_written_in_C++_rather_than_a_functional_language_like_Haskell?"></span> | <span id="Why_is_Nix_written_in_C++_rather_than_a_functional_language_like_Haskell?"></span> | ||
<div class="mw-translate-fuzzy"> | |||
== 为什么 Nix 是用 C++ 编写的,而不是像 Haskell 这样的函数式语言? == | == 为什么 Nix 是用 C++ 编写的,而不是像 Haskell 这样的函数式语言? == | ||
</div> | |||
主要是因为 Nix 旨在轻量级、易于学习且具有良好的可移植性(零依赖)。 | 主要是因为 Nix 旨在轻量级、易于学习且具有良好的可移植性(零依赖)。 | ||
<span id="How_to_keep_build-time_dependencies_around_/_be_able_to_rebuild_while_being_offline?"></span> | <span id="How_to_keep_build-time_dependencies_around_/_be_able_to_rebuild_while_being_offline?"></span> | ||
<div class="mw-translate-fuzzy"> | |||
== 如何保留构建时依赖 / 在离线状态下重新构建? == | == 如何保留构建时依赖 / 在离线状态下重新构建? == | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
| Line 74: | Line 84: | ||
<span id="Why_-_instead_of_-?"></span> | <span id="Why_-_instead_of_-?"></span> | ||
<div class="mw-translate-fuzzy"> | |||
== 为什么使用 <hash>-<name> 而不是 <name>-<hash>? == | == 为什么使用 <hash>-<name> 而不是 <name>-<hash>? == | ||
</div> | |||
在少数需要深入查看 /nix/store 的情况下,将哈希值的前几位放在开头更方便记忆和使用。 | 在少数需要深入查看 /nix/store 的情况下,将哈希值的前几位放在开头更方便记忆和使用。 | ||
| Line 105: | Line 117: | ||
<span id="I've_updated_my_channel_and_something_is_broken,_how_can_I_rollback_to_an_earlier_channel?"></span> | <span id="I've_updated_my_channel_and_something_is_broken,_how_can_I_rollback_to_an_earlier_channel?"></span> | ||
<div class="mw-translate-fuzzy"> | |||
== 我更新了我的 channel,但出现了问题,如何回滚到之前的 channel? == | == 我更新了我的 channel,但出现了问题,如何回滚到之前的 channel? == | ||
</div> | |||
查看可用的各代 channel: | 查看可用的各代 channel: | ||
| Line 133: | Line 147: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
== I'm working on a new package, how can I build it without adding it to nixpkgs? == | === I'm working on a new package, how can I build it without adding it to nixpkgs? === | ||
</div> | </div> | ||
| Line 142: | Line 156: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
== How can I compile a package with debugging symbols included? == | === How can I compile a package with debugging symbols included? === | ||
</div> | </div> | ||
| Line 158: | Line 172: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
== How can I force a rebuild from source even without modifying the nix expression? == | === How can I force a rebuild from source even without modifying the nix expression? === | ||
</div> | </div> | ||
| Line 167: | Line 181: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
<syntaxhighlight lang="bash">sudo nix-build --check -A ncdu</syntaxhighlight> | <syntaxhighlight lang="bash">sudo nix-build --check -A ncdu</syntaxhighlight> | ||
== How can I manage software with nix-env like with configuration.nix? == | === How can I manage software with nix-env like with configuration.nix? === | ||
</div> | </div> | ||
| Line 204: | Line 218: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
== I've downloaded a binary, but I can't run it, what can I do? == | === I've downloaded a binary, but I can't run it, what can I do? === | ||
Binaries normally do not work out of the box when you download them because they normally just assume that libraries can be found in hardcoded paths such as <code>/lib</code>. However this assumption is incorrect on NixOS systems due to the inner workings of <code>nix</code> - there is no default path, everything gets set to the corresponding version on compile time. | Binaries normally do not work out of the box when you download them because they normally just assume that libraries can be found in hardcoded paths such as <code>/lib</code>. However this assumption is incorrect on NixOS systems due to the inner workings of <code>nix</code> - there is no default path, everything gets set to the corresponding version on compile time. | ||
</div> | </div> | ||
| Line 240: | Line 254: | ||
programs.nix-ld = { | programs.nix-ld = { | ||
enable = true; | enable = true; | ||
libraries = pkgs.steam-run | libraries = pkgs.steam-run.args.multiPkgs pkgs; | ||
};</syntaxhighlight> | };</syntaxhighlight> | ||
</div> | </div> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
This uses the libraries that are used by [[Steam]] to simulate a traditional Linux FHS environment to run games in. It's a [https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/ | This uses the libraries that are used by [[Steam]] to simulate a traditional Linux FHS environment to run games in. It's a [https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/by-name/st/steam/package.nix big list] that usually contains all the libraries your binary needs to run. | ||
</div> | </div> | ||
| Line 315: | Line 329: | ||
<br> | <br> | ||
If your target application can't find shared libraries inside buildFHSUserEnv, you may run [https://github.com/lexleogryfon/de-generate nix-de-generate] for target application inside FHS, which will generate newenv.nix file, an nix-expression of buildFHSUserEnv with resolved dependencies for shared libraries. | If your target application can't find shared libraries inside buildFHSUserEnv, you may run [https://github.com/lexleogryfon/de-generate nix-de-generate] for target application inside FHS, which will generate newenv.nix file, an nix-expression of buildFHSUserEnv with resolved dependencies for shared libraries. | ||
== What are channels and how do they get updated? == | </div> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
=== What are channels and how do they get updated? === | |||
{{main|Channel branches}} | {{main|Channel branches}} | ||
</div> | </div> | ||
| Line 370: | Line 387: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
== How do I know where's nixpkgs channel located and at which commit? == | === How do I know where's nixpkgs channel located and at which commit? === | ||
</div> | </div> | ||
| Line 387: | Line 404: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
== Nixpkgs branches == | === Nixpkgs branches === | ||
Branches on the nixpkgs repo have a relationship with channels, but that relationship is not 1:1. | Branches on the nixpkgs repo have a relationship with channels, but that relationship is not 1:1. | ||
</div> | </div> | ||
| Line 405: | Line 422: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
== There's an updated version for $software on nixpkgs but not in channels, how can I use it? == | === There's an updated version for $software on nixpkgs but not in channels, how can I use it? === | ||
</div> | </div> | ||
| Line 419: | Line 436: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
== How do I install a specific version of a package for build reproducibility etc.? == | === How do I install a specific version of a package for build reproducibility etc.? === | ||
</div> | </div> | ||
| Line 431: | Line 448: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
== An error occurs while fetching sources from an url, how do I fix it? == | === An error occurs while fetching sources from an url, how do I fix it? === | ||
</div> | </div> | ||
| Line 439: | Line 456: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
If that fails you can update the url in the nix expression yourself. [ | If that fails you can update the url in the nix expression yourself. [[#How_do_I_know_where's_nixpkgs_channel_located_and_at_which_commit?|Navigate to your channel's expressions]] and find the package in one of the subdirectories. Edit the respective ''default.nix'' file by altering the ''url'' and ''sha256''. You can use <code>nix-prefetch-url url</code> to get the SHA-256 hash of source distributions. | ||
</div> | </div> | ||
| Line 471: | Line 488: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
== How do I know the sha256 to use with fetchgit, fetchsvn, fetchbzr or fetchcvs? == | === How do I know the sha256 to use with fetchgit, fetchsvn, fetchbzr or fetchcvs? === | ||
</div> | </div> | ||
| Line 491: | Line 508: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
== Should I use http://hydra.nixos.org/ as a binary cache? == | === Should I use http://hydra.nixos.org/ as a binary cache? === | ||
</div> | </div> | ||
| Line 499: | Line 516: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
== I'm trying to install NixOS but my WiFi isn't working and I don't have an ethernet port == | === I'm trying to install NixOS but my WiFi isn't working and I don't have an ethernet port === | ||
</div> | </div> | ||
| Line 515: | Line 532: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
== How can I disable the binary cache and build everything locally? == | === How can I disable the binary cache and build everything locally? === | ||
</div> | </div> | ||
| Line 531: | Line 548: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
== How do I enable sandboxed builds on non-NixOS? == | === How do I enable sandboxed builds on non-NixOS? === | ||
</div> | </div> | ||
| Line 558: | Line 575: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
== How can I install a package from unstable while remaining on the stable channel? == | === How can I install a package from unstable while remaining on the stable channel? === | ||
</div> | </div> | ||
| Line 619: | Line 636: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
== I'm unable to connect my USB HDD | External HDD is failing to mount automatically == | === I'm unable to connect my USB HDD | External HDD is failing to mount automatically === | ||
</div> | </div> | ||
| Line 652: | Line 669: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
== What is the origin of the name "Nix" == | === What is the origin of the name "Nix" === | ||
</div> | </div> | ||
| Line 660: | Line 677: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
== What does it mean to say that NixOS is "immutable" == | === What does it mean to say that NixOS is "immutable" === | ||
Immutability is a property of data, in general, which means that the data cannot be modified after it is created. In the context of an operating system, it really means that certain parts of the system have this property. In the case of Nix and NixOS, that includes the Nix store, where files can be created but not modified after the time they are created. It does not apply to every part of the operating system, in that users can still modify their own files in their home directory, for example. | Immutability is a property of data, in general, which means that the data cannot be modified after it is created. In the context of an operating system, it really means that certain parts of the system have this property. In the case of Nix and NixOS, that includes the Nix store, where files can be created but not modified after the time they are created. It does not apply to every part of the operating system, in that users can still modify their own files in their home directory, for example. | ||
</div> | </div> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
== I'm getting ‘infinite recursion’ errors when trying to do something clever with <code>imports</code> == | === I'm getting ‘infinite recursion’ errors when trying to do something clever with <code>imports</code> === | ||
</div> | </div> | ||
| Line 689: | Line 706: | ||
{{:FAQ/stateVersion}} | {{:FAQ/stateVersion}} | ||
{{:FAQ/notfound}} | {{:FAQ/notfound}} | ||
<!-- Transclude subpages --> | <!-- Transclude subpages --> | ||
</div> | </div> | ||