-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflake.nix
More file actions
96 lines (83 loc) · 3.11 KB
/
flake.nix
File metadata and controls
96 lines (83 loc) · 3.11 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
91
92
93
94
95
96
{
description = "infrahub-backup - Backup/restore and task management tools for Infrahub";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
version =
if self ? shortRev then self.shortRev
else if self ? dirtyShortRev then self.dirtyShortRev
else "dev";
# Shared build configuration for both binaries.
# The neo4j watchdog must be pre-built because both packages
# import src/internal/app which has //go:embed directives
# referencing the watchdog binaries.
commonAttrs = {
inherit version;
src = ./.;
vendorHash = "sha256-W7KHeb9vue1Z9pCi00q174yHi0RtbVLjYlSGdVSRo7s=";
# Don't run preBuild (watchdog compilation) in the go-modules
# derivation — it only needs to fetch/vendor dependencies.
overrideModAttrs = finalAttrs: prevAttrs: {
preBuild = "";
};
env.CGO_ENABLED = 0;
ldflags = [
"-s" "-w"
"-X main.version=${version}"
];
preBuild = ''
# Build embedded neo4j watchdog binaries required by //go:embed
GOOS=linux GOARCH=arm64 go build -ldflags "-s -w" \
-o src/internal/app/embedded/neo4jwatchdog/neo4j_watchdog_linux_arm64 \
./tools/neo4jwatchdog
GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" \
-o src/internal/app/embedded/neo4jwatchdog/neo4j_watchdog_linux_amd64 \
./tools/neo4jwatchdog
'';
meta = with pkgs.lib; {
homepage = "https://github.com/opsmill/infrahub-backup";
license = licenses.asl20;
maintainers = [ ];
};
};
in
{
packages = {
infrahub-backup = pkgs.buildGoModule (commonAttrs // {
pname = "infrahub-backup";
subPackages = [ "src/cmd/infrahub-backup" ];
meta = commonAttrs.meta // {
description = "Backup and restore tool for Infrahub instances";
mainProgram = "infrahub-backup";
};
});
infrahub-taskmanager = pkgs.buildGoModule (commonAttrs // {
pname = "infrahub-taskmanager";
subPackages = [ "src/cmd/infrahub-taskmanager" ];
meta = commonAttrs.meta // {
description = "Task manager maintenance tool for Infrahub instances";
mainProgram = "infrahub-taskmanager";
};
});
default = pkgs.symlinkJoin {
name = "infrahub-ops-cli-${version}";
paths = [
self.packages.${system}.infrahub-backup
self.packages.${system}.infrahub-taskmanager
];
};
};
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
go
golangci-lint
gopls
];
};
});
}