Nix is an alternative to Flatpak.
Note 1 : there is no isolation of Nix and the programs it installs from the rest of EasyOS in my test
Note 2 : Nix creates a very large number of files (Saving to session or taking a snapshot of Easy is long)
EDIT : For a first or a speed reading go after METHOD I RECOMMEND
Some links :
https://en.wikipedia.org/wiki/Nix_(package_manager)
https://nixos.wiki/wiki/Nix_package_manager
https://nixos.org/learn.html
https://wiki.archlinux.org/title/Nix
https://nix-tutorial.gitlabpages.inria. ... arted.html
https://nixos.org/guides/how-nix-works.html
https://zero-to-nix.com/
https://nixos.org/guides/nix-pills/index.html
https://ianthehenry.com/posts/how-to-le ... roduction/
The documentation for Nix is very complicated but here i just want a very basic use : install and remove binaries packages available in the default channel (a channel for Nix is like a repository for distributions)
Summary of several weeks of testing.
To install Nix i found three sources:
https://nixos.org/download.html#download-nix
https://zero-to-nix.com/start/install
https://github.com/DavHau/nix-portable
The first is the official installer
The second is "The Determinate Nix Installer" (see https://github.com/determinateSystems/nix-installer and https://determinate.systems/posts/zero-to-nix).
It installs Nix with parts announced as still experimental (https://zero-to-nix.com/concepts/nix and https://zero-to-nix.com/concepts/nix-installer)
The third would be a portable version of Nix. I don't really understand and in quick tests don't seem to bring utility for a basic use.
****************
Official installer :
Two installation methods: multi-user or single-user
-In single-user installation, the script don't be run as root. So i created an new user named nix (this name was just a choice, probably not a good idea to avoid confusion) .As the environment variable XDG_CACHE_HOME of nix was /root/.cache and not /home/nix/.cache(EDIT : not exact see viewtopic.php?p=95149#p95149), we need to trick :
Code: Select all
adduser -D nix
mkdir /nix
chown nix /nix
mkdir /home/nix/.cache
mkdir /home/nix/.cache/nix
chown nix /home/nix/.cache/nix
ln -s /home/nix/.cache/nix /root/.cache/nix
Seem to work but at each boot /root/.cache/nix was deleted. As that time I didn't know how to launch a script at boot, so i give up
-In multi-user installation, the script wants to create new users and groups. It call the commands useradd and groupadd that don't exist in EasyOS.
We need to add lines to configurations files :
In /etc/group
Code: Select all
nixbld:x:30000:nixbld1,nixbld2,nixbld3,nixbld4,nixbld5,nixbld6,nixbld7,nixbld8,nixbld9,nixbld10,nixbld11,nixbld12,nixbld13,nixbld14,nixbld15,nixbld16,nixbld17,nixbld18,nixbld19,nixbld20,nixbld21,nixbld22,nixbld23,nixbld24,nixbld25,nixbld26,nixbld27,nixbld28,nixbld29,nixbld30,nixbld31,nixbld32
in /etc/gshadow
Code: Select all
nixbld:!::nixbld1,nixbld2,nixbld3,nixbld4,nixbld5,nixbld6,nixbld7,nixbld8,nixbld9,nixbld10,nixbld11,nixbld12,nixbld13,nixbld14,nixbld15,nixbld16,nixbld17,nixbld18,nixbld19,nixbld20,nixbld21,nixbld22,nixbld23,nixbld24,nixbld25,nixbld26,nixbld27,nixbld28,nixbld29,nixbld30,nixbld31,nixbld32
in /etc/password
Code: Select all
nixbld1:x:30001:30000:Nix build user 1,,,:/var/empty:/sbin/nologin
nixbld2:x:30002:30000:Nix build user 2,,,:/var/empty:/sbin/nologin
nixbld3:x:30003:30000:Nix build user 3,,,:/var/empty:/sbin/nologin
nixbld4:x:30004:30000:Nix build user 4,,,:/var/empty:/sbin/nologin
nixbld5:x:30005:30000:Nix build user 5,,,:/var/empty:/sbin/nologin
nixbld6:x:30006:30000:Nix build user 6,,,:/var/empty:/sbin/nologin
nixbld7:x:30007:30000:Nix build user 7,,,:/var/empty:/sbin/nologin
nixbld8:x:30008:30000:Nix build user 8,,,:/var/empty:/sbin/nologin
nixbld9:x:30009:30000:Nix build user 9,,,:/var/empty:/sbin/nologin
nixbld10:x:30010:30000:Nix build user 10,,,:/var/empty:/sbin/nologin
nixbld11:x:30011:30000:Nix build user 11,,,:/var/empty:/sbin/nologin
nixbld12:x:30012:30000:Nix build user 12,,,:/var/empty:/sbin/nologin
nixbld13:x:30013:30000:Nix build user 13,,,:/var/empty:/sbin/nologin
nixbld14:x:30014:30000:Nix build user 14,,,:/var/empty:/sbin/nologin
nixbld15:x:30015:30000:Nix build user 15,,,:/var/empty:/sbin/nologin
nixbld16:x:30016:30000:Nix build user 16,,,:/var/empty:/sbin/nologin
nixbld17:x:30017:30000:Nix build user 17,,,:/var/empty:/sbin/nologin
nixbld18:x:30018:30000:Nix build user 18,,,:/var/empty:/sbin/nologin
nixbld19:x:30019:30000:Nix build user 19,,,:/var/empty:/sbin/nologin
nixbld20:x:30020:30000:Nix build user 20,,,:/var/empty:/sbin/nologin
nixbld21:x:30021:30000:Nix build user 21,,,:/var/empty:/sbin/nologin
nixbld22:x:30022:30000:Nix build user 22,,,:/var/empty:/sbin/nologin
nixbld23:x:30023:30000:Nix build user 23,,,:/var/empty:/sbin/nologin
nixbld24:x:30024:30000:Nix build user 24,,,:/var/empty:/sbin/nologin
nixbld25:x:30025:30000:Nix build user 25,,,:/var/empty:/sbin/nologin
nixbld26:x:30026:30000:Nix build user 26,,,:/var/empty:/sbin/nologin
nixbld27:x:30027:30000:Nix build user 27,,,:/var/empty:/sbin/nologin
nixbld28:x:30028:30000:Nix build user 28,,,:/var/empty:/sbin/nologin
nixbld29:x:30029:30000:Nix build user 29,,,:/var/empty:/sbin/nologin
nixbld30:x:30030:30000:Nix build user 30,,,:/var/empty:/sbin/nologin
nixbld31:x:30031:30000:Nix build user 31,,,:/var/empty:/sbin/nologin
nixbld32:x:30032:30000:Nix build user 32,,,:/var/empty:/sbin/nologin
NB : /sbin/nologin don't exist in Easy, we can create it with :
Code: Select all
ln -s /bin/false /sbin/nologin
and finally in /etc/shadow
Code: Select all
nixbld1:!:19471:0:99999:7:::
nixbld2:!:19471:0:99999:7:::
nixbld3:!:19471:0:99999:7:::
nixbld4:!:19471:0:99999:7:::
nixbld5:!:19471:0:99999:7:::
nixbld6:!:19471:0:99999:7:::
nixbld7:!:19471:0:99999:7:::
nixbld8:!:19471:0:99999:7:::
nixbld9:!:19471:0:99999:7:::
nixbld10:!:19471:0:99999:7:::
nixbld11:!:19471:0:99999:7:::
nixbld12:!:19471:0:99999:7:::
nixbld13:!:19471:0:99999:7:::
nixbld14:!:19471:0:99999:7:::
nixbld15:!:19471:0:99999:7:::
nixbld16:!:19471:0:99999:7:::
nixbld17:!:19471:0:99999:7:::
nixbld18:!:19471:0:99999:7:::
nixbld19:!:19471:0:99999:7:::
nixbld20:!:19471:0:99999:7:::
nixbld21:!:19471:0:99999:7:::
nixbld22:!:19471:0:99999:7:::
nixbld23:!:19471:0:99999:7:::
nixbld24:!:19471:0:99999:7:::
nixbld25:!:19471:0:99999:7:::
nixbld26:!:19471:0:99999:7:::
nixbld27:!:19471:0:99999:7:::
nixbld28:!:19471:0:99999:7:::
nixbld29:!:19471:0:99999:7:::
nixbld30:!:19471:0:99999:7:::
nixbld31:!:19471:0:99999:7:::
nixbld32:!:19471:0:99999:7:::
We can now launch the installation script :
Code: Select all
sh <(curl -L https://nixos.org/nix/install) --daemon
We can use /root/Startup to launch the nix-daemon at boot as requested by the script (I think it useless for a basic use of Nix)
****************
Determinate Nix installer
(METHOD I RECOMMEND)
Script to launch
Code: Select all
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install linux --init none
EDIT : deletion of the idea to replace the folder /nix by a symbolic link. It's not allowed by Nix !
Then to subscribe to the nixkpgs-unstable channel (This part is automatic in the official nix installer) :
Code: Select all
nix-channel --add https://nixos.org/channels/nixpkgs-unstable
nix-channel --update
Installation terminated !
The documentation on the zero-to-nix site is clear but very incomplete.
I will use nix in the same way as with the official installer (The concept of Flake highlighted by zero-to-nix is set aside here)
****************
Basic commands
Before starting :
Code: Select all
echo $PATH
to verify that nix is in the PATH
If not open a new terminal
The principal command is nix-env with options (see https://github.com/tldr-pages/tldr/blob ... nix-env.md for details) :
To search an available package : (example here with the search of "name")
nix-env -qaP | grep -i name (very slow, long time to wait the answer)
Alternately, it's faster using the site https://search.nixos.org/packages (choose the channel unstable) (More on searching packages : https://nixos.wiki/wiki/Searching_packages)
To install the package named "example"
nix-env -iA nixpkgs.example
If "example" is an application, we can run it in a terminal by simply typing example. If another version of example is installed in Easy,it's the version provided by Nix that run
To remove "example" of the user environment (if "example" is an application, example get out of the PATH and typing example no longer work or launch the version installed in Easy) :
nix-env -e example
When we install or remove a pckage, we create a new generation of the user-environment.
To really delete a package (after it was removed), we need to delete the old generations where it was installed. and then tu run the garbage collector
Code: Select all
nix-env --delete-generations old
delete all the generations other that the last (For more choice see https://nixos.org/manual/nix/unstable/p ... ction.html)
To run the garbage collector :
Code: Select all
nix-store --gc
To delete all the old generations and run the garbage collector in an unique command :
Code: Select all
$ nix-collect-garbage -d
EDIT : to remove Nix all its components and programms it has installed :
Code: Select all
/nix/nix-installer uninstall