2013-07-19 17:51:31 +03:00
|
|
|
<appendix xmlns="http://docbook.org/ns/docbook"
|
|
|
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
|
|
xml:id="chap-hacking">
|
|
|
|
|
|
|
|
<title>Hacking</title>
|
|
|
|
|
2020-07-18 10:48:13 +03:00
|
|
|
<para>This section provides some notes on how to hack on Nix. To get
|
2013-07-19 17:51:31 +03:00
|
|
|
the latest version of Nix from GitHub:
|
|
|
|
<screen>
|
2020-07-18 10:48:13 +03:00
|
|
|
$ git clone https://github.com/NixOS/nix.git
|
2014-02-28 15:01:26 +02:00
|
|
|
$ cd nix
|
2013-07-19 17:51:31 +03:00
|
|
|
</screen>
|
|
|
|
</para>
|
|
|
|
|
2020-07-21 00:30:39 +03:00
|
|
|
<para>To build Nix for the current operating system/architecture use
|
2020-07-18 10:48:13 +03:00
|
|
|
|
|
|
|
<screen>
|
|
|
|
$ nix-build
|
|
|
|
</screen>
|
|
|
|
|
|
|
|
or if you have a flakes-enabled nix:
|
|
|
|
|
|
|
|
<screen>
|
|
|
|
$ nix build
|
|
|
|
</screen>
|
|
|
|
|
|
|
|
This will build <literal>defaultPackage</literal> attribute defined in the <literal>flake.nix</literal> file.
|
|
|
|
|
|
|
|
To build for other platforms add one of the following suffixes to it: aarch64-linux,
|
|
|
|
i686-linux, x86_64-darwin, x86_64-linux.
|
|
|
|
|
|
|
|
i.e.
|
|
|
|
|
2013-07-19 17:51:31 +03:00
|
|
|
<screen>
|
2020-07-18 10:48:13 +03:00
|
|
|
nix-build -A defaultPackage.x86_64-linux
|
2013-07-19 17:51:31 +03:00
|
|
|
</screen>
|
2020-07-18 10:48:13 +03:00
|
|
|
|
2013-07-19 17:51:31 +03:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>To build all dependencies and start a shell in which all
|
|
|
|
environment variables are set up so that those dependencies can be
|
|
|
|
found:
|
|
|
|
<screen>
|
2016-11-28 17:13:23 +02:00
|
|
|
$ nix-shell
|
2013-07-19 17:51:31 +03:00
|
|
|
</screen>
|
|
|
|
To build Nix itself in this shell:
|
|
|
|
<screen>
|
2014-07-16 12:09:01 +03:00
|
|
|
[nix-shell]$ ./bootstrap.sh
|
2020-07-18 10:48:13 +03:00
|
|
|
[nix-shell]$ ./configure $configureFlags
|
|
|
|
[nix-shell]$ make -j $NIX_BUILD_CORES
|
2013-07-19 17:51:31 +03:00
|
|
|
</screen>
|
2018-08-21 22:44:37 +03:00
|
|
|
To install it in <literal>$(pwd)/inst</literal> and test it:
|
2013-07-19 17:51:31 +03:00
|
|
|
<screen>
|
|
|
|
[nix-shell]$ make install
|
|
|
|
[nix-shell]$ make installcheck
|
2020-07-18 10:48:13 +03:00
|
|
|
[nix-shell]$ ./inst/bin/nix --version
|
|
|
|
nix (Nix) 2.4
|
|
|
|
</screen>
|
|
|
|
|
|
|
|
If you have a flakes-enabled nix you can replace:
|
|
|
|
|
|
|
|
<screen>
|
|
|
|
$ nix-shell
|
|
|
|
</screen>
|
|
|
|
|
|
|
|
by:
|
|
|
|
|
|
|
|
<screen>
|
|
|
|
$ nix develop
|
2013-07-19 17:51:31 +03:00
|
|
|
</screen>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
</appendix>
|