download HEAD source code using different version control systems automatically and update nix sources
Haskell
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test-files
README
Setup.hs
nix-repository-manager.cabal

README

nix-repository-manager3
=======================

purpose: fetch contents and inject them into .nix files.
The only content implementation are version control system snapshots right now

it looks like this

# REGION NAME: { region options in nix attrs format }
  CONTENTS
# END

The most common use cases are:

  mkDerivation {
    # REGION AUTO UPDATE: { name = "library"; [ .. git,hg,mercurial, .. ]; [fields = "src name"] }
      name = "library-git-x3454"
      src = fetchurl { ... }
    # END

    // manually coded buildInputs, meta, and more attr names
  }

However for nixpkgs-{haskell,ruby}-overlay the contents are more complicated
because dependencies are extracted from .cabal or .gem files automatically.

usage:
nix-repository-manager 1 . --update names_or_group_names
1 is the numbe of parallel VCS actions

Instead of --update you can also use --update-then-publish or --publish
the publish action will upload the snapshot file using rsync

You have to create a ~/.nix-repository-manager file having three lines:

  FORMAT:0.0
  #MIRROR
  http://your-host.com/path/
  #UPLOAD
  ["rsync","-cs","--progress","--inplace", "FILE", "user@your-host.com:/path"]
  #MANAGED_DIRECTORY
  ~/managed-repos/

FILE will be replaced by the snapshot file


You have to override fetchurl and substitute the first part of the url in order
to use the local files.

  # Example:
  packageOverrides = p: {

    fetchurl = args: 
      let 
        prefix = "http://mawercer.de/~nix/";
        len = builtins.stringLength prefix;
        newArgs = 
            if args ? url && builtins.substring 0 len args.url == prefix
            then (removeAttrs args ["url"]) // { urls = [ "file:///home/marc/managed_repos/dist/${builtins.substring len 9999 args.url}" args.url ]; }
            else args;
      in p.fetchurl newArgs;
  };


SPECIAL NAMES
===============
subdir: only tar up a subdirectory of a repository

TROUBLE?
==========
Some operations such as svn or darcs require some minimal setup such as
defining a user accepting a remote host. You may have to run the checkout
manually the first time to reply to those questions

implementation details:
=======================
  important files
  managed repo dir contains
    ./dist
    ./dist/NAME.{tar.bz2,.gem,..} the snapshot

OUTDATED - TODO - If you read this ping me to fix it - (somewhat historical) 
========================

nix-repository-manager2
=======================

This is the second version of my helper application which
updates head repositories automatically.

This version implements source regions.
They are updated on request.


EXAMPLE:
========

initial file:

{
  myPackage = stdenv.mkDerivation {
    # REGION AUTO UPDATE:        { name="hack-nix"; type="git"; url="git://github.com/MarcWeber/hack-nix.git"; groups="haskell_packages group2"; }
    # END
    a = 20;
  }
}

Run this command to make the tool fill in source information based on the options found in the coment string:

  $ nix-repository-manager $DIR_CONTAINING_NIX_FILES --update hack-nix

yields:

  # REGION AUTO UPDATE: ...
  src = sourceFromHead "hack-nix-07c4f810c13183325cd920919e7fb3d2f9128bce.tar.gz"
                       (throw "not published");
  # END


Use --publish to copy the local distribution file on a server and add a
fechurl call so that the snapshot can be used by everyone:

  # REGION AUTO UPDATE:        { name="hack-nix"; type="git"; url="git://github.com/MarcWeber/hack-nix.git"; groups="haskell_packages"; }
  src = sourceFromHead "hack-nix-07c4f810c13183325cd920919e7fb3d2f9128bce.tar.gz"
                       (fetchurl { url = "http://mawercer.de/~nix/repos/hack-nix-07c4f810c13183325cd920919e7fb3d2f9128bce.tar.gz"; sha256 = "2a6fca6dfb7b832e8b3c30df7210a68499f41e5d82dcfa36520854425a89c6e2"; });
  # END


A region is updated when either the name or one word of the groups string
matches any additional argument which is "hack-nix" in this example.

local disk locations:
${NIX_REPOSITORY_MANAGER_REPO_DIR}/dist/$name.tar.gz  # the snapshot file
${NIX_REPOSITORY_MANAGER_REPO_DIR}/$name              # the repository
${NIX_REPOSITORY_MANAGER_REPO_DIR}/$name.log          # update log containing rev number and date


Make nix know about this location by putting this into your ~/.nixpkgs/config.nix:

{
  sourceFromHead.managedRepoDir = builtins.getEnv "NIX_REPOSITORY_MANAGER_REPO_DIR";
  sourceFromHead.useLocalRepos = true; # set to false to fetch sources given by fetchurl command
}