generated from serokell/metatemplates
-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
121 lines (108 loc) · 3.62 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
# SPDX-FileCopyrightText: 2021 Serokell <https://serokell.io>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
{
nixConfig = {
flake-registry = "https://github.com/serokell/flake-registry/raw/master/flake-registry.json";
};
inputs = {
haskell-nix = {
inputs.hackage.follows = "hackage";
inputs.stackage.follows = "stackage";
};
hackage.flake = false;
stackage.flake = false;
};
outputs = { self, nixpkgs, haskell-nix, serokell-nix, deploy-rs, hackage, stackage, nix-npm-buildpackage, flake-utils }:
nixpkgs.lib.recursiveUpdate
(let
system = "x86_64-linux";
inherit (nixpkgs.lib) mapAttrs;
inherit (nixpkgs.legacyPackages.${system}) linkFarm;
mkEdnaNode = hostName:
let
profile = with self.packages.${system};
linkFarm "edna-deploy-profile" [
{ name = "backend.tar.gz";
path = docker-backend; }
{ name = "frontend.tar.gz";
path = docker-frontend; }
];
in {
hostname = "${hostName}.edna.serokell.team";
sshOpts = [ "-p" "17788" ];
profiles.edna-docker = {
sshUser = "deploy";
path = deploy-rs.lib.${system}.activate.custom profile
''
sudo systemctl restart docker-backend
sudo systemctl restart docker-frontend
'';
};
};
in {
# Do not roll back profile closure deployment
deploy.magicRollback = false;
deploy.nodes.staging = mkEdnaNode "staging";
deploy.nodes.demo = mkEdnaNode "demo";
checks = mapAttrs (_: lib: lib.deployChecks self.deploy) deploy-rs.lib;
})
(flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
let
inherit (serokell-nix.lib) pkgsWith;
pkgs = pkgsWith nixpkgs.legacyPackages.${system} [
nix-npm-buildpackage.overlay
haskell-nix.overlay
serokell-nix.overlay
];
analysis-env = pkgs.callPackage ./analysis { };
backend = pkgs.callPackage ./backend {
inherit analysis-env;
EDNA_ANALYSIS_DIR = ./analysis;
};
docker = pkgs.callPackage ./docker.nix {
backend = backend.server;
inherit frontend;
};
frontend = pkgs.callPackage ./frontend { };
frontendCheck = checkPhase:
frontend.overrideAttrs (_: {
doBuild = false;
doCheck = true;
inherit checkPhase;
});
in {
defaultPackage = self.packages.${system}.backend-server;
packages = {
analysis-env = analysis-env;
backend-lib = backend.library;
backend-server = backend.server;
docker-backend = docker.backend-image;
docker-frontend = docker.frontend-image;
frontend = frontend;
};
checks = {
backend-test = backend.test;
frontend-stylelint = frontendCheck "yarn run stylelint";
frontend-tscompile = frontendCheck "yarn run tscompile";
frontend-tslint = frontendCheck "yarn run tslint";
};
# stack2cabal is broken because of strict constraints, set 'jailbreak' to ignore them
packages.stack2cabal = pkgs.haskell.lib.overrideCabal pkgs.haskellPackages.stack2cabal (drv: {
jailbreak = true;
broken = false;
});
devShell = pkgs.mkShell {
inputsFrom = [ self.packages.${system}.backend-lib ];
buildInputs = with pkgs.haskellPackages; [
cabal-install hpack hlint self.packages.${system}.stack2cabal
deploy-rs.defaultPackage.${system}
pkgs.skopeo
pkgs.reuse
pkgs.bats
backend.server
self.packages.${system}.analysis-env
];
};
}));
}