Skip to content

Commit c4591a9

Browse files
committed
Flakify readme
1 parent 35aa637 commit c4591a9

File tree

4 files changed

+23
-27
lines changed

4 files changed

+23
-27
lines changed

flake.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
in rec {
1111
lib = forAllSystems (system: nixpkgs.legacyPackages."${system}".callPackage ./default.nix { });
1212

13+
packages = forAllSystems (system: {
14+
readme = nixpkgs.legacyPackages."${system}".callPackage ./readme.nix { };
15+
});
16+
1317
# Useful when composing with other flakes:
1418
overlay = import ./overlay.nix;
1519

readme.nix

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
# This script is used to test & generate `README.md`.
2+
{ pkgs }:
23

34
let
4-
sources = import ./nix/sources.nix;
5-
6-
pkgs = import ./nix {
7-
system = builtins.currentSystem;
8-
nixpkgs = "nixpkgs";
9-
};
105

116
naersk = pkgs.callPackage ./default.nix {
127
inherit (pkgs.rustPackages) cargo rustc;
@@ -26,17 +21,11 @@ let
2621
};
2722

2823
in
29-
rec {
30-
body = pkgs.runCommand "readme-body" {
31-
buildInputs = [ docparse ];
32-
} ''
33-
cat ${./README.tpl.md} > $out
34-
docparse ${./config.nix} >> gen
35-
sed -e '/GEN_CONFIGURATION/{r gen' -e 'd}' -i $out
36-
'';
37-
38-
test = pkgs.runCommand "readme-test" { } ''
39-
diff ${./README.md} ${body}
40-
touch $out
41-
'';
42-
}
24+
pkgs.runCommand "readme"
25+
{
26+
buildInputs = [ docparse ];
27+
} ''
28+
cat ${./README.tpl.md} > $out
29+
docparse ${./config.nix} >> gen
30+
sed -e '/GEN_CONFIGURATION/{r gen' -e 'd}' -i $out
31+
''

script/gen

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
#!/usr/bin/env nix-shell
2-
#!nix-shell -i bash
3-
#!nix-shell -I nixpkgs=./nix
4-
#!nix-shell -p nix
1+
#!/usr/bin/env bash
52

63
set -euo pipefail
74

85
echo "Updating README"
96

10-
cat $(nix-build ./readme.nix -A body) > README.md
7+
cat $(nix build .#readme --print-out-paths) > README.md
118
129
echo done

test/fast/readme/default.nix

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
{ ... }:
2-
(import ../../../readme.nix).test
1+
{ pkgs, ... }:
2+
let
3+
readme = pkgs.callPackage ../../../readme.nix { };
4+
in
5+
pkgs.runCommand "readme-test" { } ''
6+
diff ${../../../README.md} ${readme}
7+
touch $out
8+
''

0 commit comments

Comments
 (0)