about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/compilers/fasmg/default.nix
blob: ec915bcb04bcf452d54f343878909bfdc6b3a7fd (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
58
{ lib, stdenv
, fetchzip
}:

stdenv.mkDerivation rec {
  pname = "fasmg";
  version = "j27m";

  src = fetchzip {
    url = "https://flatassembler.net/fasmg.${version}.zip";
    sha256 = "0qmklb24n3r0my2risid8r61pi88gqrvm1c0xvyd0bp1ans6d7zd";
    stripRoot = false;
  };

  buildPhase = let
    inherit (stdenv.hostPlatform) system;

    path = {
      x86_64-linux = {
        bin = "fasmg.x64";
        asm = "source/linux/x64/fasmg.asm";
      };
      x86_64-darwin = {
        bin = "source/macos/x64/fasmg";
        asm = "source/macos/x64/fasmg.asm";
      };
      x86-linux = {
        bin = "fasmg";
        asm = "source/linux/fasmg.asm";
      };
      x86-darwin = {
        bin = "source/macos/fasmg";
        asm = "source/macos/fasmg.asm";
      };
    }.${system} or (throw "Unsupported system: ${system}");

  in ''
    chmod +x ${path.bin}
    ./${path.bin} ${path.asm} fasmg
  '';

  outputs = [ "out" "doc" ];

  installPhase = ''
    install -Dm755 fasmg $out/bin/fasmg

    mkdir -p $doc/share/doc/fasmg
    cp docs/*.txt $doc/share/doc/fasmg
  '';

  meta = with lib; {
    description = "x86(-64) macro assembler to binary, MZ, PE, COFF, and ELF";
    homepage = "https://flatassembler.net";
    license = licenses.bsd3;
    maintainers = with maintainers; [ orivej luc65r ];
    platforms = with platforms; intersectLists (linux ++ darwin) x86;
  };
}