From aa848bf39ad8f0956be0b7adb919ce4abc659ec5 Mon Sep 17 00:00:00 2001 From: Nicolas Mattia Date: Fri, 8 Feb 2019 19:29:48 +0100 Subject: [PATCH] Update README --- README.md | 41 +++++++++++++++++++++++++++++++++++++---- README.tpl.md | 32 ++++++++++++++++++++++++++++---- nix/packages.nix | 24 ++++++------------------ 3 files changed, 71 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 2012a4e..333b8f9 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ [![CircleCI](https://circleci.com/gh/nmattia/niv.svg?style=svg)](https://circleci.com/gh/nmattia/niv) -A tool for dealing with third-party packages in [Nix]. +A tool for dealing with third-party packages in [Nix]. Read more about it in +the [usage](#usage) section. ## Install @@ -23,9 +24,20 @@ $ snack run -- ## Usage -* [Add](#add) -* [Update](#update) -* [Drop](#drop) +`niv` simplifies [adding](#add) and [updating](#update) dependencies in Nix +projects. It uses a single file, `nix/sources.json`, where it stores the data +necessary for fetching and updating the packages. + +* [Add](#add): inserts a package in `nix/sources.json`. +* [Update](#update): updates one or all packages in `nix/sources.json`. +* [Drop](#drop): deletes a package from `nix/sources.json`. + +`niv` has two more utility functions: + +* [Init](#init): bootstraps a Nix projects, in particular creates a + `nix/sources.json` file containing `niv` and `nixpkgs` as well as a + `nix/sources.nix` file that returns the sources as a Nix object. +* [Show](#show): shows the packages' information. ``` NIV - Version manager for Nix projects @@ -114,4 +126,25 @@ Available options: ``` +### Init + +``` +Usage: niv init + Initialize a Nix project. Existing files won't be modified. + +Available options: + -h,--help Show this help text + +``` + +### show + +``` +Usage: niv show + +Available options: + -h,--help Show this help text + +``` + [Nix]: https://nixos.org/nix/ diff --git a/README.tpl.md b/README.tpl.md index 184dc5c..da013ad 100644 --- a/README.tpl.md +++ b/README.tpl.md @@ -2,7 +2,8 @@ [![CircleCI](https://circleci.com/gh/nmattia/niv.svg?style=svg)](https://circleci.com/gh/nmattia/niv) -A tool for dealing with third-party packages in [Nix]. +A tool for dealing with third-party packages in [Nix]. Read more about it in +the [usage](#usage) section. ## Install @@ -23,9 +24,20 @@ $ snack run -- ## Usage -* [Add](#add) -* [Update](#update) -* [Drop](#drop) +`niv` simplifies [adding](#add) and [updating](#update) dependencies in Nix +projects. It uses a single file, `nix/sources.json`, where it stores the data +necessary for fetching and updating the packages. + +* [Add](#add): inserts a package in `nix/sources.json`. +* [Update](#update): updates one or all packages in `nix/sources.json`. +* [Drop](#drop): deletes a package from `nix/sources.json`. + +`niv` has two more utility functions: + +* [Init](#init): bootstraps a Nix projects, in particular creates a + `nix/sources.json` file containing `niv` and `nixpkgs` as well as a + `nix/sources.nix` file that returns the sources as a Nix object. +* [Show](#show): shows the packages' information. ``` replace_niv_help @@ -49,4 +61,16 @@ replace_niv_update_help replace_niv_drop_help ``` +### Init + +``` +replace_niv_init_help +``` + +### show + +``` +replace_niv_show_help +``` + [Nix]: https://nixos.org/nix/ diff --git a/nix/packages.nix b/nix/packages.nix index d228e5e..6906e42 100644 --- a/nix/packages.nix +++ b/nix/packages.nix @@ -12,27 +12,15 @@ rec (runCommand "niv_help" { buildInputs = [ niv ]; } "niv --help > $out" ); - niv_add_help = builtins.readFile - (runCommand "niv_add_help" { buildInputs = [ niv ]; } - "niv add --help > $out" - ); - niv_update_help = builtins.readFile - (runCommand "niv_update_help" { buildInputs = [ niv ]; } - "niv update --help > $out" - ); - niv_drop_help = builtins.readFile - (runCommand "niv_drop_help" { buildInputs = [ niv ]; } - "niv drop --help > $out" + niv_cmd_help = cmd: builtins.readFile + (runCommand "niv_${cmd}_help" { buildInputs = [ niv ]; } + "niv ${cmd} --help > $out" ); + cmds = [ "add" "update" "drop" "init" "show" ]; }; lib.replaceStrings - [ - "replace_niv_help" - "replace_niv_add_help" - "replace_niv_update_help" - "replace_niv_drop_help" - ] - [ niv_help niv_add_help niv_update_help niv_drop_help ] + ([ "replace_niv_help" ] ++ (map (cmd: "replace_niv_${cmd}_help") cmds)) + ([ niv_help ] ++ (map niv_cmd_help cmds)) template ); readme-test = runCommand "README-test" {}