17

All the instructions I find for creating a local repository of Nix packages involve creating a local clone of the main nixpkgs repository and adding to that.

Is there a way I can create a small repository just containing my local add-on packages?

6

Yes, just create an expression for the single package. You can get dependencies from nixpkgs by pkgs = import <nixpkgs> {};.

5

This blog post have some details: http://sandervanderburg.blogspot.no/2014/07/managing-private-nix-packages-outside.html

For more low-level from-the-ground-up details there's the nix-pill series: http://lethalman.blogspot.no/2014/07/nix-pill-1-why-you-should-give-it-try.html

But I think the basic approach is to create your own version of ~/.nix-defexpr/channels_root/nixos/pkgs/top-level/all-packages.nix, say mypkgs.nix adding dependencies from the default "repo" by importing <nixpkgs>.

Install packages by doing nix-env -f mypkgs.nix -i DERIVATION_NAME

But since nix is based on a full-blown language there's infinity ways you could do it I guess.

1

I'm by no means a Nix expert so I don't know if this is the best way, but it's what I do. I have a local repo for packages in $HOME/nix-local, which contains a number of package files vault/default.nix, blackbox/default.nix etc and a config.nix file which defines packageOverrides to call them. So something like:

$ cat nix-local/config.nix
{
  packageOverrides = pkgs: rec {
    vault = pkgs.callPackage ./vault {};
    blackbox = pkgs.callPackage ./blackbox {};
    # ...
}

$ export NIXPKGS_CONFIG=$HOME/nix-local/config.nix    

You can see the full repo at https://github.com/telent/nix-local

  • 4
    To anyone reading this since about 2017, this repo is not currently maintained and I would strongly suggest you read up on "overlays", a much cleaner way to do what packageOverrides used to do – telent Oct 3 '18 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.