Revise Nix-related notes

Added more notes as I developed the Guix overlay for NixOS over time. It
does have a nice experience, overall (albeit clunky one due to the documentation).
This commit is contained in:
Gabriel Arazas 2022-10-25 16:58:19 +08:00
parent 86408c3c04
commit 5242780327
5 changed files with 968 additions and 127 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,28 @@
:PROPERTIES:
:ID: f884a71c-0a0f-4fd7-82ff-00674ed4bd66
:END:
#+title: nixpkgs
#+date: 2022-09-03 15:02:21 +08:00
#+date_modified: 2022-09-03 20:26:16 +08:00
#+language: en
The main repository of what [[id:3b3fdcbf-eb40-4c89-81f3-9d937a0be53c][Nix package manager]] mainly offers.
This is where you get most of the updates from whether you're using [[id:7e8e83d5-4b08-44f6-800d-a322f6960a62][NixOS]] or in a foreign distro to update the list of packages.
It contains a lot of stuff such as...
- Massive set of package definitions (about 80k as of 2022-09-03) for various applications and dependencies.
- [[roam:NixOS modules]] for various programs, services, and the basis for NixOS, in general.
- A library that extends the builtin functions from [[id:a57e63a7-6daa-4639-910d-c6648df156a3][Nix language]].
- Includes a way to painlessly define derivations to compile with =stdenv.mkDerivation=.
- Various support for easily packaging projects made in different programming languages are also built on top of =mkDerivation=.
- Various mechanisms to make packaging easier such as [[id:75790f28-48de-462d-9503-eb2d6206df72][nixpkgs setup hooks]].
Being familiar with nixpkgs allows you to understand NixOS better and define packages in a more idiomatic way.
It's a large repository with Nix code so it is a nice way to learn more about Nix.
Among other things, it is made to be extensible as seen with features like...
- [[id:8568ce92-99a8-4d20-9723-eee41a507327][Nix overrides and overlays]] that allows fine-grained changes to package definitions and changes part of the package set that nixpkgs has.
- Its standard library can be extended further with =lib.extends=.

View File

@ -0,0 +1,22 @@
:PROPERTIES:
:ID: 75790f28-48de-462d-9503-eb2d6206df72
:END:
#+title: nixpkgs setup hooks
#+date: 2022-09-02 23:33:05 +08:00
#+date_modified: 2022-09-03 17:41:41 +08:00
#+language: en
Setup hooks are additional steps given from a package typically written as a shell script.
They are usually defined in a package with common build steps that would otherwise be repeated on a lot of packages such as...
- [[https://github.com/NixOS/nixpkgs/blob/350fd0044447ae8712392c6b212a18bdf2433e71/pkgs/development/tools/build-managers/meson/setup-hook.sh][Meson]] where it gives common arguments such as the [[https://www.gnu.org/software/automake/manual/html_node/Standard-Directory-Variables.html][GNU directory variables]] relative to the output from the derivation (i.e., ~out~).
- [[https://github.com/NixOS/nixpkgs/blob/350fd0044447ae8712392c6b212a18bdf2433e71/pkgs/development/interpreters/guile/setup-hook-3.0.sh][Guile]] where it set up different search paths related to GNU Guile.
- [[https://github.com/NixOS/nixpkgs/blob/350fd0044447ae8712392c6b212a18bdf2433e71/pkgs/development/interpreters/python/wrap.sh][Python]] also works similarly to Guile's only with a lot more of setup hooks for building and wrapping programs build with Python as it is used for various functions (e.g., =buildPythonPackage=, =buildPythonApplication=).
You can see more setup hooks example at ~pkgs/build-support/setup-hooks~ from roam:nixpkgs.
- Adding a setup hook is made with ~setupHook~ attribute from ~stdenv.mkDerivation~ where it needs either a path or a derivation.
- You could also make a setup hook with additional environment with ~makeSetupHook~ function.

View File

@ -3,7 +3,7 @@
:END:
#+title: Nix package manager
#+date: "2021-06-05 12:34:49 +08:00"
#+date_modified: "2021-07-28 16:31:56 +08:00"
#+date_modified: "2022-09-03 20:26:48 +08:00"
#+language: en
@ -18,7 +18,7 @@ Among other things, Nix also has the following features to look out for.
- Creating [[id:de801b92-819e-4944-9f5b-5cea145a2798][Reproducible executables with Nix]] enabling to execute with one script only requiring the package manager.
- How the build process works along with [[id:8f23f862-a19a-4a13-8d8f-69c280a8e072][Nix derivations]].
- With [[id:8568ce92-99a8-4d20-9723-eee41a507327][Nix overrides and overlays]], you can change parts of a system and/or packages.
- With [[id:8568ce92-99a8-4d20-9723-eee41a507327][nixpkgs overrides and overlays]], you can change parts of [[id:f884a71c-0a0f-4fd7-82ff-00674ed4bd66][nixpkgs]].
- The new way to manage channels with [[id:6873de22-9eac-492c-93a8-6cdf8cbfc0f8][Nix flakes]].
- How [[id:963c043e-4972-4b29-8360-223ec3465203][Nix packages]] are built and eventually created an extensive package ecosystem with the [[id:a57e63a7-6daa-4639-910d-c6648df156a3][Nix language]].

View File

@ -1,13 +1,13 @@
:PROPERTIES:
:ID: 8568ce92-99a8-4d20-9723-eee41a507327
:END:
#+title: Nix overrides and overlays
#+title: nixpkgs overrides and overlays
#+date: 2021-07-28 12:54:40 +08:00
#+date_modified: 2021-07-28 12:55:03 +08:00
#+date_modified: 2022-09-03 20:26:34 +08:00
#+language: en
You can override values in Nix as a way to customize nixpkgs.
You can override values in [[id:f884a71c-0a0f-4fd7-82ff-00674ed4bd66][nixpkgs]] as a way to customize nixpkgs.
For example, if you want to use a different version from the nixpkgs channel, you can change the appropriate value.
#+begin_src nix