nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildGoModule,
4 fetchFromGitHub,
5 pnpm_9,
6 nodejs,
7 go_1_24,
8 git,
9 cacert,
10 nixosTests,
11}:
12let
13 pname = "homebox";
14 version = "0.20.2";
15 src = fetchFromGitHub {
16 owner = "sysadminsmedia";
17 repo = "homebox";
18 tag = "v${version}";
19 hash = "sha256-6AJYC5SIITLBgYOq8TdwxAvRcyg8MOoA7WUDar9jSxM=";
20 };
21in
22buildGoModule {
23 inherit pname version src;
24
25 vendorHash = "sha256-GTSFpfql0ebXtZC3LeIZo8VbCZdsbemNK5EarDTRAf0=";
26 modRoot = "backend";
27 # the goModules derivation inherits our buildInputs and buildPhases
28 # Since we do pnpm thing in those it fails if we don't explicitly remove them
29 overrideModAttrs = _: {
30 nativeBuildInputs = [
31 go_1_24
32 git
33 cacert
34 ];
35 preBuild = "";
36 };
37
38 pnpmDeps = pnpm_9.fetchDeps {
39 inherit pname version;
40 src = "${src}/frontend";
41 fetcherVersion = 1;
42 hash = "sha256-gHQ8Evo31SFmnBHtLDY5j5zZwwVS4fmkT+9VHZJWhfs=";
43 };
44 pnpmRoot = "../frontend";
45
46 env.NUXT_TELEMETRY_DISABLED = 1;
47
48 preBuild = ''
49 pushd ../frontend
50
51 pnpm build
52
53 popd
54
55 mkdir -p ./app/api/static/public
56 cp -r ../frontend/.output/public/* ./app/api/static/public
57 '';
58
59 nativeBuildInputs = [
60 pnpm_9
61 pnpm_9.configHook
62 nodejs
63 ];
64
65 env.CGO_ENABLED = 0;
66 doCheck = false;
67
68 tags = [
69 "nodynamic"
70 ];
71
72 ldflags = [
73 "-s"
74 "-w"
75 "-extldflags=-static"
76 "-X main.version=${src.tag}"
77 "-X main.commit=${src.tag}"
78 ];
79 installPhase = ''
80 runHook preInstall
81
82 mkdir -p $out/bin
83 cp -r $GOPATH/bin/api $out/bin/
84
85 runHook postInstall
86 '';
87
88 passthru = {
89 tests = {
90 inherit (nixosTests) homebox;
91 };
92 };
93
94 meta = {
95 mainProgram = "api";
96 homepage = "https://homebox.software/";
97 description = "Inventory and organization system built for the Home User";
98 maintainers = with lib.maintainers; [
99 patrickdag
100 tebriel
101 ];
102 license = lib.licenses.agpl3Only;
103 platforms = lib.platforms.linux;
104 };
105}