-
-
Notifications
You must be signed in to change notification settings - Fork 90
/
flake.nix
164 lines (161 loc) · 6.03 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
{
description = "VAST as a standalone app or NixOS module";
nixConfig = {
extra-substituters = "https://vast.cachix.org";
extra-trusted-public-keys = "vast.cachix.org-1:0L8rErLUuFAdspyGYYQK3Sgs9PYRMzkLEqS2GxfaQhA=";
};
inputs.nixpkgs.url = "github:NixOS/nixpkgs/9499706a638d2ae434a89595a9d5024486677ada";
inputs.flake-compat.url = "github:edolstra/flake-compat";
inputs.flake-compat.flake = false;
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nix-filter.url = "github:numtide/nix-filter";
outputs = {
self,
nixpkgs,
flake-utils,
...
} @ inputs:
{
nixosModules.vast = {
imports = [
./nix/module.nix
];
_module.args = {
inherit (self.packages."x86_64-linux") vast;
};
};
}
// flake-utils.lib.eachSystem ["x86_64-linux"] (
system: let
overlay = import ./nix/overlay.nix {inherit inputs versionShortOverride versionLongOverride;};
pkgs = nixpkgs.legacyPackages."${system}".appendOverlays [overlay];
inherit
(builtins.fromJSON (builtins.readFile ./version.json))
vast-version-fallback
vast-version-rev-count
;
hasVersionSuffix = builtins.hasAttr "revCount" self;
versionSuffix =
if hasVersionSuffix
then "-${builtins.toString (self.revCount - vast-version-rev-count)}-g${builtins.substring 0 10 self.rev}"
else "";
# Simulate `git describe --abbrev=10 --match='v[0-9]*`.
# We would like to simulate `--dirty` too, but that is currently not
# possible (yet?: https://github.com/NixOS/nix/pull/5385).
versionShortOverride =
"${vast-version-fallback}"
# If self.revCount is equal to the refCount of the tagged commit, then
# self.rev must be the tagged commit and the fallback itself is the
# correct version. If not we append the difference between both counts
# and the abbreviated commit hash.
pkgs.lib.optionalString (hasVersionSuffix && self.revCount > vast-version-rev-count)
versionSuffix;
# Simulate `git describe --abbrev=10 --long --match='v[0-9]*`.
versionLongOverride = "${vast-version-fallback}${versionSuffix}";
stream-image = {
name,
pkg,
}: {
type = "app";
program = "${pkgs.dockerTools.streamLayeredImage {
inherit name;
# Don't overwrite "latest" Dockerfile based build.
tag = "latest-nix";
config = let
vast-dir = "/var/lib/vast";
in {
Entrypoint = ["${pkgs.lib.getBin pkg}/bin/vast"];
CMD = ["--help"];
Env = [
# When changing these, make sure to also update the entries in the
# Dockerfile.
"VAST_ENDPOINT=0.0.0.0:42000"
"VAST_DB_DIRECTORY=${vast-dir}"
"VAST_LOG_FILE=/var/log/vast/server.log"
];
ExposedPorts = {
"42000/tcp" = {};
};
WorkingDir = "${vast-dir}";
Volumes = {
"${vast-dir}" = {};
};
};
}}";
};
in rec {
inherit pkgs;
packages = flake-utils.lib.flattenTree {
vast = pkgs.vast;
vast-static = pkgs.pkgsStatic.vast;
vast-ce = pkgs.vast-ce;
vast-ce-static = pkgs.pkgsStatic.vast-ce;
vast-full = pkgs.vast-full;
vast-full-static = pkgs.pkgsStatic.vast-full;
vast-integration-test-shell = pkgs.mkShell {
packages = pkgs.vast-integration-test-deps;
};
static-shell = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
git
nixUnstable
coreutils
];
};
default = pkgs.vast;
};
apps.vast = flake-utils.lib.mkApp {drv = packages.vast;};
apps.vast-static = flake-utils.lib.mkApp {drv = packages.vast-static;};
apps.vast-ce = flake-utils.lib.mkApp {drv = packages.vast-ce;};
apps.vast-ce-static = flake-utils.lib.mkApp {drv = packages.vast-ce-static;};
apps.vast-full = flake-utils.lib.mkApp {drv = packages.vast-full;};
apps.vast-full-static = flake-utils.lib.mkApp {drv = packages.vast-full-static;};
apps.stream-vast-image = stream-image {
name = "tenzir/vast";
pkg = self.packages.${system}.vast;
};
apps.stream-vast-slim-image = stream-image {
name = "tenzir/vast-slim";
pkg = self.packages.${system}.vast-static;
};
apps.stream-vast-ce-image = stream-image {
name = "tenzir/vast-ce";
pkg = self.packages.${system}.vast-ce;
};
apps.stream-vast-ce-slim-image = stream-image {
name = "tenzir/vast-ce-slim";
pkg = self.packages.${system}.vast-ce-static;
};
apps.stream-vast-full-image = stream-image {
name = "tenzir/vast-full";
pkg = self.packages.${system}.vast-full;
};
apps.stream-vast-full-slim-image = stream-image {
name = "tenzir/vast-full-slim";
pkg = self.packages.${system}.vast-full-static;
};
apps.default = apps.vast;
devShell = import ./shell.nix {inherit pkgs;};
formatter = pkgs.alejandra;
hydraJobs =
{inherit packages;}
// (
let
vast-vm-tests =
nixpkgs.legacyPackages."${system}".callPackage ./nix/nixos-test.nix
{
# FIXME: the pkgs channel has an issue made the testing creashed
makeTest = import (nixpkgs.outPath "/nixos/tests/make-test-python.nix");
inherit self pkgs;
};
in
pkgs.lib.optionalAttrs pkgs.stdenv.isLinux {
inherit
(vast-vm-tests)
vast-vm-systemd
;
}
);
}
);
}