summaryrefslogtreecommitdiff
path: root/misc/nixos/pkgs/os-specific/linux/vtcol/default.nix
blob: dec074b2e70254290b69b1403c4d9a14bc62bd41 (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
{ lib, stdenv
, cpio
, docutils
, rust
, installShellFiles
, fetchFromGitLab
, rustPlatform
}:

rustPlatform.buildRustPackage rec {
  pname = "vtcol";
  version = "0.42.5";

  src = fetchFromGitLab {
    domain = "gitlab.com";
    owner = "phgsng";
    repo = pname;
    rev = "d6e8a37767644b50001e14ebbab594e799a94db7";
    sha256 = "sha256-fHWxiuCFO+N+ubPCS/Is64V2pLzh7xozDcRo7pQLMBg=";
  };

  cargoSha256 = "sha256-NSwn3vavrsPr+qn6oQY6kO5d9TKrxwcnqO7a3qpBphs==";

  nativeBuildInputs = [ docutils cpio installShellFiles ];

  buildFeatures = [ "vtcol-bin" ];

  cargoPatches = [ ./cargo-lock.patch ];

  target = rust.toRustTargetSpec stdenv.hostPlatform;

  # building the manpage requires docutils/rst2man
  postInstall = ''
    echo "create and install manpage"
    make man
    installManPage doc/vtcol.1.gz

    echo "create cpio archive for initrd"
    binout="target/${target}/release/${pname}"
    ls "$binout"
    mkdir -p -- tmp/usr/bin
    ls
    ls tmp
    cp -f -- "$binout" tmp/usr/bin
    pushd tmp
    <<<usr/bin/${pname} cpio -ov -H ustar >${pname}.cpio

    install -D -m644 ${pname}.cpio $out/share/vtcol/${pname}.cpio
  '';

  meta = with lib; {
    description = "Color schemes for the Linux console";
    homepage = "https://gitlab.com/phgsng/vtcol";
    license = licenses.gpl3;
    mainProgram = "vtcol";
  };
}