summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/is/iscc/package.nix
blob: aa406e4e0a4c7a841e2ed4271cb18e8340f928ec (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{
  stdenvNoCC,
  fetchurl,
  innoextract,
  runtimeShell,
  wineWow64Packages,
  lib,
}:

let
  version = "6.4.1";
  tagVersion = lib.replaceStrings [ "." ] [ "_" ] version;
in
stdenvNoCC.mkDerivation rec {
  pname = "iscc";
  inherit version;
  src = fetchurl {
    url = "https://github.com/jrsoftware/issrc/releases/download/is-${tagVersion}/innosetup-${version}.exe";
    hash = "sha256-9Bdg4fGuFdIIm7arFi4hcguSrnUG7XBmezkgAGPWjjQ=";
  };
  nativeBuildInputs = [
    innoextract
    wineWow64Packages.stable
  ];
  unpackPhase = ''
    runHook preUnpack

    innoextract $src

    runHook postUnpack
  '';
  dontBuild = true;
  installPhase = ''
    runHook preInstall

    mkdir -p "$out/bin"
    cp -r ./app/* "$out/bin"

    cat << 'EOF' > "$out/bin/iscc"
    #!${runtimeShell}
    export PATH=${wineWow64Packages.stable}/bin:$PATH
    export WINEDLLOVERRIDES="mscoree=" # disable mono

    # Solves PermissionError: [Errno 13] Permission denied: '/homeless-shelter/.wine'
    export HOME=$(mktemp -d)

    wineInputFile=$(${wineWow64Packages.stable}/bin/wine winepath -w $1)
    ${wineWow64Packages.stable}/bin/wine "$out/bin/ISCC.exe" "$wineInputFile"
    EOF

    substituteInPlace $out/bin/iscc \
      --replace "\$out" "$out"

    chmod +x "$out/bin/iscc"

    runHook postInstall
  '';

  # Stripping causes `$out/bin/Setup.e32` to lose something important and causes the built windows installers to not run on windows "This app can't run on your PC".
  # They worked in wine but not on real windows.
  dontStrip = 1;

  meta = {
    description = "Compiler for Inno Setup, a tool for creating Windows installers";
    homepage = "https://jrsoftware.org/isinfo.php";
    changelog = "https://jrsoftware.org/files/is6-whatsnew.htm";
    license = lib.licenses.unfreeRedistributable;
    maintainers = with lib.maintainers; [ liberodark ];
    mainProgram = "iscc";
    platforms = wineWow64Packages.stable.meta.platforms;
  };
}