summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/to/toolbox/package.nix
blob: 76841065be3e3cb5ef1a97104ece91c633eed335 (plain)
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
{
  lib,
  buildGoModule,
  fetchFromGitHub,
  glibc,
  go-md2man,
  installShellFiles,
}:

buildGoModule (finalAttrs: {
  pname = "toolbox";
  version = "0.0.99.3";

  src = fetchFromGitHub {
    owner = "containers";
    repo = "toolbox";
    rev = finalAttrs.version;
    hash = "sha256-9HiWgEtaMypLOwXJ6Xg3grLSZOQ4NInZtcvLPV51YO8=";
  };

  patches = [ ./glibc.patch ];

  vendorHash = "sha256-k79TcC9voQROpJnyZ0RsqxJnBT83W5Z+D+D3HnuQGsI=";

  postPatch = ''
    substituteInPlace src/cmd/create.go --subst-var-by glibc ${glibc}
  '';

  modRoot = "src";

  nativeBuildInputs = [
    go-md2man
    installShellFiles
  ];

  ldflags = [
    "-s"
    "-w"
    "-X github.com/containers/toolbox/pkg/version.currentVersion=${finalAttrs.version}"
  ];

  preCheck = "export PATH=$GOPATH/bin:$PATH";

  postInstall = ''
    cd ..
    for d in doc/*.md; do
      go-md2man -in $d -out ''${d%.md}
    done
    installManPage doc/*.[1-9]
    installShellCompletion --bash completion/bash/toolbox
    install profile.d/toolbox.sh -Dt $out/share/profile.d
  '';

  meta = {
    homepage = "https://containertoolbx.org";
    changelog = "https://github.com/containers/toolbox/releases/tag/${finalAttrs.version}";
    description = "Tool for containerized command line environments on Linux";
    license = lib.licenses.asl20;
    maintainers = [ ];
    mainProgram = "toolbox";
  };
})