-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflake.nix
135 lines (117 loc) · 3.74 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# SPDX-FileCopyrightText: 2023 Serokell <https://serokell.io>
#
# SPDX-License-Identifier: MPL-2.0
{
nixConfig = {
flake-registry = "https://github.com/serokell/flake-registry/raw/master/flake-registry.json";
};
inputs = {
flake-utils.url = "github:numtide/flake-utils";
flake-compat = {
flake = false;
};
haskell-nix = {
inputs.hackage.follows = "hackage";
inputs.stackage.follows = "stackage";
};
hackage = {
flake = false;
};
stackage = {
flake = false;
};
};
outputs = { self, nixpkgs, haskell-nix, hackage, stackage, serokell-nix, flake-compat, flake-utils, deploy-rs, ... }@inputs:
{
nixosModules.default = import ./module.nix inputs;
deploy.nodes = {
staging = {
hostname = "tejat-prior.gemini.serokell.team";
user = "deploy";
sshOpts = [ "-p 17788" ];
profiles = {
tzbot.path = deploy-rs.lib.x86_64-linux.activate.custom
self.packages.x86_64-linux.tzbot
"sudo /run/current-system/sw/bin/systemctl restart tzbot";
};
};
};
} // (flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
let
haskellPkgs = haskell-nix.legacyPackages."${system}";
pkgs = import nixpkgs {
inherit system;
overlays = [
serokell-nix.overlay
];
};
lib = pkgs.lib;
hs-package-name = "tzbot";
# invoke haskell.nix
hs-pkgs = haskellPkgs.haskell-nix.stackProject {
src = haskellPkgs.haskell-nix.haskellLib.cleanGit {
name = hs-package-name;
src = ./.;
};
# haskell.nix configuration
modules = [{
packages.tzbot = {
ghcOptions = [
"-Werror"
];
# enable haddock for local packages
doHaddock = true;
};
# disable haddock for dependencies
doHaddock = false;
}];
};
hs-pkg = hs-pkgs.${hs-package-name};
# returns the list of all components for a package
get-package-components = pkg:
# library
lib.optional (pkg ? library) pkg.library
# haddock
++ lib.optional (pkg ? library) pkg.library.haddock
# exes, tests and benchmarks
++ lib.attrValues pkg.exes
++ lib.attrValues pkg.tests
++ lib.attrValues pkg.benchmarks;
# all components for the current haskell package
all-components = get-package-components hs-pkg.components;
stack2cabal = haskellPkgs.haskell.lib.overrideCabal haskellPkgs.haskellPackages.stack2cabal
(drv: { jailbreak = true; broken = false; });
in {
# nixpkgs revision pinned by this flake
legacyPackages = pkgs;
# derivations that we can run from CI
checks = {
# builds all haskell components
build-all = pkgs.linkFarmFromDrvs "build-all" all-components;
# runs the test
test = hs-pkg.checks.tzbot-test;
trailing-whitespace = pkgs.build.checkTrailingWhitespace ./.;
reuse-lint = pkgs.build.reuseLint ./.;
shellcheck = pkgs.build.shellcheck ./.;
hlint = pkgs.build.haskell.hlint ./.;
stylish-haskell = pkgs.build.haskell.stylish-haskell ./.;
} // deploy-rs.lib.${system}.deployChecks self.deploy;
devShells = {
ci = pkgs.mkShell {
buildInputs = [
stack2cabal
deploy-rs.defaultPackage.${system}
];
};
doctest = hs-pkgs.shellFor {
withHoogle = false;
# https://github.com/input-output-hk/haskell.nix/issues/839
exactDeps = true;
additional = _ : [ hs-pkg.components.library ];
};
};
packages = {
tzbot = hs-pkg.components.exes.tzbot-exe;
};
}));
}