1
1
mirror of https://github.com/nmattia/niv.git synced 2024-11-07 22:36:53 +03:00

Generate README from niv

This commit is contained in:
Nicolas Mattia 2019-01-30 23:56:35 +01:00
parent 703d1b6408
commit c8d451b153
5 changed files with 97 additions and 10 deletions

View File

@ -70,6 +70,7 @@ getVersionsSpec = do
Just _ -> abortVersionsIsntAMap
Nothing -> abortVersionsIsntJSON
-- TODO: pretty
setVersionsSpec :: VersionsSpec -> IO ()
setVersionsSpec versionsSpec = encodeFile pathNixVersionsJson versionsSpec

View File

@ -31,9 +31,10 @@ Available commands:
init Initialize a Nix project. Existing files won't be
modified.
add Add dependency
show
show
update Update dependencies
drop Drop dependency
```
@ -47,14 +48,15 @@ Examples:
niv add my-package -v alpha-0.1 -t http://example.com/archive/<version>.zip
Usage: niv add PACKAGE ([-b|--branch BRANCH] | [-o|--owner OWNER] |
[-r|--repo REPO] | [-v|--version VERSION] |
[-a|--attribute KEY=VAL] | [-t|--template URL])
[-n|--name NAME]
[-r|--repo REPO] | [-v|--version VERSION] |
[-a|--attribute KEY=VAL] | [-t|--template URL]) [-n|--name NAME]
Add dependency
Available options:
-t,--template URL foo
-t,--template URL Used during 'update' when building URL. Occurrences
of <foo> are replaced with attribute 'foo'.
-h,--help Show this help text
```
@ -67,14 +69,16 @@ Examples:
niv update nixpkgs
niv update my-package -v beta-0.2
Usage: niv update [PACKAGE] ([-b|--branch BRANCH] | [-o|--owner OWNER]
| [-r|--repo REPO] | [-v|--version VERSION] |
[-a|--attribute KEY=VAL] | [-t|--template URL])
Usage: niv update [PACKAGE] ([-b|--branch BRANCH] | [-o|--owner OWNER] |
[-r|--repo REPO] | [-v|--version VERSION] |
[-a|--attribute KEY=VAL] | [-t|--template URL])
Update dependencies
Available options:
-t,--template URL foo
-t,--template URL Used during 'update' when building URL. Occurrences
of <foo> are replaced with attribute 'foo'.
-h,--help Show this help text
```
### Drop
@ -89,6 +93,7 @@ Usage: niv drop PACKAGE
Available options:
-h,--help Show this help text
```
[Nix]: https://nixos.org/nix/

46
README.tpl.md Normal file
View File

@ -0,0 +1,46 @@
# niv
A tool for dealing with third-party packages in [Nix].
## Building
Inside the provided nix shell:
``` bash
$ # GHCi:
$ snack ghci
$ # run:
$ snack run -- <args>
```
## Usage
* [Add](#add)
* [Update](#update)
* [Drop](#drop)
```
replace_niv_help
```
### Add
```
replace_niv_add_help
```
### Update
```
replace_niv_update_help
```
### Drop
```
replace_niv_drop_help
```
[Nix]: https://nixos.org/nix/

View File

@ -1,2 +1,2 @@
with { pkgs = import ./nix; };
pkgs.niv
{ inherit (pkgs) niv readme ; }

View File

@ -10,4 +10,39 @@
(self: super:
{ niv = super.snack-lib.executable ../package.yaml ; }
)
(self: super:
{ readme = self.writeText "README.md"
(with
{ template = builtins.readFile ../README.tpl.md;
niv_help = builtins.readFile
(self.runCommand "niv_help" { buildInputs = [ self.niv ]; }
"niv --help > $out"
);
niv_add_help = builtins.readFile
(self.runCommand "niv_add_help" { buildInputs = [ self.niv ]; }
"niv add --help > $out"
);
niv_update_help = builtins.readFile
(self.runCommand "niv_update_help" { buildInputs = [ self.niv ]; }
"niv update --help > $out"
);
niv_drop_help = builtins.readFile
(self.runCommand "niv_drop_help" { buildInputs = [ self.niv ]; }
"niv drop --help > $out"
);
};
self.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 ]
template
);
}
)
]