nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchzip,
5
6 # update script
7 writeScript,
8 coreutils,
9 curl,
10 gnugrep,
11 htmlq,
12 nix-update,
13}:
14
15stdenv.mkDerivation (finalAttrs: {
16 pname = "fasmg";
17 version = "l2fx";
18
19 src = fetchzip {
20 url = "https://flatassembler.net/fasmg.${finalAttrs.version}.zip";
21 sha256 = "sha256-np7HhVp1SaII25nPPJGtBB4325K/1S3rKqOudsBNeCk=";
22 stripRoot = false;
23 };
24
25 buildPhase =
26 let
27 inherit (stdenv.hostPlatform) system;
28
29 path =
30 {
31 x86_64-linux = {
32 bin = "fasmg.x64";
33 asm = "source/linux/x64/fasmg.asm";
34 };
35 x86_64-darwin = {
36 bin = "source/macos/x64/fasmg";
37 asm = "source/macos/x64/fasmg.asm";
38 };
39 x86-linux = {
40 bin = "fasmg";
41 asm = "source/linux/fasmg.asm";
42 };
43 x86-darwin = {
44 bin = "source/macos/fasmg";
45 asm = "source/macos/fasmg.asm";
46 };
47 }
48 .${system} or (throw "Unsupported system: ${system}");
49
50 in
51 ''
52 chmod +x ${path.bin}
53 ./${path.bin} ${path.asm} fasmg
54 '';
55
56 outputs = [
57 "out"
58 "doc"
59 ];
60
61 installPhase = ''
62 install -Dm755 fasmg $out/bin/fasmg
63
64 mkdir -p $doc/share/doc/fasmg
65 cp docs/*.txt $doc/share/doc/fasmg
66 '';
67
68 passthru.updateScript = writeScript "update-fasmg.sh" ''
69 export PATH="${
70 lib.makeBinPath [
71 coreutils
72 curl
73 gnugrep
74 htmlq
75 nix-update
76 ]
77 }:$PATH"
78 version=$(
79 curl 'https://flatassembler.net/download.php' \
80 | htmlq .links a.boldlink -a href \
81 | grep -E '^fasmg\..*\.zip$' \
82 | head -n1 \
83 | cut -d. -f2
84 )
85 nix-update fasmg --version "$version"
86 '';
87
88 meta = {
89 description = "x86(-64) macro assembler to binary, MZ, PE, COFF, and ELF";
90 mainProgram = "fasmg";
91 homepage = "https://flatassembler.net";
92 license = lib.licenses.bsd3;
93 maintainers = [ lib.maintainers.iamanaws ];
94 platforms = with lib.platforms; lib.intersectLists (linux ++ darwin) x86;
95 };
96})