1
1
mirror of https://github.com/nmattia/niv.git synced 2024-11-29 00:42:04 +03:00
Easy dependency management for Nix projects
Go to file
2019-01-26 23:39:38 +01:00
nix Implement basic CLI 2019-01-17 23:00:48 +01:00
default.nix Implement basic CLI 2019-01-17 23:00:48 +01:00
Main.hs Add attr discovery 2019-01-26 23:39:38 +01:00
package.yaml Add attr discovery 2019-01-26 23:39:38 +01:00
README.md Add attr discovery 2019-01-26 23:39:38 +01:00

niv

A tool for dealing with third-party packages in Nix.

Building

Inside the provided nix shell:

$ # GHCi:
$ snack ghci
$ # actual build:
$ snack build

Usage

NOTES

  • no support for non-json, to enforce convention
  • fixed path to nix/versions.json, to enforce convention

Commands

Abbreviations:

Attributes

  • -b -> --branch
  • -n -> --name
  • -o -> --owner
  • -r -> --repo
  • -t -> --template
  • -a -> --attribute

VCS

  • -h -> --github
  • -l -> --gitlab

init

  • [<p1> --branch foo <p2> ...]

Creates (if the file doesn't exist)

  • nix/versions.json:
{"nixpkgs": { ... }}

*nix/fetch.nix:

...

*default.nix:

with { fetch = import <fetch>; };
let pkgs = import fetch.nixpkgs;
in pkgs.hello

add

  • <package>: adds the following to the versions file where let <username/repo> = <package>
{ "<repo>":
  { "owner":  "<username>",
    "repo":   "<repo>",
    "rev":    "<latest commit on <branch>>",
    "sha256": "<sha256>",
    "branch": "<branch>"
  }
}
  • --branch: specifies <branch> (default: master)
  • --username <username>: then let <repo> = <package>
  • --gitlab: use gitlab instead of GitHub
  • --attribute <attribute> <value>: sets <attribute> to <value>

If the package already exists, merges with the package (prior to heuristics)

update

  • [p [--commit] [--branch]]
  • []: all packages are updated
  • [p1 p2 ...]: the specified packages are updated
  • --commit <rev>: rev is set to <rev> and the package is prefetched
  • --branch <branch>: branch is set to <branch>, rev is set to the latest revision on that branch and the package is prefetched

show

  • Shows all packages

drop

<p1> <p2>

  • Drops the specified packages

NOTE: should the URLs be used instead? or more simply, how do we differentiate between Gitlab/GitHub?