I’ve been experimenting with NixOS and running Nix on macOS, and I’ve been documenting some of the problems and solutions I’ve encountered in the process.
Global configuration paths for NixOS:
Apply the updated global configuration.
Updating major releases
If you want to update NixOS 21.11 to 22.05:
Consider changing or not changing
Commonly used NixOS configurations.
Home Manager describes the program that users see by default, while NixOS is configured for all users.
Application configuration file.
Commonly used configurations
Commonly used Home Manager configurations.
Overriding Dependency Versions
Set the JDK version that the JVM program depends on.
The specific naming of parameters depends on the beginning of the corresponding package on nixpkgs.
nixpkgs-fmt is used to format Nix code.
search.nixos.org You can search for various packages on nixpkgs and also see the different platform support. The downside is that you can’t see if the packages are unfree or broken, and some darwin os-specific packages are not shown.
It is easy to write
default.nix to package your project.
For a simple cmake program, you can write
default.nix in the following format:
You can use the
nix-build command to build, and the result will create a
result softlink in the current directory, which is the installation directory.
nix-build also creates a
build directory, it is recommended to use a different name when developing to prevent conflicts.
For Qt projects, the implementation is a little more complicated because there are different big versions of Qt, so it has to be split into two files, first
Here it means compiling with
qt5, then when writing
xxx.nix, the libraries passed in such as
qtbase are the version of
In actual testing, we found that the running program may report
Could not initialize GLX error, which can be solved by adding environment variables via
In addition to packaging, the packages needed for the development environment are usually defined in
Then you can use
nix-shell to enter the development environment. If you don’t want outside environment variables to be passed in, you can use