Summary Files Commits Branches @commit @diff @stats
path: root / packages / inferno64 / default.nix
blob: 2dcd6e1e995bca3585d1d6cf4b47b064c9a4a9cf (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
{
  lib,
  stdenv,
  fetchFromGitHub,
  xorg,
  libpulseaudio,
  ...
}:
# TODO: non-Linux OS setup
# TODO: insert meta
stdenv.mkDerivation rec {
  pname = "inferno64";
  version = "2026-04-29";

  src = fetchFromGitHub {
    owner = "caerwynj";
    repo = pname;
    rev = "8e3a1e2eb576bfbe8a82fa24f89764c41e064ed3";
    hash = "sha256-w8sGJ3JfSvdfusejJClT9MWTUA76MNgXOHMJ6cfeHhA";
  };

  buildInputs = [
    libX11
    libXext
    libpulseaudio
  ];

  postPatch = ''
    sed -i '/types.h/a #include <sys/stat.h>' ./lib9/create.c
    sed -i '19a\
    		-fpermissive\\' ./mkfiles/mkfile-Linux-amd64
  '';

  configurePhase = ''
    runHook preConfigure

    export ROOT="$PWD"
    export objtype='amd64'
    export PATH="$PATH:$PWD/Linux/$objtype/bin"

    ./makemk.sh
    mk mkdirs

    runHook postConfigure
  '';

  buildPhase = ''
    runHook preBuild

    mk install

    runHook postBuild
  '';

  installPhase = lib.warn ''
    All Inferno files are stored under a directory on your filesystem.
    Nix outputs (under /nix/store) are read-only.
    To initialize a directory for the Inferno FS, run the "inferno_init" script.
  '' ''
    runHook preInstall

    mkdir -p "$out/usr/inferno"
    cp -r . "$out/usr/inferno"
    ln -s "$out/usr/inferno/Linux/amd64/bin" "$out/bin"

    cat <<SH >"$out/bin/inferno_init"
    #!${stdenv.builder}

    [ -z "\$1" ] && set '/usr/inferno'
    [ ! -d "\$1" ] && echo "'\$1' doesn't exist or not a directory!" && exit 1

    cp -sr "$out/usr/inferno"/* "\$1" || exit $?
    find "\$1" -type d -not -path "\$1" -exec chmod +w {} +

    echo "'\$1' initialised for Inferno!"

    echo "You're probably planning on using the emulator, just issue:"
    if [ "\$1" != '/usr/inferno' ]
    then
        echo "emu -r '\$1'"
    else
        echo 'emu'
    fi
    SH
    chmod +x "$out/bin/inferno_init"

    runHook postInstall
  '';

  # All (most?) resultant scripts are ran with /dis/sh,
  # not with /nix/store/...-bash-...
  dontFixup = true;
}