About me: My name is Solène Rapenne, pronouns she/her. I like learning and sharing knowledge. Hobbies: '(BSD OpenBSD Qubes OS Lisp cmdline gaming security QubesOS internet-stuff). I love percent and lambda characters. Qubes OS core team member, former OpenBSD developer solene@. No AI is involved in this blog.

Contact me: solene at dataswamp dot org or @solene@bsd.network (mastodon).

I'm a freelance OpenBSD, FreeBSD, Linux and Qubes OS consultant, this includes DevOps, DevSecOps, technical writing or documentation work. If you enjoy this blog, you can sponsor my open source work financially so I can write this blog and contribute to Free Software as my daily job.

How to hack on Nix and try your changes

Written by Solène, on 19 August 2022.
Tags: #nix #development #nixos

Comments on Fediverse/Mastodon

1. Introduction §

Not obvious development process is hard to document. I wanted to make changes to the nix program, but I didn't know how to try them.

Fortunately, a coworker explained to me the process, and here it is!

The nix project GitHub page

2. Get the sources and compile §

First, you need to get the sources of the project, and compile it in some way to run it from the project directory:

git clone https://github.com/NixOS/nix/
cd nix
nix-shell
./bootstrap.sh
./configure --prefix=$PWD
make

3. Run the nix daemon §

In order to try nix, we need to stop nix-daemon.service, but also stop nix-daemon.socket to prevent it to restart the nix-daemon.

systemctl stop nix-daemon.socket
systemctl stop nix-daemon.service

Now, when you want your nix-daemon to work, just run this command from the project directory:

sudo bin/nix --extra-experimental-features nix-command daemon

Note this command doesn't fork on background.

If you need some settings in the nix.conf file, you have to create etc/nix/nix.conf relative to the project directory.

4. Restart the nix-daemon §

Once you are done with the development, exit your running daemon and restart the service and socket.

systemctl start nix-daemon.socket
systemctl start nix-daemon.service