-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathblog.nix
104 lines (86 loc) · 3.24 KB
/
blog.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
let
all-hies = import (builtins.fetchTarball "https://github.com/infinisil/all-hies/tarball/master") {};
in
{ pkgs ? import <nixpkgs> {}
, thirdparty ? []
, nur ? import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") {
pkgs = pkgs;
}
}:
with pkgs;
let
# -------------- Utils -------------
script = { ... } @ args: nur.repos.ysndr.lib.wrap (
{
shell = true;
} // args
);
# ------------- Haskell ------------
# hie = all-hies.selection { selector = p: { inherit (p) ghc865; }; };
haskellPackages' = haskellPackages.extend (
self: super: with pkgs.haskell.lib; {
# hakyll = appendPatch (dontCheck (super.callHackage "hakyll" "4.13.4.1" {})) ./hakyll.patch;
# hakyll-images = unmarkBroken super.hakyll-images;
JuicyPixels-extra = super.callHackage "JuicyPixels-extra" "0.4.1" {};
# pandoc = super.callHackage "pandoc" "2.14.0.1" {};
# hakyll-sass = unmarkBroken super.hakyll-sass;
}
);
# --------------- JS --------------
css-tools = (import ./css-tools { inherit pkgs; });
# ------------ dist ---------------
thirdparty' = linkFarm "thirdparty" thirdparty;
# ------------- generator -----------
generator = (haskellPackages'.callCabal2nix "Site" "${./generator}" {});
generator-with-thirdparty =
symlinkJoin {
name = "generator-with-thirdparty";
paths = [generator css-tools.shell.nodeDependencies css-tools.package ];
buildInputs = [ makeWrapper ];
postBuild = ''
wrapProgram $out/bin/generator \
--set THIRDPARTY "${thirdparty'}" \
--set POSTCSS_MODULES "${css-tools.shell.nodeDependencies}/lib/node_modules" \
--prefix NODE_PATH : ${css-tools.shell.nodeDependencies}/lib/node_modules \
--prefix PATH : ${css-tools.shell.nodeDependencies}/bin
'';
};
# --------------- Commands ----------------
generate-website = script {
name = "generate-website";
paths = [ generator-with-thirdparty git css-tools.shell.nodeDependencies ];
script = ''
generator rebuild
'';
};
# ---------------- Shell ------------------
haskell-env = haskellPackages'.ghcWithHoogle (
hp: with hp; [ haskell-language-server cabal-install ]
++ generator.buildInputs
);
shell = mkShell {
name = "blog-env";
buildInputs = [
haskell-env
css-tools.shell.nodeDependencies
];
shellHook = ''
export THIRDPARTY="${thirdparty'}"
export HAKYLL_ENV="development"
export POSTCSS_MODULES="${css-tools.shell.nodeDependencies}/lib/node_modules"
export NODE_PATH="$POSTCSS_MODULES:$NODE_PATH"
export NODE_ENV="$HAKYLL_ENV"
export HIE_HOOGLE_DATABASE="${haskell-env}/share/doc/hoogle/default.hoo"
export NIX_GHC="${haskell-env}/bin/ghc"
export NIX_GHCPKG="${haskell-env}/bin/ghc-pkg"
export NIX_GHC_DOCDIR="${haskell-env}/share/doc/ghc/html"
export NIX_GHC_LIBDIR=$( $NIX_GHC --print-libdir )
'';
};
in
{
inherit shell generator generator-with-thirdparty generate-website;
ci = {
compile = generate-website;
};
}