Experimental package management with Nix and NixOS
Preparing Your System
The first issue you'll face when transitioning to NixOS is which applications to enable. Most users will find all the applications they need in the NixOS repositories. (By the way, there are also some alternative repositories.)
Even though the installer is command-line only, it is surprisingly easy to use. You can use any standard partition scheme. The install manual has examples that you can copy if you don't have any special demands. You do have to know how to handle a partition program. They suggest you use partition labels, which is really useful. You'll need to partition your disks, mount the root partition, boot your new system, and run the nixos-generate-configuration
command:
nixos-generate-configuration --root /mnt
Use the manual that is included in the install ISO. The manual looks long and complicated, but it is actually comprehensive and clear. When this command has finished, you will need to edit your configuration.nix
file.
configuration.nix
The nixos-generate-configuration
command generates two files: configuration.nix
and hardware.nix
. In most cases, you will do nothing with the hardware file, since the installer has set everything according to the current system you are on. The interesting part is the configuration.nix
file. Inside, you will have all the settings you need and the applications you want on the general system.
Starting from the top, the file has the curly brackets that define your environment (Figure 4). You change this setting for extreme cases; on a desktop, leave it alone. Second, you have an import statement that imports the hardware file. You can use this section if you want to break out some of your configuration. Any Nix file that you reference will be added to your configuration.
Next, there should be a few lines about your boot loader. The Nix installer detects UEFI and BIOS; don't change the boot loader configuration unless you have very particular circumstances. As you go down the file, most options are clear and follow standards for locale and time zone. When you want to choose a desktop system, however, you are left in the dark – the configuration file has nothing for you.
Fear not! The NixOS website has a very nice interface for looking for options and applications [3]. On this page, you can enter in the application that you want. If you search for Gnome, you get a long list of options (Figure 5). Click on the option you want and the Name given in the list is the name you put in the file. The Gnome entry needs the setting:
services.xserver.desktopManager.gnome3.enable = 1;
The list of options has more than 10,000 entries! You can use them when you want, but don't let the shear number hold you back. All options you need, initially, are in the original file. You will only need to add a window or desktop manager. Once you have written the file, you can install. The procedure is one script. At the end of the script, you need to set the root password.
The script compiles all programs that are not available in binary form, so it might take a while. You have options for distributing the compile to other computers. If you have problems, you can also choose the --show-trace
option to see a diagnostic trace.
After the installation, reboot into your new system.
Updating Applications
At some point a package might require an upgrade. You can use the --upgrade
action for this job. More surprising is that you can upgrade to the same versions. As the manual states, this might seem useless. However, you can use it to recompile your current applications to newer libraries and also cut out duplicates of libraries. Enter the following command:
nix-env --upgrade --leq
You can also skip the leq
parameter, in which case the command will upgrade everything without optimizing the libraries you use. An upgrade leads to another concern; you may have many versions of any file in your system, which means you'll have many generations to deal with.
« Previous 1 2 3 Next »
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Gnome Fans Everywhere Rejoice for the Latest Release
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.