2014-08-24 21:18:18 +04:00
|
|
|
|
<chapter xmlns="http://docbook.org/ns/docbook"
|
|
|
|
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
|
|
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
|
|
|
|
version="5.0"
|
|
|
|
|
xml:id="sec-getting-sources">
|
|
|
|
|
|
|
|
|
|
<title>Getting the Sources</title>
|
|
|
|
|
|
|
|
|
|
<para>By default, NixOS’s <command>nixos-rebuild</command> command
|
|
|
|
|
uses the NixOS and Nixpkgs sources provided by the
|
2017-04-01 16:32:25 +03:00
|
|
|
|
<literal>nixos</literal> channel (kept in
|
2014-08-24 21:18:18 +04:00
|
|
|
|
<filename>/nix/var/nix/profiles/per-user/root/channels/nixos</filename>).
|
|
|
|
|
To modify NixOS, however, you should check out the latest sources from
|
2016-04-20 21:53:24 +03:00
|
|
|
|
Git. This is as follows:
|
2014-08-24 21:18:18 +04:00
|
|
|
|
|
|
|
|
|
<screen>
|
|
|
|
|
$ git clone git://github.com/NixOS/nixpkgs.git
|
2015-05-20 15:16:00 +03:00
|
|
|
|
$ cd nixpkgs
|
|
|
|
|
$ git remote add channels git://github.com/NixOS/nixpkgs-channels.git
|
|
|
|
|
$ git remote update channels
|
2014-08-24 21:18:18 +04:00
|
|
|
|
</screen>
|
|
|
|
|
|
2016-04-20 21:53:24 +03:00
|
|
|
|
This will check out the latest Nixpkgs sources to
|
|
|
|
|
<filename>./nixpkgs</filename> the NixOS sources to
|
|
|
|
|
<filename>./nixpkgs/nixos</filename>. (The NixOS source tree lives in
|
|
|
|
|
a subdirectory of the Nixpkgs repository.) The remote
|
|
|
|
|
<literal>channels</literal> refers to a read-only repository that
|
|
|
|
|
tracks the Nixpkgs/NixOS channels (see <xref linkend="sec-upgrading"/>
|
|
|
|
|
for more information about channels). Thus, the Git branch
|
2017-03-25 22:14:04 +03:00
|
|
|
|
<literal>channels/nixos-17.03</literal> will contain the latest built
|
|
|
|
|
and tested version available in the <literal>nixos-17.03</literal>
|
2016-04-20 21:53:24 +03:00
|
|
|
|
channel.</para>
|
2014-08-24 21:18:18 +04:00
|
|
|
|
|
|
|
|
|
<para>It’s often inconvenient to develop directly on the master
|
|
|
|
|
branch, since if somebody has just committed (say) a change to GCC,
|
|
|
|
|
then the binary cache may not have caught up yet and you’ll have to
|
|
|
|
|
rebuild everything from source. So you may want to create a local
|
|
|
|
|
branch based on your current NixOS version:
|
|
|
|
|
|
|
|
|
|
<screen>
|
2015-05-20 15:16:00 +03:00
|
|
|
|
$ nixos-version
|
2017-03-25 22:14:04 +03:00
|
|
|
|
17.09pre104379.6e0b727 (Hummingbird)
|
2015-05-20 15:16:00 +03:00
|
|
|
|
|
2017-04-01 16:32:25 +03:00
|
|
|
|
$ git checkout -b local 6e0b727
|
2014-08-24 21:18:18 +04:00
|
|
|
|
</screen>
|
|
|
|
|
|
2015-05-20 15:16:00 +03:00
|
|
|
|
Or, to base your local branch on the latest version available in a
|
2014-08-24 21:18:18 +04:00
|
|
|
|
NixOS channel:
|
|
|
|
|
|
|
|
|
|
<screen>
|
2015-05-20 15:16:00 +03:00
|
|
|
|
$ git remote update channels
|
2017-03-25 22:14:04 +03:00
|
|
|
|
$ git checkout -b local channels/nixos-17.03
|
2015-05-20 15:16:00 +03:00
|
|
|
|
</screen>
|
|
|
|
|
|
2017-03-25 22:14:04 +03:00
|
|
|
|
(Replace <literal>nixos-17.03</literal> with the name of the channel
|
2015-05-20 15:16:00 +03:00
|
|
|
|
you want to use.) You can use <command>git merge</command> or
|
|
|
|
|
<command>git rebase</command> to keep your local branch in sync with
|
|
|
|
|
the channel, e.g.
|
|
|
|
|
|
|
|
|
|
<screen>
|
|
|
|
|
$ git remote update channels
|
2017-03-25 22:14:04 +03:00
|
|
|
|
$ git merge channels/nixos-17.03
|
2014-08-24 21:18:18 +04:00
|
|
|
|
</screen>
|
|
|
|
|
|
2015-05-20 15:16:00 +03:00
|
|
|
|
You can use <command>git cherry-pick</command> to copy commits from
|
|
|
|
|
your local branch to the upstream branch.</para>
|
2014-08-24 21:18:18 +04:00
|
|
|
|
|
|
|
|
|
<para>If you want to rebuild your system using your (modified)
|
|
|
|
|
sources, you need to tell <command>nixos-rebuild</command> about them
|
|
|
|
|
using the <option>-I</option> flag:
|
|
|
|
|
|
|
|
|
|
<screen>
|
2016-06-01 17:23:32 +03:00
|
|
|
|
# nixos-rebuild switch -I nixpkgs=<replaceable>/my/sources</replaceable>/nixpkgs
|
2014-08-24 21:18:18 +04:00
|
|
|
|
</screen>
|
|
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
|
|
<para>If you want <command>nix-env</command> to use the expressions in
|
|
|
|
|
<replaceable>/my/sources</replaceable>, use <command>nix-env -f
|
|
|
|
|
<replaceable>/my/sources</replaceable>/nixpkgs</command>, or change
|
|
|
|
|
the default by adding a symlink in
|
|
|
|
|
<filename>~/.nix-defexpr</filename>:
|
|
|
|
|
|
|
|
|
|
<screen>
|
|
|
|
|
$ ln -s <replaceable>/my/sources</replaceable>/nixpkgs ~/.nix-defexpr/nixpkgs
|
|
|
|
|
</screen>
|
|
|
|
|
|
|
|
|
|
You may want to delete the symlink
|
|
|
|
|
<filename>~/.nix-defexpr/channels_root</filename> to prevent root’s
|
2017-04-01 16:32:25 +03:00
|
|
|
|
NixOS channel from clashing with your own tree (this may break the
|
|
|
|
|
command-not-found utility though). If you want to go back to the default
|
|
|
|
|
state, you may just remove the <filename>~/.nix-defexpr</filename>
|
|
|
|
|
directory completely, log out and log in again and it should have been
|
|
|
|
|
recreated with a link to the root channels.</para>
|
2014-08-24 21:18:18 +04:00
|
|
|
|
|
|
|
|
|
<!-- FIXME: not sure what this means.
|
|
|
|
|
<para>You should not pass the base directory
|
|
|
|
|
<filename><replaceable>/my/sources</replaceable></filename>
|
|
|
|
|
to <command>nix-env</command>, as it will break after interpreting expressions
|
|
|
|
|
in <filename>nixos/</filename> as packages.</para>
|
|
|
|
|
-->
|
|
|
|
|
|
2014-12-14 13:26:08 +03:00
|
|
|
|
</chapter>
|