Skip to content

Commit

Permalink
readme: introduce add subcommand file and github
Browse files Browse the repository at this point in the history
  • Loading branch information
nlewo committed Apr 16, 2019
1 parent dcf24ab commit 83e906f
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 31 deletions.
80 changes: 55 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,27 @@ The following data was added in `nix/sources.json` for `jq`:
}
```

Alternatively, the GitHub `add` sub-command could have been used:

``` shell
$ niv add github stedolan/jq
```

#### Using custom URLs

It is possible to use niv to fetch packages from custom URLs. Run this command
to add the Haskell compiler [GHC] to your `nix/sources.json`:

``` shell
$ niv add ghc \
-v 8.4.3 \
-t 'https://downloads.haskell.org/~ghc/<version>/ghc-<version>-i386-deb8-linux.tar.xz'
$ niv add file \
ghc \
'https://downloads.haskell.org/~ghc/<version>/ghc-<version>-i386-deb8-linux.tar.xz' \
-v 8.4.3 \
```

The option `-v` sets the "version" attribute to `8.4.3`. The option `-t` sets a
template that can be reused by niv when fetching a new URL (see the
documentation for [add](#add) and [update](#update)).
The option `-v` sets the "version" attribute to `8.4.3`. The second
argument sets a template that can be reused by niv when fetching a new
URL (see the documentation for [add](#add) and [update](#update)).

For updating the version of GHC used run this command:

Expand Down Expand Up @@ -213,17 +220,33 @@ Available commands:

#### Add

```
Usage: niv add (COMMAND | PACKAGE)
Add dependency
Available options:
-h,--help Show this help text
Available commands:
github Add GitHub dependency
file Add file dependency
<owner>/<repo> Add GitHub dependency
```

#### Add a GitHub dependency

```
Examples:
niv add stedolan/jq
niv add NixOS/nixpkgs-channels -n nixpkgs -b nixos-18.09
niv add my-package -v alpha-0.1 -t http://example.com/archive/<version>.zip
niv add github stedolan/jq
niv add github NixOS/nixpkgs-channels -n nixpkgs -b nixos-18.09
Usage: niv add [-n|--name NAME] PACKAGE ([-a|--attribute KEY=VAL] |
[-b|--branch BRANCH] | [-o|--owner OWNER] | [-r|--repo REPO] |
[-v|--version VERSION] | [-t|--template URL] | [-T|--type TYPE])
Add dependency
Usage: niv add github [-n|--name NAME] PACKAGE [-a|--attribute KEY=VAL]
([-b|--branch BRANCH] | [-o|--owner OWNER] |
[-r|--repo REPO] | [-v|--version VERSION] |
[-t|--template URL])
Add GitHub dependency
Available options:
-n,--name NAME Set the package name to <NAME>
Expand All @@ -234,6 +257,24 @@ Available options:
-v,--version VERSION Equivalent to --attribute version=<VERSION>
-t,--template URL Used during 'update' when building URL. Occurrences
of <foo> are replaced with attribute 'foo'.
-h,--help Show this help text
```

#### Add a file dependency

```
Examples:
niv add file my-package http://example.com/archive/<version>.zip -v alpha-0.1
Usage: niv add file [-n|--name NAME] PACKAGE URL-TEMPLATE
[-a|--attribute KEY=VAL] [-T|--type TYPE]
Add file dependency
Available options:
-n,--name NAME Set the package name to <NAME>
-a,--attribute KEY=VAL Set the package spec attribute <KEY> to <VAL>
-T,--type TYPE The type of the URL target. The value can be either
'file' or 'tarball'. If not set, the value is
inferred from the suffix of the URL.
Expand All @@ -250,22 +291,11 @@ Examples:
niv update nixpkgs
niv update my-package -v beta-0.2
Usage: niv update [PACKAGE] ([-a|--attribute KEY=VAL] | [-b|--branch BRANCH] |
[-o|--owner OWNER] | [-r|--repo REPO] | [-v|--version VERSION]
| [-t|--template URL] | [-T|--type TYPE])
Usage: niv update [PACKAGE] [-a|--attribute KEY=VAL]
Update dependencies
Available options:
-a,--attribute KEY=VAL Set the package spec attribute <KEY> to <VAL>
-b,--branch BRANCH Equivalent to --attribute branch=<BRANCH>
-o,--owner OWNER Equivalent to --attribute owner=<OWNER>
-r,--repo REPO Equivalent to --attribute repo=<REPO>
-v,--version VERSION Equivalent to --attribute version=<VERSION>
-t,--template URL Used during 'update' when building URL. Occurrences
of <foo> are replaced with attribute 'foo'.
-T,--type TYPE The type of the URL target. The value can be either
'file' or 'tarball'. If not set, the value is
inferred from the suffix of the URL.
-h,--help Show this help text
```
Expand Down
22 changes: 20 additions & 2 deletions README.tpl.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,20 @@ The following data was added in `nix/sources.json` for `jq`:
}
```

Alternatively, the GitHub `add` sub-command could have been used:

``` shell
$ niv add github stedolan/jq
```

#### Using custom URLs

It is possible to use niv to fetch packages from custom URLs. Run this command
to add the Haskell compiler [GHC] to your `nix/sources.json`:

``` shell
$ niv add ghc \
-v 8.4.3 \
$ niv add file ghc \
-v 8.4.3 \
-t 'https://downloads.haskell.org/~ghc/<version>/ghc-<version>-i386-deb8-linux.tar.xz'
```

Expand All @@ -203,6 +209,18 @@ replace_niv_help
replace_niv_add_help
```

#### Add a GitHub dependency

```
replace_niv_add_github_help
```

#### Add a file dependency

```
replace_niv_add_file_help
```

#### Update

```
Expand Down
4 changes: 2 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ rec
);
niv_cmd_help = cmd: builtins.readFile
(pkgs.runCommand "niv_${cmd}_help" { buildInputs = [ niv ]; }
"niv ${cmd} --help > $out"
"niv ${pkgs.lib.replaceStrings ["_"] [" "] cmd} --help > $out"
);
cmds = [ "add" "update" "drop" "init" "show" ];
cmds = [ "add" "add_github" "add_file" "update" "drop" "init" "show" ];
};
pkgs.lib.replaceStrings
([ "replace_niv_help" ] ++ (map (cmd: "replace_niv_${cmd}_help") cmds))
Expand Down
4 changes: 2 additions & 2 deletions site/niv.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 83e906f

Please sign in to comment.