General questions for a popularization article in France

@jojo As a fellow French, I am willing to proof-read your article if you want. I am not a NixOS expert but I have been using it for half a year now for what that’s worth.

1 Like

The article is overall finished. Thanks to the help @juliendehos and @samueldr it has greatly improved through comments and reviews and I’m currently planning to send it to the editor next week.

I am still not 100% sure of a part about the upgrading process of NixOS. Here is my current hypothesis (written in the article) :

During a system upgrade:

  1. The new system is stored at: /nix/store/qzaqjh
-nixos-system-<hostname>-19.03.
  2. The corresponding generation is created: /nix/var/nix/profiles/system-141-link.
  3. The profile is updated : /nix/var/nix/profiles/system points afterwards to generation 141.
  4. At last, the generation link is copied to /run/current-system . This last link thus points towards /nix/store/qzaqjh
-nixos-system-<hostname>-19.03.

When exactly does nixos-rebuild switch updates the /run/current-system link ? Is it actually the 4th step ? Or does it occur before ?

I searched in the NixOS paper of 2010 and even looked at the source code of switch-to-configuration.pl without finding this information.

Next sentence of the article currently explains that the atomicity of the system upgrade is due to the atomicity of step 4. Could someone confirm this too ?

Found out that switch-to-configuration.pl calls an activation script generated during system build : /nix/store/jwwfv...-nixos-system-jlucas-laptop-20.03pre193781.d484f2b7fc0/activate. Relevant lines of this script:

systemConfig=/nix/store/jwwfv...-nixos-system-jlucas-laptop-20.03pre193781.d484f2b7fc0

...

# Make this configuration the current configuration.
# The readlink is there to ensure that when $systemConfig = /system
# (which is a symlink to the store), /run/current-system is still
# used as a garbage collection root.
ln -sfn "$(readlink -f "$systemConfig")" /run/current-system

# Prevent the current configuration from being garbage-collected.
ln -sfn /run/current-system /nix/var/nix/gcroots/current-system

A stackoverflow discussion tends IMO to show that ln -sfn is not atomic. strace does show that ln -sfn calls first unlink, then symlink


Another question: Why not having /run/current-system pointing to /nix/var/nix/profiles/system ?

EDIT:

In the Nix manual:

the default symlink is made to point at the new generation. This last step is atomic on Unix, which explains how we can do atomic upgrades

AFAIK, during this process, Nix calls replaceSymlink to:

  1. create a temporary new default profile
  2. and then atomically make the switch through the system rename function

Why not using this process during nixos-rebuild switch ? while switching /run/current-system to the new system ?

I have just received a positive feedback of the editor about the article :slight_smile:

In addition to current technical images describing NixOS, editor asks if it would be possible to add two screenshots, representative of the distribution : “thus readers will have an idea of what it looks like”.
The editor may expect something like a screenshot of the Desktop Environment (DE), e.g. Unity of Ubuntu. But NixOS is a bit like Arch Linux on this point and has not a default DE. KDE is the default DE in the virtual machine but, it is not customized for NixOS. Gnome displays a NixOS wallpaper but its software manager icon is not meant for NixOS

So first I thought that I would explain to the editor that showing a random DE was meaningless.

But afterwards I thought that it could also be interesting, from a kind of commercial point of view, to show how a DE of NixOS can look like. Do you have a DE or a Display Manager with a NixOS graphic theme (e.g. GitHub - NixOS/nixos-artwork: Nix related artwork) that would be interesting to showcase ? Otherwise I will dismiss this request from the editor.

2 Likes

But afterwards I thought that it could also be interesting, from a kind of commercial point of view, to show how a DE of NixOS can look like. Do you have a DE or a Display Manager with a NixOS graphic theme (e.g. GitHub - NixOS/nixos-artwork: Nix related artwork) that would be interesting to showcase ? Otherwise I will dismiss this request from the editor.

There is also an option to offer a screenshot with minimal decoration, NixOS logo wallpaper, and an editor window with syntax-highlighted configuration.nix (or something in this direction).

3 Likes

There is the NixOS screenshot thread that may give you some ideas :slight_smile:

3 Likes

I think that is a legitimate request. But we can only show what it CAN look like if you choose to.

You could show 2 screenshots, one with KDE and one with i3 and have the description “KDE is one of 11 available desktop environments. It is used in the graphical installation CD.”

Already sent a screenshot of my deskop: a minimalist and dark-themed Xfce+i3. The screenshot shows three tiled windows : Firefox with NixOS main page, a console with neofetch (including a NixOS ASCII logo) and a third window with Vim and configuration.nix using syntax highlighting.

It would have been interesting to add that “it is one of 11 available desktop environments” with a list of these environments but the answer to the first review is already sent
 I will try to add this if I have a new opportunity.

1 Like

Article is being formatted now.

I woke up recently with a doubt concerning the meaning of “purely functional”, that seems rather important since it is used in the NixOS paper title and pervasively in the NixOS about page.
From these sources and digging here and there on the web (e.g. wikipedia page) I wrote something during last round of review, in french, similar to

NixOS manages the system configuration in a purely functional manner, any new version is built directly from the configuration file and storing this new version in memory does not overwrite the preceding version – similar to purely functional languages, computed values of which are immutable.

Is it correct enough ? If no I may have some time to send an edition request


TLDR; Is there a precise definition of “purely functional” in the NixOS world ?

I think that your definitions lacks the fact that in a “purely functional” paradigm, building a package (or configuration, which is a package) should not have any other side-effect than the act of generating the package itself. This means, for example, that a package build script cannot download dependencies from the Internet, read anything outside of the Nix store, or write anything outside of the output directory.

See the description of the Nix package manager:

Nix is a purely functional package manager . This means that it treats packages like values in purely functional programming languages such as Haskell — they are built by functions that don’t have side-effects, and they never change after they have been built.

3 Likes

maybe be more specific and say “purely functional programming languages”? Or are the audience only programmers that expect that?

Oh sorry @davidak, I realize that I missed to answer to your last post. Your suggestion has been included in the final version of the article, thanks :wink:

Article is out in Linux Pratique n°117 jan-feb 2020 :partying_face:

6 Likes

Great. Is there a chance to get the article for our community?

What do you mean ? A free version for all the members ?

Just the one article to post here without explicit right to redistribute it.

I suppose I’m too late for your article, but on the topic of building well-specified, reproducible, (extremely) minimalist Docker containers with Nix, @grahamc gave an excellent talk a couple weeks ago at NYLUG that’s worth checking out!

Specifically, he addressed your question about how it compares to multi-stage builds.

6 Likes

Answer from the editor :

Unfortunately no, it is not possible.
You will have to wait 6 months after publication for the CC version.

You will have to wait 6 months after publication for the CC version.

Will a free creative commons version be published on the website? That would be also fine, so we can link to it later.

Yes after 6 months it will be online with CC BY-NC-ND license. Like this article (a random sample shared by the editor) Analyse d’un problĂšme posĂ© par Intel SGX : la communication sĂ©curisĂ©e entre une enclave et un pĂ©riphĂ©rique | Connect - Editions Diamond