-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathflake.nix
74 lines (70 loc) · 2.18 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
{
description = "zureg";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = inputs:
inputs.flake-utils.lib.eachDefaultSystem (system:
let
pkgs = inputs.nixpkgs.legacyPackages.${system};
haskell = pkgs.haskell.packages.ghc96;
package = haskell.callCabal2nix "zureg" ./. {
urlencoded = (pkgs.haskell.lib.doJailbreak haskell.urlencoded);
};
packageExes = pkgs.haskell.lib.justStaticExecutables package;
migrations = pkgs.stdenv.mkDerivation {
name = "migrations";
src = ./lib/Zureg/Database/Migrations;
installPhase = ''
mkdir -p $out/var/lib/zureg/migrations
cp *.sql $out/var/lib/zureg/migrations
'';
};
in {
packages = {
default = package;
docker = pkgs.dockerTools.buildLayeredImage {
name = "jaspervdj/zureg";
tag = "latest";
contents = [
pkgs.cacert
migrations
];
config.Cmd = "${packageExes}/bin/zureg-web";
};
};
devShells = {
default = let
postgres = {
db = "zureg";
password = "hunter2";
port = "5433";
};
in pkgs.mkShell {
buildInputs = [ pkgs.zlib.dev ];
packages = [
pkgs.cabal-install
pkgs.entr
pkgs.jq
pkgs.docker
pkgs.postgresql
pkgs.awscli2
haskell.stylish-haskell
(haskell.ghc.withPackages (p:
package.buildInputs ++ [ p.postgresql-simple ]))
];
shellHook = ''
docker container port ${postgres.db}-postgres || docker run \
--rm \
--name ${postgres.db}-postgres \
-e POSTGRES_DB=${postgres.db} \
-e POSTGRES_PASSWORD=${postgres.password} \
-p ${postgres.port}:5432 \
-d postgres
'';
};
};
formatter = pkgs.nixfmt;
});
}