Skip to content

Commit 254c215

Browse files
authored
chore(nix): add package derivation (#5)
1 parent bec8551 commit 254c215

3 files changed

Lines changed: 78 additions & 0 deletions

File tree

.goreleaser.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,4 @@ changelog:
113113
exclude:
114114
- '^docs'
115115
- '^test'
116+
- '^chore'

default.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
pkgs ? import <nixpkgs> {},
3+
isUnstable ? false,
4+
}:
5+
pkgs.callPackage ./nix/package.nix {
6+
src =
7+
if isUnstable
8+
then pkgs.lib.cleanSource ./.
9+
else null;
10+
}

nix/package.nix

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
lib,
3+
stdenv,
4+
buildGo125Module,
5+
fetchFromGitHub,
6+
installShellFiles,
7+
src ? null,
8+
}: let
9+
version =
10+
if src != null
11+
then "unstable"
12+
else "0.1.1";
13+
in
14+
buildGo125Module {
15+
pname = "tpm-trust";
16+
inherit version;
17+
18+
src =
19+
if src != null
20+
then src
21+
else
22+
fetchFromGitHub {
23+
owner = "loicsikidi";
24+
repo = "tpm-trust";
25+
tag = "v${version}";
26+
hash = "sha256-w6CVs8huAhlkYiA7a6dY4WsF3Ri5puW494rq9mnpmjY=";
27+
};
28+
29+
vendorHash = "sha256-yuqq485vIO+EI05RzjEFX2L2Mtp6gS3pi8RK3gmeUu0=";
30+
31+
# Build the main package (at the root)
32+
# subPackages defaults to [ "." ] if not specified
33+
34+
ldflags = [
35+
"-s"
36+
"-w"
37+
"-X main.version=${version}"
38+
"-X main.builtBy=nix"
39+
];
40+
41+
doCheck = true;
42+
43+
checkFlags = [
44+
"-v"
45+
"-timeout=30s"
46+
];
47+
48+
nativeBuildInputs = [installShellFiles];
49+
50+
postInstall =
51+
lib.optionalString
52+
(stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
53+
# Generate shell completions
54+
installShellCompletion --cmd tpm-trust \
55+
--bash <($out/bin/tpm-trust completion bash) \
56+
--zsh <($out/bin/tpm-trust completion zsh) \
57+
--fish <($out/bin/tpm-trust completion fish)
58+
'';
59+
60+
meta = {
61+
description = "TPM Trust Bundle - manages TPM root certificates bundle";
62+
homepage = "https://github.com/loicsikidi/tpm-trust";
63+
license = lib.licenses.bsd3;
64+
maintainers = [];
65+
mainProgram = "tpm-trust";
66+
};
67+
}

0 commit comments

Comments
 (0)