How do I create a local repository for NixOS/nixpkgs?

5,485

Solution 1

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.

Solution 2

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

Solution 3

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

Share:
5,485

Related videos on Youtube

Michael Ekstrand
Author by

Michael Ekstrand

Assistant professor in computer science at Boise State University specializing in human-computer interaction, recommender systems, and information retrieval.

Updated on September 18, 2022

Comments

  • Michael Ekstrand
    Michael Ekstrand almost 2 years

    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?

  • telent
    telent over 5 years
    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