aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
blob: ddaaef22a6a1ba193337d30937f9a18ab703833e (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
{
  description = "Wiimms SZS Tools - command line tools for Mario Kart Wii files";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs { inherit system; };
        version = "2.42a";
      in {
        packages = {
          wiimms-szs-tools = pkgs.stdenv.mkDerivation {
            pname = "wiimms-szs-tools";
            inherit version;

            src = ./.;

            buildInputs = with pkgs; [ ncurses libpng zlib ];

            postPatch = ''
              # Fix shebangs: /usr/bin/env doesn't exist in Nix sandbox
              sed -i '1s|#!/usr/bin/env bash|#!${pkgs.bash}/bin/bash|' \
                project/gen-template.sh project/gen-text-file.sh
            '';

            buildPhase = ''
              make -C project SHELL=bash NOWIIMM=1
            '';

            installPhase = ''
              for tool in wszst wbmgt wctct wimgt wkclt wkmpt wlect wmdlt wpatt wstrt; do
                install -Dm755 "project/$tool" "$out/bin/$tool"
              done
            '';

            meta = with pkgs.lib; {
              description = "Command-line tools to extract, modify and create Mario Kart Wii files";
              homepage = "https://szs.wiimm.de/";
              license = licenses.gpl2Plus;
              maintainers = [ ];
              platforms = platforms.linux;
            };
          };
          default = self.packages.${system}.wiimms-szs-tools;
        };
      });
}