about summary refs log tree commit diff
path: root/nixpkgs/pkgs/by-name/na/nawk/package.nix
blob: 2ad1e2c9c3cdbcc218fa44d537f5c6f4e994947e (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
{ lib
, stdenv
, fetchFromGitHub
, bison
, buildPackages
, installShellFiles
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "nawk";
  version = "20240311";

  src = fetchFromGitHub {
    owner = "onetrueawk";
    repo = "awk";
    rev = finalAttrs.version;
    hash = "sha256-4iAQR8djhhp5Yn4H1IdzotQLY0d/Gz/vNQPfAUNQV0A=";
  };

  depsBuildBuild = [ buildPackages.stdenv.cc ];

  nativeBuildInputs = [
    bison
    installShellFiles
  ];

  outputs = [ "out" "man" ];

  makeFlags = [
    "CC=${stdenv.cc.targetPrefix}cc"
    "HOSTCC=${if stdenv.buildPlatform.isDarwin then "clang" else "cc"}"
  ];

  installPhase = ''
    runHook preInstall
    install -Dm755 a.out "$out/bin/nawk"
    mv awk.1 nawk.1
    installManPage nawk.1
    runHook postInstall
  '';

  meta = {
    homepage = "https://awk.dev";
    description = "The one, true implementation of AWK";
    longDescription = ''
      This is the version of awk described in "The AWK Programming Language",
      Second Edition, by Al Aho, Brian Kernighan, and Peter Weinberger
      (Addison-Wesley, 2023, ISBN 0-13-826972-6).
    '';
    changelog = "https://github.com/onetrueawk/awk/blob/${finalAttrs.src.rev}/ChangeLog";
    license = lib.licenses.mit;
    mainProgram = "nawk";
    maintainers = with lib.maintainers; [ AndersonTorres konimex ];
    platforms = lib.platforms.all;
  };
})