about summary refs log tree commit diff
path: root/pkgs/tools/filesystems/f3/default.nix
blob: 04430fc23ee41e21b99f8bccfddf4836a1b6e5df (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
{ stdenv
, lib
, fetchFromGitHub
, parted
, systemd
, argp-standalone
}:

stdenv.mkDerivation rec {
  pname = "f3";
  version = "8.0";

  src = fetchFromGitHub {
    owner = "AltraMayor";
    repo = pname;
    rev = "v${version}";
    sha256 = "17l5vspfcgfbkqg7bakp3gql29yb05gzawm8n3im30ilzdr53678";
  };

  postPatch = ''
    sed -i 's/-oroot -groot//' Makefile

    for f in f3write.h2w log-f3wr; do
     substituteInPlace $f \
       --replace '$(dirname $0)' $out/bin
    done
  '';

  buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ systemd parted ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin [ argp-standalone ];

  buildFlags = [
    "all" # f3read, f3write
  ]
  ++ lib.optional stdenv.hostPlatform.isLinux "extra"; # f3brew, f3fix, f3probe

  installFlags = [
    "PREFIX=${placeholder "out"}"
  ];

  installTargets = [
    "install"
  ]
  ++ lib.optional stdenv.hostPlatform.isLinux "install-extra";

  postInstall = ''
    install -Dm555 -t $out/bin f3write.h2w log-f3wr
    install -Dm444 -t $out/share/doc/${pname} LICENSE README.rst
  '';

  meta = with lib; {
    description = "Fight Flash Fraud";
    homepage = "https://fight-flash-fraud.readthedocs.io/en/stable/";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [ makefu evils ];
  };
}