-
Notifications
You must be signed in to change notification settings - Fork 88
/
readme.nix
52 lines (43 loc) · 1.06 KB
/
readme.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# This script is used to test & generate `README.md`.
let
sources = import ./nix/sources.nix;
pkgs = import ./nix {
system = builtins.currentSystem;
nixpkgs = "nixpkgs";
};
naersk = pkgs.callPackage ./default.nix {
inherit (pkgs.rustPackages) cargo rustc;
};
docparse = naersk.buildPackage {
root = ./docparse;
src = builtins.filterSource
(
p: t:
let
p' = pkgs.lib.removePrefix (toString ./docparse + "/") p;
in
p' == "Cargo.lock" || p' == "Cargo.toml" || p' == "src" || p' == "src/main.rs"
) ./docparse;
};
in
rec {
body =
let
readme = builtins.readFile ./README.tpl.md;
params = builtins.readFile (
pkgs.runCommand "docparse"
{ buildInputs = [ docparse ]; }
"docparse ${./config.nix} > $out"
);
in
pkgs.writeText "readme" (
builtins.replaceStrings
[ "{{ params }}" ]
[ params ]
readme
);
test = pkgs.runCommand "readme-test" { } ''
diff ${./README.md} ${body}
touch $out
'';
}