-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
94 lines (83 loc) · 2.09 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
{ pkgs ? null, compiler ? null }:
let
nixpkgs =
if isNull pkgs then
import (import ./nix/sources.nix).nixos { }
else if builtins.typeOf pkgs == "set" then
pkgs
else
import (builtins.getAttr pkgs (import ./nix/sources.nix)) { };
haskellPackagesBase =
if isNull compiler then
nixpkgs.haskellPackages
else
nixpkgs.haskell.packages.${compiler};
appSrcRegex = [
"^app.*$"
"^peits.cabal$"
"^LICENSE$"
];
siteSrcRegex = [
"^posts.*$"
"^pages.*$"
"^static.*$"
"^templates.*$"
"^config\.yml$"
"^citations.*$"
];
haskellPackages = haskellPackagesBase.override {
overrides = self: super:
let
hsPkgs = import ./nix/overrides.nix {
pkgs = nixpkgs;
self = self;
super = super;
};
src = nixpkgs.lib.sourceByRegex ./. appSrcRegex;
drv = self.callCabal2nix "peits" src { };
in
hsPkgs // { peits = drv; };
};
isMac =
builtins.any
(arch: builtins.currentSystem == arch)
[ "x86_64-darwin" ];
inotify = if isMac then [ nixpkgs.entr ] else [ nixpkgs.inotify-tools ];
nodejs = nixpkgs.nodejs-16_x;
mermaid-cli = nixpkgs.nodePackages.mermaid-cli.override { nodejs = nodejs; };
yarn = nixpkgs.yarn.override { nodejs = nodejs; };
deps = [
nixpkgs.python310Packages.pygments
nixpkgs.minify
# mermaid-cli
];
site = nixpkgs.stdenv.mkDerivation {
name = "alexpeits-github-io";
buildInputs = deps ++ [
nixpkgs.glibcLocales
];
LANG = "en_US.UTF-8";
src = nixpkgs.lib.sourceByRegex ./. siteSrcRegex;
buildPhase = ''
${haskellPackages.peits}/bin/peits
'';
installPhase = ''
mkdir "$out"
cp -R _build "$out/_build"
'';
};
shell = haskellPackages.shellFor {
packages = ps: [ ps.peits ];
buildInputs = deps ++ inotify ++ [
haskellPackages.ghcid
haskellPackages.cabal-install
haskellPackages.ormolu
nodejs
yarn
];
withHoogle = true;
};
in
if nixpkgs.lib.inNixShell
then shell
else { site = site; peits = haskellPackages.peits; }