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
-
Rhino Linux Announces Latest "Quick Update"
If you prefer your Linux distribution to be of the rolling type, Rhino Linux delivers a beautiful and reliable experience.
-
Plasma Desktop Will Soon Ask for Donations
The next iteration of Plasma has reached the soft feature freeze for the 6.2 version and includes a feature that could be divisive.
-
Linux Market Share Hits New High
For the first time, the Linux market share has reached a new high for desktops, and the trend looks like it will continue.
-
LibreOffice 24.8 Delivers New Features
LibreOffice is often considered the de facto standard office suite for the Linux operating system.
-
Deepin 23 Offers Wayland Support and New AI Tool
Deepin has been considered one of the most beautiful desktop operating systems for a long time and the arrival of version 23 has bolstered that reputation.
-
CachyOS Adds Support for System76's COSMIC Desktop
The August 2024 release of CachyOS includes support for the COSMIC desktop as well as some important bits for video.
-
Linux Foundation Adopts OMI to Foster Ethical LLMs
The Open Model Initiative hopes to create community LLMs that rival proprietary models but avoid restrictive licensing that limits usage.
-
Ubuntu 24.10 to Include the Latest Linux Kernel
Ubuntu users have grown accustomed to their favorite distribution shipping with a kernel that's not quite as up-to-date as other distros but that changes with 24.10.
-
Plasma Desktop 6.1.4 Release Includes Improvements and Bug Fixes
The latest release from the KDE team improves the KWin window and composite managers and plenty of fixes.
-
Manjaro Team Tests Immutable Version of its Arch-Based Distribution
If you're a fan of immutable operating systems, you'll be thrilled to know that the Manjaro team is working on an immutable spin that is now available for testing.