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 15, 2019
1 parent 4d75f7e commit 25fc4c9
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 23 deletions.
71 changes: 52 additions & 19 deletions README.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 Down Expand Up @@ -213,25 +219,61 @@ 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 repository

```
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] |
[-t|--template URL]) ([-b|--branch BRANCH] |
[-o|--owner OWNER] | [-r|--repo REPO] |
[-v|--version VERSION])
Add GitHub 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,--template URL Used during 'update' when building URL. Occurrences
of <foo> are replaced with attribute 'foo'.
-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>
-h,--help Show this help text
```

#### Add a file

```
Examples:
niv add file my-package -v alpha-0.1 -t http://example.com/archive/<version>.zip
Usage: niv add file [-n|--name NAME] PACKAGE ([-a|--attribute KEY=VAL] |
[-t|--template URL]) [-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,--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
Expand All @@ -250,22 +292,13 @@ 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] | [-t|--template URL])
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 repository

```
replace_niv_add_github_help
```

#### Add a file

```
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

0 comments on commit 25fc4c9

Please sign in to comment.