summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/cp/cpufetch/package.nix
blob: ed990b71d18a1bc62704cac862f009c4649ac480 (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
{
  lib,
  stdenv,
  fetchFromGitHub,
  installShellFiles,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "cpufetch";
  version = "1.07";

  src = fetchFromGitHub {
    owner = "Dr-Noob";
    repo = "cpufetch";
    rev = "v${finalAttrs.version}";
    sha256 = "sha256-qmT7WBWKtSWGIK/dEd3/bF1bBjqSjfkP99htfnlFLCw=";
  };

  postPatch =
    # Copy-pasting typo
    # https://github.com/Dr-Noob/cpufetch/issues/350
    ''
      substituteInPlace src/ppc/udev.c \
        --replace-fail 'memset(name, 0, sizeof(char) * 128)' 'memset(path, 0, sizeof(char) * 128)'
    '';

  nativeBuildInputs = [
    installShellFiles
  ];

  # Upstream Makefile bug: for x86 builds, sysctl.c is only added to
  # SOURCE on FreeBSD even though cpuid.c calls get_sys_info_by_name
  # (defined there) on darwin too. Without this the x86_64-darwin
  # build fails to link with "Undefined symbols: _get_sys_info_by_name".
  # Widen the conditional to cover Darwin alongside FreeBSD.
  patches = lib.optionals stdenv.hostPlatform.isDarwin [
    ./darwin-x86-sysctl.patch
  ];

  installPhase = ''
    runHook preInstall

    mkdir $out
    install -Dm755 cpufetch   $out/bin/cpufetch
    install -Dm644 LICENSE    $out/share/licenses/cpufetch/LICENSE
    installManPage cpufetch.1

    runHook postInstall
  '';

  meta = {
    description = "Simplistic yet fancy CPU architecture fetching tool";
    license = lib.licenses.gpl2Only;
    homepage = "https://github.com/Dr-Noob/cpufetch";
    changelog = "https://github.com/Dr-Noob/cpufetch/releases/tag/v${finalAttrs.version}";
    maintainers = with lib.maintainers; [ devhell ];
    mainProgram = "cpufetch";
  };
})