summary refs log tree commit diff
path: root/pkgs/tools/package-management/holo-build/default.nix
blob: 20e3b555fd2f520fe6e92faa284e9855235b6712 (plain) (blame)
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
{ lib, buildGoModule, fetchFromGitHub, installShellFiles, perl, file }:

buildGoModule rec {
  pname = "holo-build";
  version = "1.6.1";

  src = fetchFromGitHub {
    owner = "holocm";
    repo = pname;
    rev = "v${version}";
    sha256 = "0lypbgf96bcc4m3968xa4il1zwprsdyc0pw6pl9mqq7djxabikd0";
  };

  postPatch = ''
    substituteInPlace Makefile \
      --replace 'VERSION :=' 'VERSION ?='
    substituteInPlace src/holo-build.sh \
      --replace '/usr/lib/holo/holo-build' '${placeholder "out"}/lib/holo/holo-build'
  '';

  vendorSha256 = null;

  nativeBuildInputs = [ installShellFiles perl ];

  subPackages = [ "src/holo-build" ];

  buildFlagsArray = [ "-ldflags=-s -w -X github.com/holocm/holo-build/src/holo-build/common.version=${version}" ];

  postBuild = ''
    make build/man/holo-build.8 VERSION=${version}
  '';

  checkInputs = [ file ];

  checkPhase = ''
    ln -s ../../go/bin/holo-build build/holo-build
    go build -ldflags "-s -w -X github.com/holocm/holo-build/src/holo-build/common.version=${version}" -o build/dump-package ./src/dump-package
    bash test/compiler/run_tests.sh
    bash test/interface/run_tests.sh
  '';

  postInstall = ''
    installManPage build/man/*
    installShellCompletion --bash --name holo-build util/autocomplete.bash
    installShellCompletion --zsh --name _holo-build util/autocomplete.zsh

    # install wrapper script
    mkdir -p $out/lib/holo
    mv $out/bin/holo-build $out/lib/holo/holo-build
    cp src/holo-build.sh $out/bin/holo-build
  '';

  meta = with lib; {
    description = "Cross-distribution system package compiler";
    homepage = "https://holocm.org/";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [ SuperSandro2000 ];
  };
}