This repository has been archived by the owner on Nov 13, 2022. It is now read-only.
generated from srid/ema-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
90 lines (86 loc) · 3.17 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
{
description = "Banyan";
inputs = {
banyan-emanote.url = "github:srid/emanote/master";
nixpkgs.follows = "banyan-emanote/nixpkgs";
tailwind-haskell.url = "github:srid/tailwind-haskell";
NanoID = {
url = "github:srid/NanoID/srid";
flake = false;
};
flake-utils.url = "github:numtide/flake-utils";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = inputs@{ self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachSystem [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ] (system:
let
name = "banyan";
overlays = [ ];
pkgs = import nixpkgs { inherit system overlays; config.allowBroken = true; };
# Based on https://github.com/input-output-hk/daedalus/blob/develop/yarn2nix.nix#L58-L71
filter = name: type:
let
baseName = baseNameOf (toString name);
sansPrefix = pkgs.lib.removePrefix (toString ./.) name;
in
# Ignore these files when building source package
!(
baseName == "README.md" ||
sansPrefix == "/bin" ||
sansPrefix == "/content" ||
sansPrefix == "/.github" ||
sansPrefix == "/.vscode" ||
sansPrefix == "/.ghcid"
);
m1MacHsBuildTools =
pkgs.haskellPackages.override {
overrides = self: super:
let
workaround140774 = hpkg: with pkgs.haskell.lib;
overrideCabal hpkg (drv: {
enableSeparateBinOutput = false;
});
in
{
ghcid = workaround140774 super.ghcid;
ormolu = workaround140774 super.ormolu;
};
};
project = returnShellEnv:
pkgs.haskellPackages.developPackage {
inherit returnShellEnv name;
root = pkgs.lib.cleanSourceWith { inherit filter name; src = ./.; };
withHoogle = false;
overrides = self: super: with pkgs.haskell.lib; {
ema = disableCabalFlag inputs.banyan-emanote.inputs.ema.defaultPackage.${system} "with-examples";
emanote = inputs.banyan-emanote.defaultPackage.${system};
tailwind = inputs.tailwind-haskell.defaultPackage.${system};
NanoID = self.callCabal2nix "NanoID" inputs.NanoID { };
};
modifier = drv:
pkgs.haskell.lib.addBuildTools drv
(with (if system == "aarch64-darwin"
then m1MacHsBuildTools
else pkgs.haskellPackages); [
cabal-fmt
cabal-install
ghcid
haskell-language-server
ormolu
pkgs.nixpkgs-fmt
pkgs.foreman
inputs.tailwind-haskell.defaultPackage.${system}
]);
};
in
{
# Used by `nix build` & `nix run`
defaultPackage = project false;
tailwind-haskell = inputs.tailwind-haskell.defaultPackage.${system};
# Used by `nix develop`
devShell = project true;
});
}