generated from tweag/project
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
107 lines (94 loc) · 2.82 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
{
inputs = {
crane = {
url = "github:ipetkov/crane";
};
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixtract.url = "github:tweag/nixtract";
};
outputs =
{ self
, crane
, nixpkgs
, nixtract
}:
let
supportedSystems = [
"aarch64-darwin"
"aarch64-linux"
"i686-linux"
"x86_64-darwin"
"x86_64-linux"
];
pkgsFor = nixpkgs.lib.genAttrs supportedSystems (system: import nixpkgs {
inherit system;
});
forAllSystems = fn: nixpkgs.lib.genAttrs supportedSystems (system: fn rec {
inherit system;
pkgs = pkgsFor.${system};
inherit (pkgs) lib;
});
mkGenealogosArtifacts = pkgs: rec {
crane-lib = crane.mkLib nixpkgs.legacyPackages.${pkgs.system};
nixtract-cli = nixtract.defaultPackage.${pkgs.system};
crane-outputs = import ./nix/crane.nix {
inherit pkgs crane-lib nixtract-cli;
inherit (pkgs) cyclonedx-cli;
};
};
in
{
overlays.default = import ./nix/overlays.nix {
inherit crane;
};
nixosModules.default = import ./nix/genealogos-module.nix { inherit mkGenealogosArtifacts; };
packages = forAllSystems ({ system, pkgs, ... }:
let artifacts = mkGenealogosArtifacts pkgs; in
let
tmp = pkgs.runCommand "tmp" { } ''
mkdir $out
mkdir -m 1777 $out/tmp
'';
in
artifacts.crane-outputs.packages // {
dockerImage = pkgs.dockerTools.buildLayeredImageWithNixDb {
name = "genealogos";
tag = "latest";
contents = [ artifacts.crane-outputs.packages.genealogos-api tmp ];
config = {
EntryPoint = [ "genealogos-api" ];
ExposedPorts."8000" = { };
Env = [
"ROCKET_ADDRESS=0.0.0.0"
"ROCKET_PORT=8000"
"SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
];
};
};
}
);
checks = forAllSystems ({ system, pkgs, ... }:
let artifacts = mkGenealogosArtifacts pkgs; in
artifacts.crane-outputs.checks
);
apps = forAllSystems ({ system, pkgs, ... }:
let artifacts = mkGenealogosArtifacts pkgs; in
{
default = {
type = "app";
program =
pkgs.lib.getExe artifacts.crane-outputs.packages.genealogos-cli;
};
});
devShells = forAllSystems ({ system, pkgs, ... }:
let artifacts = mkGenealogosArtifacts pkgs; in
{
default = artifacts.crane-lib.devShell {
inherit (artifacts.crane-outputs) checks;
packages = with pkgs; [
rust-analyzer
];
};
});
};
}