-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathshell.nix
More file actions
executable file
·63 lines (54 loc) · 2.07 KB
/
Copy pathshell.nix
File metadata and controls
executable file
·63 lines (54 loc) · 2.07 KB
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
53
54
55
56
57
58
59
60
61
62
{ pkgs ? import <nixpkgs> { } }:
let
updateCabal = pkgs.writers.writeBashBin "update-cabal" ''
echo "# created by cabal2nix " > ${toString ./.}/current-project.nix
cd ${toString ./.}
${pkgs.cabal2nix}/bin/cabal2nix . >> ${toString ./.}/current-project.nix
'';
run = pkgs.writers.writeBashBin "run" ''
cd ${toString ./.}
${pkgs.cabal-install}/bin/cabal run site -- clean
${pkgs.cabal-install}/bin/cabal run site -- watch
'';
deploy = pkgs.writers.writeBashBin "deploy" ''
cd ${toString ./.}
${pkgs.cabal-install}/bin/cabal run site -- clean
${pkgs.cabal-install}/bin/cabal run site -- build
${pkgs.cabal-install}/bin/cabal run site -- deploy
'';
genOptions = pkgs.writers.writeBashBin "gen-options" ''
cd ${toString ./options}
for option in `ls | egrep json$`
do
file=`basename $option ".json"`
echo $file
cat > ${toString ./options}/''${file}.html <<EOF
---
title: ''${file}
letter: ''${file:0:1}
info: ""
---
EOF
# create first part
${pkgs.pandoc}/bin/pandoc --from markdown --to html5 \
${toString ./options}/''${file}.markdown \
>> ${toString ./options}/''${file}.html
echo '<ul class="options-list">' >> ${toString ./options}/''${file}.html
# create options list
cat ${toString ./options}/''${file}.json \
| ${pkgs.jq}/bin/jq --raw-output 'to_entries | .[] | "
<li>
<strong>\(@html "\( .key )" )</strong>
<p><strong>type</strong>: \( .value.type )</p>
<p><strong>default</strong>: \( .value.default )</p>
<p><strong>description</strong>: \( @html "\(.value.description)" )</p>
<p><strong>defined</strong>: in <a href=\"\( .value.declarations[0].url )\"> \( .value.declarations[0].path )</a>
\( if .value.example then "<p><strong>example</strong>: \(.value.example)" else "" end )
</li>
"' >> ${toString ./options}/''${file}.html
echo "</ul>" >> ${toString ./options}/''${file}.html
done
'';
in pkgs.mkShell {
buildInputs = with pkgs; [ updateCabal run deploy lessc genOptions ];
}