diff options
author | AndersonTorres <torres.anderson.85@protonmail.com> | 2021-10-28 00:43:40 -0300 |
---|---|---|
committer | AndersonTorres <torres.anderson.85@protonmail.com> | 2021-10-30 16:27:43 -0300 |
commit | 59af9bd85580057fb6ba3130fa94a49fea109d81 (patch) | |
tree | fb09ca1c368c7a16515cce10b22e3d9579f53da9 /pkgs/desktops/arcan/arcan/default.nix | |
parent | 134191380c7de09d3eb425ec4305ecb0c1f13e78 (diff) | |
download | nixpkgs-59af9bd85580057fb6ba3130fa94a49fea109d81.tar nixpkgs-59af9bd85580057fb6ba3130fa94a49fea109d81.tar.gz nixpkgs-59af9bd85580057fb6ba3130fa94a49fea109d81.tar.bz2 nixpkgs-59af9bd85580057fb6ba3130fa94a49fea109d81.tar.lz nixpkgs-59af9bd85580057fb6ba3130fa94a49fea109d81.tar.xz nixpkgs-59af9bd85580057fb6ba3130fa94a49fea109d81.tar.zst nixpkgs-59af9bd85580057fb6ba3130fa94a49fea109d81.zip |
arcan.arcan: fix static openal issues
Arcan has some interesting idiosyncrasies. One of them is using cmake. The other is using cmake to vendor some low-level, custom-patched dependencies. In order to work around them, I have created ... a set of custom patches! And on top of it, I have factored the vendored sources in a separate file, in order to clean up the `default.nix` file.
Diffstat (limited to 'pkgs/desktops/arcan/arcan/default.nix')
-rw-r--r-- | pkgs/desktops/arcan/arcan/default.nix | 98 |
1 files changed, 63 insertions, 35 deletions
diff --git a/pkgs/desktops/arcan/arcan/default.nix b/pkgs/desktops/arcan/arcan/default.nix index 48d4f9a5481..8420df5e7e2 100644 --- a/pkgs/desktops/arcan/arcan/default.nix +++ b/pkgs/desktops/arcan/arcan/default.nix @@ -1,6 +1,7 @@ { lib , stdenv , fetchFromGitHub +, fetchgit , SDL2 , cmake , espeak @@ -23,6 +24,7 @@ , libvncserver , libxcb , libxkbcommon +, lua , luajit , makeWrapper , mesa @@ -36,22 +38,16 @@ , xcbutil , xcbutilwm , xz -, buildManpages ? true, ruby +, buildManPages ? true, ruby +, useBuiltinLua ? true +, useStaticFreetype ? false +, useStaticLibuvc ? false +, useStaticOpenAL ? true +, useStaticSqlite ? false }: -let - # TODO: investigate vendoring, especially OpenAL - # WARN: vendoring of OpenAL is required for running arcan_lwa - # INFO: maybe it needs leaveDotGit, but it is dangerous/impure - letoram-openal-src = fetchFromGitHub { - owner = "letoram"; - repo = "openal"; - rev = "1c7302c580964fee9ee9e1d89ff56d24f934bdef"; - hash = "sha256-InqU59J0zvwJ20a7KU54xTM7d76VoOlFbtj7KbFlnTU="; - }; -in stdenv.mkDerivation rec { - pname = "arcan"; + pname = "arcan" + lib.optionalString useStaticOpenAL "-static-openal"; version = "0.6.1pre1+unstable=2021-10-16"; src = fetchFromGitHub { @@ -61,28 +57,11 @@ stdenv.mkDerivation rec { hash = "sha256-4FodFuO51ehvyjH4YaF/xBY9dwA6cP/e6/BvEsH4w7U="; }; - postUnpack = '' - pushd . - cd $sourceRoot/external/git/ - cp -a ${letoram-openal-src}/ openal/ - chmod --recursive 744 openal/ - popd - ''; - - # TODO: work with upstream in order to get rid of these hardcoded paths - postPatch = '' - substituteInPlace ./src/platform/posix/paths.c \ - --replace "/usr/bin" "$out/bin" \ - --replace "/usr/share" "$out/share" - - substituteInPlace ./src/CMakeLists.txt --replace "SETUID" "# SETUID" - ''; - nativeBuildInputs = [ cmake makeWrapper pkg-config - ] ++ lib.optionals buildManpages [ + ] ++ lib.optionals buildManPages [ ruby ]; @@ -108,6 +87,7 @@ stdenv.mkDerivation rec { libvncserver libxcb libxkbcommon + lua luajit mesa openal @@ -121,11 +101,54 @@ stdenv.mkDerivation rec { xz ]; + patches = [ + # Nixpkgs-specific: redirect vendoring + ./000-openal.patch + ./001-luajit.patch + ./002-libuvc.patch + ./003-freetype.patch + ]; + + # Emulate external/git/clone.sh + postUnpack = let + inherit (import ./clone-sources.nix { inherit fetchFromGitHub fetchgit; }) + letoram-openal-src freetype-src libuvc-src luajit-src; + in + '' + pushd $sourceRoot/external/git/ + '' + + (lib.optionalString useStaticOpenAL '' + cp -a ${letoram-openal-src}/ openal + chmod --recursive 744 openal + '') + + (lib.optionalString useStaticFreetype '' + cp -a ${freetype-src}/ freetype + chmod --recursive 744 freetype + '') + + (lib.optionalString useStaticLibuvc '' + cp -a ${libuvc-src}/ libuvc + chmod --recursive 744 libuvc + '') + + (lib.optionalString useBuiltinLua '' + cp -a ${luajit-src}/ luajit + chmod --recursive 744 luajit + '') + + '' + popd + ''; + + postPatch = '' + substituteInPlace ./src/platform/posix/paths.c \ + --replace "/usr/bin" "$out/bin" \ + --replace "/usr/share" "$out/share" + + substituteInPlace ./src/CMakeLists.txt --replace "SETUID" "# SETUID" + ''; + # INFO: According to the source code, the manpages need to be generated before # the configure phase - preConfigure = lib.optionalString buildManpages '' - pushd . - cd doc + preConfigure = lib.optionalString buildManPages '' + pushd doc ruby docgen.rb mangen popd ''; @@ -136,7 +159,12 @@ stdenv.mkDerivation rec { "-DDISTR_TAG=Nixpkgs" "-DENGINE_BUILDTAG=${version}" "-DHYBRID_SDL=on" - "-DSTATIC_OPENAL=off" + "-DBUILTIN_LUA=${if useBuiltinLua then "on" else "off"}" + "-DDISABLE_JIT=${if useBuiltinLua then "on" else "off"}" + "-DSTATIC_FREETYPE=${if useStaticFreetype then "on" else "off"}" + "-DSTATIC_LIBUVC=${if useStaticLibuvc then "on" else "off"}" + "-DSTATIC_OPENAL=${if useStaticOpenAL then "on" else "off"}" + "-DSTATIC_SQLite3=${if useStaticSqlite then "on" else "off"}" "../src" ]; |