Summary Files Commits Branches @commit @diff @stats
path: root / packages / inferno-os / default.nix
blob: e2f9d8e5660752d956427ece2c922d2420dfa151 (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
{
  lib,
  pkgsi686Linux,
  fetchFromGitHub,
  ...
}:
# TODO: less hardcoded setup
# TODO: insert meta
let
  inherit (pkgsi686Linux) stdenv xorg;
in
stdenv.mkDerivation rec {
  pname = "inferno-os";
  version = "2025-08-13";

  src = fetchFromGitHub {
    owner = pname;
    repo = pname;
    rev = "d7b29f497205f48247d2bab33340bd7ace64de4d";
    hash = "sha256-AoFhoNwl8qtpP+OMTfmnEEwdwd71L1YMT2CIz/Q78+o=";
    fetchSubmodules = true;
  };

  buildInputs = [
    libX11
    libXext
  ];

  # TODO: move these changes to a patch
  postPatch = ''
    sed -i '/types.h/a #include <sys/stat.h>' ./lib9/create.c
    sed -i '/#include "limbo.h"/a #include <ctype.h>' ./limbo/limbo.y
    sed -i '1622s/qcmdcmp/(int(*)(void*,void*))\0/' ./libtk/utils.c
    sed -i '/if(0){/,/}/d;s/pthread_yield/sched_yield/g' ./emu/port/kproc-pthreads.c
    sed -i 's/nrand(\([^)]\+\))/rand() % \1/' ./emu/port/devssl.c
    sed -i '18a\
    		-fcommon\\' ./mkfiles/mkfile-Linux-386
  '';

  configurePhase = ''
    runHook preConfigure

    sed -i "/^ROOT/s|=.*|=$PWD|;s/Plan9/Linux/;/^OBJTYPE/d;/^#OBJTYPE=/s/^#//" ./mkconfig
    export PATH="$PATH:$PWD/Linux/386/bin"

    ./makemk.sh
    mk nuke

    runHook postConfigure
  '';

  buildPhase = ''
    runHook preBuild

    mk install

    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    mkdir "$out"
    cp -r ./Linux/386/* "$out"

    runHook postInstall
  '';
}