-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflake.nix
More file actions
90 lines (72 loc) · 2.66 KB
/
Copy pathflake.nix
File metadata and controls
90 lines (72 loc) · 2.66 KB
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
{
description = "OA-Verifier - Zero-trust attestation service";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
# Fixed timestamp for reproducibility (2024-01-01T00:00:00Z)
SOURCE_DATE_EPOCH = "1704067200";
# Go server binary (reproducible)
server = pkgs.buildGoModule {
pname = "oa-verifier";
version = "0.1.0";
src = ./.;
subPackages = [ "cmd/verifier" ];
vendorHash = "sha256-Gw49LP2f8VWvUqViQayxKH+fMuj4OCjCHIgFSBGPvuw=";
CGO_ENABLED = 0;
ldflags = [ "-s" "-w" "-buildid=" ];
preBuild = ''
export SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH}
'';
postInstall = ''
mv $out/bin/verifier $out/bin/oa-verifier
'';
meta = with pkgs.lib; {
description = "OA-Verifier attestation service";
license = licenses.agpl3Plus;
mainProgram = "oa-verifier";
};
};
in {
packages = {
inherit server;
# Reproducible container image
# NOTE: Must be built on x86_64-linux for Azure deployment
# GitHub Actions runs on x86_64-linux, so CI builds work correctly
container = pkgs.dockerTools.buildImage {
name = "oa-verifier";
tag = "latest";
created = "2024-01-01T00:00:00Z"; # Fixed timestamp
copyToRoot = pkgs.buildEnv {
name = "image-root";
paths = [ pkgs.cacert pkgs.tzdata server ];
pathsToLink = [ "/bin" "/etc" ];
};
config = {
Entrypoint = [ "/bin/oa-verifier" ];
ExposedPorts."443/tcp" = {};
Env = [ "SSL_CERT_FILE=/etc/ssl/certs/ca-bundle.crt" ];
WorkingDir = "/app";
};
};
default = server;
};
devShells.default = pkgs.mkShell {
buildInputs = [ pkgs.go_1_22 pkgs.gopls pkgs.docker pkgs.azure-cli pkgs.jq ];
shellHook = ''
echo "OA-Verifier Dev Environment"
echo " nix build .#server - Build Go binary"
echo " nix build .#container - Build Docker image (Linux only)"
'';
};
apps.default = flake-utils.lib.mkApp {
drv = server;
name = "oa-verifier";
};
}
);
}