Title: How to hack on Nix and try your changes
Author: Solène
Date: 19 August 2022
Tags: nix development nixos
Description: This article explains how to make changes to the nix
program and how to use it locally

# 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
# 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:

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

# 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.

```shell
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:

```shell
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.

# Restart the nix-daemon

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

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