-
Notifications
You must be signed in to change notification settings - Fork 169
/
Copy pathdefault.nix
74 lines (70 loc) · 2.21 KB
/
default.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
{ nixpkgs ? import ../nix/nixpkgs.nix {}
, ghc ? nixpkgs.haskell.packages.ghc88 # TODO: Fixes for GHC 9+
}:
with nixpkgs;
let
docsEnv = poetry2nix.mkPoetryEnv {
projectDir = ./.;
};
chinookPostgresRaw = fetchurl {
url = "https://raw.githubusercontent.com/lerocha/chinook-database/e7e6d5f008e35d3f89d8b8a4f8d38e3bfa7e34bd/ChinookDatabase/DataSources/Chinook_PostgreSql.sql";
sha256 = "sha256-CVQAyq0WlAn7+0d72nsm9krVDLtMA1QcgHJhwdttNC4=";
};
chinookPostgres = runCommand "chinook-postgres" {} ''
${glibc.bin}/bin/iconv -f ISO-8859-2 -t UTF-8 ${chinookPostgresRaw} > $out
'';
chinookSqliteRaw = fetchurl {
url = "https://raw.githubusercontent.com/lerocha/chinook-database/e7e6d5f008e35d3f89d8b8a4f8d38e3bfa7e34bd/ChinookDatabase/DataSources/Chinook_Sqlite.sql";
sha256 = "sha256-Zu+IP8fhmYwpgofjtMJLvL8jFRlKJ43mjLANivq6Q9s=";
};
chinookSqlite = runCommand "chinook-sqlite" {} ''
tail -c +4 ${chinookSqliteRaw} > $out
'';
in
stdenv.mkDerivation {
pname = "beam-docs";
version = "0";
src = nix-gitignore.gitignoreFilterSource
(path: type: let
prefix = "${builtins.toPath ./..}/";
strippedPath = lib.removePrefix prefix path;
in lib.or
(builtins.elem strippedPath [
"beam-postgres"
"beam-sqlite"
])
(builtins.any (lib.flip lib.hasPrefix strippedPath) [
"build-docs.sh"
"mkdocs.yml"
"docs"
"beam-postgres/examples"
"beam-postgres/beam-docs.sh"
"beam-sqlite/examples"
"beam-sqlite/beam-docs.sh"
])
)
[]
./..;
nativeBuildInputs = [
# (beamGhc.ghc.withPackages beamLib.beamPackageList)
docsEnv
poetry
postgresql
sqlite
curl
pv
];
buildPhase = ''
mkdir postgres tmp
initdb -D postgres
echo "unix_socket_directories = '$(pwd)/tmp'" >> postgres/postgresql.conf
pg_ctl -D postgres start
mkdir -p docs/.beam-query-cache/chinook-data
cp ${chinookPostgres} docs/.beam-query-cache/chinook-data/Chinook_PostgreSql.sql
cp ${chinookSqlite} docs/.beam-query-cache/chinook-data/Chinook_Sqlite.sql
CI=true BEAM_DOC_BACKEND="beam-postgres beam-sqlite" bash ./build-docs.sh builddocs
'';
installPhase = ''
cp -r site $out
'';
}