diff --git a/README.md b/README.md index 5ad6114..776d5a7 100644 --- a/README.md +++ b/README.md @@ -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//ghc--i386-deb8-linux.tar.xz' +$ niv add file \ + ghc \ + 'https://downloads.haskell.org/~ghc//ghc--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: @@ -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 + / 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/.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 @@ -234,6 +257,24 @@ Available options: -v,--version VERSION Equivalent to --attribute version= -t,--template URL Used during 'update' when building URL. Occurrences of 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/.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 + -a,--attribute KEY=VAL Set the package spec attribute to -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. @@ -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 to - -b,--branch BRANCH Equivalent to --attribute branch= - -o,--owner OWNER Equivalent to --attribute owner= - -r,--repo REPO Equivalent to --attribute repo= - -v,--version VERSION Equivalent to --attribute version= - -t,--template URL Used during 'update' when building URL. Occurrences - of 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 ``` diff --git a/README.tpl.md b/README.tpl.md index dda90c5..ebb6d40 100644 --- a/README.tpl.md +++ b/README.tpl.md @@ -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//ghc--i386-deb8-linux.tar.xz' ``` @@ -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 ``` diff --git a/default.nix b/default.nix index e15158c..539522f 100644 --- a/default.nix +++ b/default.nix @@ -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)) diff --git a/site/niv.svg b/site/niv.svg index 7150fed..123d514 100644 --- a/site/niv.svg +++ b/site/niv.svg @@ -1,4 +1,4 @@ - + @@ -44,5 +44,5 @@ - $ niv initCreating nix/sources.nixCreating nix/sources.jsonImporting 'niv' ...Reading sources fileunpacking...path is '/nix/store/n19hv2jxramvysq4sbbn49y7kngc4cyz-aedf42ae0ac4941b7d31963c0e5e2a3d8b74b216.tar.gz'Writing new sources fileImporting 'nixpkgs' ...$ niv add stedolan/jqpath is '/nix/store/wbq0p56kd31j6zznjlaxahm8815gqcwk-46d3867a08a9206685e2b6a8e19f5ad9f6ab4b39.tar.gz'path is '/nix/store/yjz2v8kfk2jkzc0w7lh43hfmcafpqs33-ad9fc9f559e78a764aac20f669f23cdd020cd943.tar.gz' + $ niv initCreating nix/sources.nixCreating nix/sources.jsonImporting 'niv' ...Reading sources fileunpacking...path is '/nix/store/8xssb8zq6i6268v34qgrmz12m4wdip0l-a489b65a5c3a29983701069d1ce395b23d9bde64.tar.gz'Writing new sources fileImporting 'nixpkgs' ...$ niv add stedolan/jqpath is '/nix/store/wbq0p56kd31j6zznjlaxahm8815gqcwk-46d3867a08a9206685e2b6a8e19f5ad9f6ab4b39.tar.gz'path is '/nix/store/yjz2v8kfk2jkzc0w7lh43hfmcafpqs33-ad9fc9f559e78a764aac20f669f23cdd020cd943.tar.gz' \ No newline at end of file