generated from srid/ema-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
72 lines (72 loc) · 2.47 KB
/
flake.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
{
description = "Ema template app";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
haskell-flake.url = "github:srid/haskell-flake";
};
outputs = inputs@{ self, nixpkgs, flake-parts, haskell-flake, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = nixpkgs.lib.systems.flakeExposed;
imports = [
haskell-flake.flakeModule
];
perSystem = { self', config, inputs', pkgs, lib, ... }: {
# "haskellProjects" comes from https://github.com/srid/haskell-flake
haskellProjects.project = {
devShell.tools = hp:
let
# Workaround for https://github.com/NixOS/nixpkgs/issues/140774
fixCyclicReference = drv:
pkgs.haskell.lib.overrideCabal drv (_: {
enableSeparateBinOutput = false;
});
in
{
inherit (pkgs)
treefmt
nixpkgs-fmt
foreman;
inherit (pkgs.haskellPackages)
cabal-fmt tailwind;
inherit (hp)
fourmolu;
ghcid = fixCyclicReference hp.ghcid;
haskell-language-server = hp.haskell-language-server.overrideScope (lself: lsuper: {
ormolu = fixCyclicReference hp.ormolu;
});
};
settings = {
NixHaskellIndex = { self, super, ... }: {
custom = _: super.NixHaskellIndex.overrideAttrs (_: {
DATAFILE = config.packages.data;
});
};
};
};
apps.default = self'.apps.project-NixHaskellIndex;
packages = {
default = self'.packages.project-NixHaskellIndex;
data = pkgs.writeTextFile {
name = "data";
text =
let data = import ./src/NHI/data.nix { inherit inputs pkgs lib; };
in builtins.toJSON data;
};
site = pkgs.runCommand "site"
{ }
''
mkdir -p $out
pushd ${self}
${lib.getExe config.packages.default} \
gen $out
${lib.getExe pkgs.haskellPackages.tailwind} \
-o $out/tailwind.css 'src/**/*.hs'
'';
};
devShells.default = config.devShells.project.overrideAttrs (_: {
DATAFILE = config.packages.data;
});
};
};
}