about summary refs log tree commit diff
path: root/pkgs/by-name/he/hello-go/package.nix
blob: e68c0b8c98fe4fde6af96d8fe7875212bc18725d (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
{
  lib,
  buildGoModule,
}:

buildGoModule {
  name = "hello-go";

  src = ./src;

  vendorHash = null;

  CGO_ENABLED = 0;

  # go installs binary into $out/bin/$GOOS_$GOARCH/hello-go in cross compilation
  postInstall = ''
    [[ -f "$out/bin/hello-go" ]] || ln -s ./''${GOOS}_''${GOARCH}/hello-go $out/bin/hello-go
  '';

  meta = {
    description = "Simple program printing hello world in Go";
    longDescription = ''
      hello-go is a simple program printing "Hello, world!" written in Go,
      aiming at testing programs that involves analyzing executables or
      emulating foreign architectures, without pulling in a heavy cross
      toolchain.

      Specify target platform by setting GOOS and GOARCH:

      ```nix
      hello-go.overrideAttrs {
        GOOS = "linux";
        GOARCH = "arm64";
      }
      ```

      See https://pkg.go.dev/internal/platform#pkg-variables for a list
      of available platforms.
    '';
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ aleksana ];
    mainProgram = "hello-go";
  };
}