Nixpkgs/Create and debug packages: Difference between revisions
imported>Fadenb m →Testing Package Updates with Nox: syntaxhighlight |
imported>Fadenb m Syntaxhighlight |
||
Line 25: | Line 25: | ||
For the sake of this article, let's set an environment variable which points to the directory where we've cloned our repo. | For the sake of this article, let's set an environment variable which points to the directory where we've cloned our repo. | ||
<syntaxhighlight lang="bash"> | |||
$ export NIXPKGS=/path/to/clone/of/nixpkgs | |||
</syntaxhighlight> | |||
make some changes ... | make some changes ... | ||
Line 31: | Line 33: | ||
'''example: list all available software''' from the local repository | '''example: list all available software''' from the local repository | ||
$NIXREPOS/nixpkgs | $NIXREPOS/nixpkgs | ||
<syntaxhighlight lang="bash"> | |||
$ nix-env -f $NIXPKGS -qaP '*' | |||
</syntaxhighlight> | |||
'''example: install software from local repository''' | '''example: install software from local repository''' | ||
<syntaxhighlight lang="bash"> | |||
$ nix-env -f $NIXPKGS -i python-urlgrabber | |||
</syntaxhighlight> | |||
'''example: update the system''' based on your local '''$NIXREPOS''' | '''example: update the system''' based on your local '''$NIXREPOS''' | ||
<syntaxhighlight lang="bash"> | |||
$ nixos-rebuild -I nixos=$NIXPKGS/nixos -I nixpkgs=$NIXPKGS switch | |||
</syntaxhighlight> | |||
'''example: build an expression and put the output in to `pwd`/results''' | '''example: build an expression and put the output in to `pwd`/results''' | ||
<syntaxhighlight lang="bash"> | |||
$ nix-build $NIXPKGS -A irssi | |||
</syntaxhighlight> | |||
'''example: get an environment which is used to build irssi (also see nix-shell)''' | '''example: get an environment which is used to build irssi (also see nix-shell)''' | ||
<syntaxhighlight lang="bash"> | |||
$ nix-build $NIXPKGS --run-env -A irssi | |||
</syntaxhighlight> | |||
'''example: get a persistent environment which is used to build irssi''' | '''example: get a persistent environment which is used to build irssi''' | ||
<syntaxhighlight lang="bash"> | |||
$ nix-build $NIXPKGS --run-env -A irssi --add-root | |||
</syntaxhighlight> | |||
== Tracking upstream changes and avoiding extra rebuilding == | == Tracking upstream changes and avoiding extra rebuilding == | ||
You have forked the relevant nix repository, but you will want to track changes in the upstream nix repo too. You can add a remote, and a corresponding branch for this. | You have forked the relevant nix repository, but you will want to track changes in the upstream nix repo too. You can add a remote, and a corresponding branch for this. | ||
<syntaxhighlight lang="bash"> | |||
git remote add upstream https://github.com/NixOS/nixpkgs.git | |||
</syntaxhighlight> | |||
You can create a branch to track the upstream master branch: | You can create a branch to track the upstream master branch: | ||
<syntaxhighlight lang="bash"> | |||
$ git checkout -b upstream-master upstream/master | |||
$ git pull | |||
</syntaxhighlight> | |||
This will put you into a branch with all the latest changes. Hydra, the build farm, regularly creates binaries, but, since people are constantly contributing to the nix repositories, it is usually the case that there are changes in the master branch which have not yet made it into the binary channel. To take advantage of available binaries you can switch to the revision which produced the binaries in your current system and apply your changes from there. You can use `nixos-version` to see the relevant short revision hash: | This will put you into a branch with all the latest changes. Hydra, the build farm, regularly creates binaries, but, since people are constantly contributing to the nix repositories, it is usually the case that there are changes in the master branch which have not yet made it into the binary channel. To take advantage of available binaries you can switch to the revision which produced the binaries in your current system and apply your changes from there. You can use `nixos-version` to see the relevant short revision hash: | ||
Line 62: | Line 80: | ||
$ nixos-version | $ nixos-version | ||
14.11pre52727.5d97886 (Caterpillar) | 14.11pre52727.5d97886 (Caterpillar) | ||
${NixOS release}.${nixpkgs revision} (since the git-repo called nixos was merged into nixpkgs) | ${NixOS release}.${nixpkgs revision} | ||
(since the git-repo called nixos was merged into nixpkgs) | |||
$ nixos-version | $ nixos-version | ||
13.07pre4871_18de9f6-3c35dae (Aardvark) | 13.07pre4871_18de9f6-3c35dae (Aardvark) |