diff --git a/.envrc b/.envrc new file mode 100644 index 000000000000..3550a30f2de3 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index be0fefb75078..bb019243b431 100644 --- a/.gitignore +++ b/.gitignore @@ -368,3 +368,7 @@ compile_commands.json # https://clangd.llvm.org/ cache folder .clangd/ .cache/ + +# Nix +result +.direnv/ diff --git a/default.nix b/default.nix deleted file mode 100644 index da9e444f20f8..000000000000 --- a/default.nix +++ /dev/null @@ -1,2 +0,0 @@ -{ onNixOS, devBuild }: -(import ../../pinned-nixpkgs.nix {}).callPackage ./godot.nix { onNixOS = onNixOS; devBuild = devBuild; pkgs = (import ../../pinned-nixpkgs.nix); } diff --git a/drivers/dummy/rasterizer_dummy.h b/drivers/dummy/rasterizer_dummy.h index 5c21fc30fb00..321dbd2b00c1 100644 --- a/drivers/dummy/rasterizer_dummy.h +++ b/drivers/dummy/rasterizer_dummy.h @@ -1,4 +1,4 @@ -*************************************************************************/ +/*************************************************************************/ /* rasterizer_dummy.h */ /*************************************************************************/ /* This file is part of: */ diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000000..cd286da9e936 --- /dev/null +++ b/flake.lock @@ -0,0 +1,143 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1743550720, + "narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c621e8422220273271f52058f618c94e405bb0f5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": [ + "wlroots-flake", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1743550720, + "narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c621e8422220273271f52058f618c94e405bb0f5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "libxcb-errors": { + "flake": false, + "locked": { + "lastModified": 1732504353, + "narHash": "sha256-LPNRkLQSTPkCRIc9lhHYIvQs8ags3GpGehCWLY5qvJw=", + "owner": "SimulaVR", + "repo": "libxcb-errors", + "rev": "cb26a7dc442b0bb37f8648986350291d3d45a47a", + "type": "github" + }, + "original": { + "owner": "SimulaVR", + "repo": "libxcb-errors", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1717179513, + "narHash": "sha256-vboIEwIQojofItm2xGCdZCzW96U85l9nDW3ifMuAIdM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "63dacb46bf939521bdc93981b4cbb7ecb58427a0", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "rev": "63dacb46bf939521bdc93981b4cbb7ecb58427a0", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs", + "systems": "systems", + "wlroots-flake": "wlroots-flake" + } + }, + "systems": { + "locked": { + "lastModified": 1689347949, + "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", + "owner": "nix-systems", + "repo": "default-linux", + "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default-linux", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1689347949, + "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", + "owner": "nix-systems", + "repo": "default-linux", + "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default-linux", + "type": "github" + } + }, + "wlroots-flake": { + "inputs": { + "flake-parts": "flake-parts_2", + "libxcb-errors": "libxcb-errors", + "nixpkgs": [ + "nixpkgs" + ], + "systems": "systems_2" + }, + "locked": { + "lastModified": 1750111025, + "narHash": "sha256-/y8ORmcHGspGGS/0x9v7RuQ/YkuVU792Qe5HuKncoME=", + "ref": "refs/heads/simula", + "rev": "e44903dee9e2e68219799699c38536e7d9961294", + "revCount": 3591, + "submodules": true, + "type": "git", + "url": "https://github.com/SimulaVR/wlroots" + }, + "original": { + "rev": "e44903dee9e2e68219799699c38536e7d9961294", + "submodules": true, + "type": "git", + "url": "https://github.com/SimulaVR/wlroots" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000000..4a7cb9d7421e --- /dev/null +++ b/flake.nix @@ -0,0 +1,201 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/63dacb46bf939521bdc93981b4cbb7ecb58427a0"; + systems.url = "github:nix-systems/default-linux"; + flake-parts = { + url = "github:hercules-ci/flake-parts"; + inputs.nixpkgs-lib.follows = "nixpkgs"; + }; + + wlroots-flake = { + url = "git+https://github.com/SimulaVR/wlroots?rev=e44903dee9e2e68219799699c38536e7d9961294&submodules=1"; + inputs.nixpkgs.follows = "nixpkgs"; + flake = true; + }; + }; + + outputs = + inputs: + inputs.flake-parts.lib.mkFlake { inherit inputs; } { + systems = import inputs.systems; + + perSystem = + { + pkgs, + lib, + system, + ... + }: + let + gdwlroots = pkgs.fetchFromGitHub { + owner = "SimulaVR"; + repo = "gdwlroots"; + rev = "f5add51f7b5055892177551a341eea510689d19b"; + hash = "sha256-1dIfXA0yWmcX4pZ84bD/Og39tl300YNeiTsWRLV7xh4="; + }; + wlroots = inputs.wlroots-flake.packages.${system}.default; + + libxcb-errors = pkgs.stdenv.mkDerivation { + pname = "libxcb-errors"; + version = "0.0.0"; + src = pkgs.fetchFromGitHub { + owner = "SimulaVR"; + repo = "libxcb-errors"; + rev = "cb26a7dc442b0bb37f8648986350291d3d45a47a"; + hash = "sha256-LPNRkLQSTPkCRIc9lhHYIvQs8ags3GpGehCWLY5qvJw="; + }; + + nativeBuildInputs = [ + pkgs.pkg-config + pkgs.python310 + pkgs.autoreconfHook + ]; + + buildInputs = [ + pkgs.xorg.libxcb + pkgs.xorg.libXau + pkgs.xorg.libXdmcp + pkgs.libbsd + pkgs.xorg.utilmacros + pkgs.xorg.xcbproto + ]; + + meta = { + description = "Allow XCB errors to print less opaquely"; + homepage = "https://github.com/SimulaVR/libxcb-errors"; + license = lib.licenses.mit; + platforms = lib.platforms.linux; + }; + }; + + godot = pkgs.stdenv.mkDerivation { + pname = "godot"; + version = "3.x-simula"; + src = lib.cleanSource ./.; + + nativeBuildInputs = [ + pkgs.scons + pkgs.pkg-config + pkgs.autoPatchelfHook + ]; + + buildInputs = [ + pkgs.xorg.libX11 + pkgs.xorg.libXcursor + pkgs.xorg.libXinerama + pkgs.xorg.libXext + pkgs.xorg.libXrandr + pkgs.xorg.libXi + pkgs.libGLU + pkgs.zlib + + pkgs.alsa-lib + pkgs.libpulseaudio + pkgs.yasm + pkgs.systemd + pkgs.libxkbcommon + pkgs.wayland + pkgs.pixman + pkgs.dbus-glib + + libxcb-errors + wlroots + ]; + + outputs = [ + "out" + "dev" + ]; + + configurePhase = '' + echo 'Copying GitHub gdwlroots to ./modules/gdwlroots' + cp -r ${gdwlroots} modules/gdwlroots + chmod -R u+w modules/gdwlroots + + echo 'Generating xdg-shell-protocol.{h,c}' + cd modules/gdwlroots + ${pkgs.wayland-scanner.bin}/bin/wayland-scanner server-header ${pkgs.wayland-protocols}/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml xdg-shell-protocol.h + ${pkgs.wayland-scanner.bin}/bin/wayland-scanner private-code ${pkgs.wayland-protocols}/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml xdg-shell-protocol.c + cd - + ''; + + buildPhase = '' + echo Building... + scons platform=x11 tools=no target=release bits=64 -j $NIX_BUILD_CORES + ''; + + installPhase = '' + # Install godot + mkdir -p $out/bin + cp bin/godot.x11.opt.64 $out/bin/godot + + # Install gdnative headers + mkdir $dev + cp -r modules/gdnative/include $dev + + # Install man + mkdir -p $out/share/man/man6 + cp misc/dist/linux/godot.6 $out/share/man/man6 + + mkdir -p $out/share/applications + mkdir -p $out/share/icons/hicolor/scalable/apps + cp misc/dist/linux/org.godotengine.Godot.desktop $out/share/applications + cp icon.svg $out/share/icons/hicolor/scalable/apps/godot.svg + cp icon.png $out/share/icons/godot.png + substituteInPlace $out/share/applications/org.godotengine.Godot.desktop \ + --replace-warn "Exec=godot" "Exec=$out/bin/godot" + ''; + + meta = { + homepage = "https://github.com/SimulaVR/godot"; + license = lib.licenses.mit; + platforms = [ "x86_64-linux" ]; + }; + }; + in + { + _module.args.pkgs = import inputs.nixpkgs { + inherit system; + config.allowUnfree = true; + }; + + packages = { + inherit godot wlroots; + default = godot; + }; + + devShells.default = pkgs.mkShell rec { + nativeBuildInputs = [ + pkgs.nil + pkgs.just + pkgs.scons + pkgs.pkg-config + ]; + + buildInputs = [ + pkgs.xorg.libX11 + pkgs.xorg.libXcursor + pkgs.xorg.libXinerama + pkgs.xorg.libXext + pkgs.xorg.libXrandr + pkgs.xorg.libXi + pkgs.libGLU + pkgs.zlib + + pkgs.alsa-lib + pkgs.libpulseaudio + pkgs.yasm + pkgs.systemd + + pkgs.libxkbcommon + pkgs.wayland + pkgs.pixman + pkgs.dbus-glib + + libxcb-errors + wlroots + ]; + }; + }; + }; +} diff --git a/godot.nix b/godot.nix deleted file mode 100644 index f414aedfeed7..000000000000 --- a/godot.nix +++ /dev/null @@ -1,251 +0,0 @@ -{ stdenv, lib, fetchFromGitHub, scons, libX11, libXcursor -, libXinerama, libXrandr, libXrender, libpulseaudio ? null -, libXi ? null, libXext, libXfixes, freetype, openssl -, alsaLib, libGLU, zlib, yasm ? null, xwayland, wayland-protocols, libglvnd, libGL, mesa, pixman, libxkbcommon, fontconfig, eudev, callPackage, devBuild ? false, onNixOS ? false, pkgs, xorg, wayland -, pkg-config, autoreconfHook, libbsd, python310, dbus, libv4l, wayland-scanner -}: - -let - options = { - touch = libXi != null; - pulseaudio = false; - }; - xvfb-run = callPackage ./xvfb-run.nix { }; - wlroots = callPackage ../wlroots { }; - - /* Modify a stdenv so that it produces debug builds; that is, - binaries have debug info, and compiler optimisations are - disabled. */ - keepDebugInfo = stdenv: stdenv // - { mkDerivation = args: stdenv.mkDerivation (args // { - dontStrip = true; - NIX_CFLAGS_COMPILE = toString (args.NIX_CFLAGS_COMPILE or "") + " -g -ggdb -Og"; - }); - }; - stdenvRes = if devBuild then (keepDebugInfo stdenv) else stdenv; - - xwayland-dev = xwayland.overrideAttrs (oldAttrs: { - stdenv = stdenvRes; - }); - libxcb-dev = xorg.libxcb.overrideAttrs (oldAttrs: { - stdenv = stdenvRes; - }); - wayland-dev = wayland.overrideAttrs (oldAttrs: { - stdenv = stdenvRes; - }); - wayland-protocols-dev = wayland-protocols.overrideAttrs (oldAttrs: { - stdenv = stdenvRes; - }); - - - - libxcb-errors = import ../wlroots/libxcb-errors { stdenv = stdenv; pkg-config=pkg-config; autoreconfHook = autoreconfHook; xorg = xorg; libbsd = libbsd; python310 = python310; lib = lib; }; - - nixGLIntel = (callPackage ./nixGL.nix { }).nixGLIntel; - nixGLRes = if (onNixOS == true) then " " else " ${nixGLIntel}/bin/nixGLIntel "; - nixGLPkg = if (onNixOS == true) then eudev else nixGLIntel; - - generateApiDev = (if onNixOS == true then "xvfb-run $out/bin/godot.x11.tools.64 --gdnative-generate-json-api $out/bin/api.json" else ("${nixGLIntel}/bin/nixGLIntel xvfb-run $out/bin/godot.x11.tools.64 --gdnative-generate-json-api $out/bin/api.json")); - generateApi = if (devBuild == false) then "cp api.json $out/bin/api.json" else generateApiDev; - - nonDevBuildInstall = if (devBuild == false) then '' - - scons platform=x11 tools=no target=release bits=64 -j $NIX_BUILD_CORES - scons platform=x11 tools=no target=release_debug bits=64 -j $NIX_BUILD_CORES - cp bin/godot.x11.opt.64 $out/bin/godot.x11.opt.64 - cp bin/godot.x11.opt.debug.64 $out/bin/godot.x11.opt.debug.64 - - '' else '' - ''; - -in stdenv.mkDerivation rec { - pname = "godot"; - version = "3.2"; - - src = ./.; - - nativeBuildInputs = [ scons pkg-config ]; - - buildInputs = [ - libX11 libXcursor libXinerama libXrandr libXrender - libXi libXext libXfixes freetype openssl alsaLib libpulseaudio - libGLU zlib yasm - wlroots xwayland-dev wayland-protocols-dev libglvnd libGL mesa libxkbcommon freetype fontconfig xorg.xorgproto xorg.libX11 xorg.libXt xorg.libXft xorg.libXext xorg.libSM xorg.libICE eudev xvfb-run nixGLPkg xorg.libpthreadstubs libxcb-dev wayland-dev - libxcb-errors - pixman dbus libv4l - ]; - - enableParallelBuilding = true; - - sconsFlags = "target=debug platform=x11"; - preConfigure = '' - sconsFlags+=" ${lib.concatStringsSep " " (lib.mapAttrsToList (k: v: "${k}=${builtins.toJSON v}") options)}" - ''; - - outputs = [ "out" "dev" "man" ]; - - configurePhase = '' - cd modules/gdwlroots - ${wayland-scanner}/bin/wayland-scanner server-header ${wayland-protocols}/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml xdg-shell-protocol.h - ${wayland-scanner}/bin/wayland-scanner private-code ${wayland-protocols}/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml xdg-shell-protocol.c - cd ../.. - patchShebangs platform/android/SCsub - patchShebangs platform/android/java/gradlew - patchShebangs platform/javascript/SCsub - patchShebangs platform/SCsub - patchShebangs platform/windows/SCsub - patchShebangs platform/x11/SCsub - patchShebangs platform/server/SCsub - patchShebangs platform/haiku/SCsub - patchShebangs platform/uwp/SCsub - patchShebangs platform/osx/SCsub - patchShebangs platform/iphone/SCsub - patchShebangs doc/tools/doc_status.py - patchShebangs doc/tools/doc_merge.py - patchShebangs doc/tools/makerst.py - patchShebangs drivers/dummy/SCsub - patchShebangs drivers/xaudio2/SCsub - patchShebangs drivers/winmidi/SCsub - patchShebangs drivers/SCsub - patchShebangs drivers/windows/SCsub - patchShebangs drivers/alsamidi/SCsub - patchShebangs drivers/png/SCsub - patchShebangs drivers/wasapi/SCsub - patchShebangs drivers/coremidi/SCsub - patchShebangs drivers/alsa/SCsub - patchShebangs drivers/unix/SCsub - patchShebangs drivers/pulseaudio/SCsub - patchShebangs drivers/gles2/SCsub - patchShebangs drivers/gles2/shaders/SCsub - patchShebangs drivers/gl_context/SCsub - patchShebangs drivers/gles3/SCsub - patchShebangs drivers/gles3/shaders/SCsub - patchShebangs drivers/coreaudio/SCsub - patchShebangs misc/hooks/pre-commit-makerst - patchShebangs misc/hooks/pre-commit-clang-format - patchShebangs misc/scripts/fix_headers.py - patchShebangs misc/scripts/make_icons.sh - patchShebangs misc/scripts/fix_style.sh - patchShebangs main/SCsub - patchShebangs nixGL.nix - patchShebangs nixGL.nix - patchShebangs nixGL.nix - patchShebangs nixGL.nix - patchShebangs scene/3d/SCsub - patchShebangs scene/audio/SCsub - patchShebangs scene/resources/SCsub - patchShebangs scene/resources/default_theme/SCsub - patchShebangs scene/resources/default_theme/make_header.py - patchShebangs scene/SCsub - patchShebangs scene/main/SCsub - patchShebangs scene/debugger/SCsub - patchShebangs scene/animation/SCsub - patchShebangs scene/2d/SCsub - patchShebangs scene/gui/SCsub - patchShebangs editor/import/SCsub - patchShebangs editor/doc/SCsub - patchShebangs editor/SCsub - patchShebangs editor/collada/SCsub - patchShebangs editor/fileserver/SCsub - patchShebangs editor/plugins/SCsub - patchShebangs editor/icons/SCsub - patchShebangs SConstruct - patchShebangs servers/physics/joints/SCsub - patchShebangs servers/physics/SCsub - patchShebangs servers/audio/effects/SCsub - patchShebangs servers/audio/SCsub - patchShebangs servers/physics_2d/SCsub - patchShebangs servers/SCsub - patchShebangs servers/camera/SCsub - patchShebangs servers/arvr/SCsub - patchShebangs servers/visual/SCsub - patchShebangs core/io/SCsub - patchShebangs core/crypto/SCsub - patchShebangs core/os/SCsub - patchShebangs core/bind/SCsub - patchShebangs core/SCsub - patchShebangs core/math/SCsub - patchShebangs modules/webp/SCsub - patchShebangs modules/ogg/SCsub - patchShebangs modules/tinyexr/SCsub - patchShebangs modules/webm/libvpx/SCsub - patchShebangs modules/webm/SCsub - patchShebangs modules/cvtt/SCsub - patchShebangs modules/vorbis/SCsub - patchShebangs modules/jsonrpc/SCsub - patchShebangs modules/gdnative/nativescript/SCsub - patchShebangs modules/gdnative/SCsub - patchShebangs modules/gdnative/videodecoder/SCsub - patchShebangs modules/gdnative/net/SCsub - patchShebangs modules/gdnative/arvr/SCsub - patchShebangs modules/gdnative/pluginscript/SCsub - patchShebangs modules/bullet/SCsub - patchShebangs modules/mono/SCsub - patchShebangs modules/upnp/SCsub - patchShebangs modules/recast/SCsub - patchShebangs modules/dds/SCsub - patchShebangs modules/etc/SCsub - patchShebangs modules/gridmap/SCsub - patchShebangs modules/SCsub - patchShebangs modules/theora/SCsub - patchShebangs modules/arkit/SCsub - patchShebangs modules/opensimplex/SCsub - patchShebangs modules/hdr/SCsub - patchShebangs modules/svg/SCsub - patchShebangs modules/camera/SCsub - patchShebangs modules/xatlas_unwrap/SCsub - patchShebangs modules/squish/SCsub - patchShebangs modules/csg/SCsub - patchShebangs modules/mobile_vr/SCsub - patchShebangs modules/stb_vorbis/SCsub - patchShebangs modules/enet/SCsub - patchShebangs modules/jpg/SCsub - patchShebangs modules/visual_script/SCsub - patchShebangs modules/regex/SCsub - patchShebangs modules/pvr/SCsub - patchShebangs modules/freetype/SCsub - patchShebangs modules/websocket/SCsub - patchShebangs modules/webrtc/SCsub - patchShebangs modules/gdscript/SCsub - patchShebangs modules/assimp/SCsub - patchShebangs modules/mbedtls/SCsub - patchShebangs modules/bmp/SCsub - patchShebangs modules/opus/SCsub - patchShebangs modules/vhacd/SCsub - patchShebangs modules/tga/SCsub - ''; - - dontStrip = true; - - installPhase = '' - mkdir -p "$out/bin" - - # Making these symlinks doesn't work for some reason - cp bin/godot.x11.tools.64 $out/bin/godot - cp bin/godot.x11.tools.64 $out/bin/godot.x11.tools.64 - - mkdir "$dev" - cp -r modules/gdnative/include $dev - - mkdir -p "$man/share/man/man6" - cp misc/dist/linux/godot.6 "$man/share/man/man6/" - - mkdir -p "$out"/share/{applications,icons/hicolor/scalable/apps} - cp misc/dist/linux/org.godotengine.Godot.desktop "$out/share/applications/" - cp icon.svg "$out/share/icons/hicolor/scalable/apps/godot.svg" - cp icon.png "$out/share/icons/godot.png" - substituteInPlace "$out/share/applications/org.godotengine.Godot.desktop" \ - --replace "Exec=godot" "Exec=$out/bin/godot" - - '' + generateApi + - '' - '' + nonDevBuildInstall; - - meta = { - homepage = "https://godotengine.org"; - description = "Free and Open Source 2D and 3D game engine"; - license = lib.licenses.mit; - platforms = [ "i686-linux" "x86_64-linux" ]; - maintainers = [ lib.maintainers.twey ]; - }; -} diff --git a/justfile b/justfile new file mode 100644 index 000000000000..de36fade7aba --- /dev/null +++ b/justfile @@ -0,0 +1,16 @@ +default: + @just --list + +build: + wayland-scanner server-header ./modules/gdwlroots/xdg-shell.xml ./modules/gdwlroots/xdg-shell-protocol.h + wayland-scanner private-code ./modules/gdwlroots/xdg-shell.xml ./modules/gdwlroots/xdg-shell-protocol.c + scons -Q -j8 platform=x11 target=debug warnings=no + +build-watch: + while inotifywait -qqre modify .; do just build; done + +clean: + rm -f ./modules/gdwlroots/xdg-shell-protocol.c + rm -f ./modules/gdwlroots/xdg-shell-protocol.h + scons -c + diff --git a/modules/gdleapmotionV2 b/modules/gdleapmotionV2 deleted file mode 160000 index e3917f9a45ad..000000000000 --- a/modules/gdleapmotionV2 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e3917f9a45ad7899704c65a3120cec38f3e093bb diff --git a/nixGL.nix b/nixGL.nix deleted file mode 100644 index 0aad0a7f1d0b..000000000000 --- a/nixGL.nix +++ /dev/null @@ -1,204 +0,0 @@ -{ ## Nvidia informations. - # Version of the system kernel module. Let it to null to enable auto-detection. - nvidiaVersion ? null, - # Hash of the Nvidia driver .run file. null is fine, but fixing a value here - # will be more reproducible and more efficient. - nvidiaHash ? null, - # Alternatively, you can pass a path that points to a nvidia version file - # and let nixGL extract the version from it. That file must be a copy of - # /proc/driver/nvidia/version. Nix doesn't like zero-sized files (see - # https://github.com/NixOS/nix/issues/3539 ). - nvidiaVersionFile ? null, - # Enable 32 bits driver - # This is one by default, you can switch it to off if you want to reduce a - # bit the size of nixGL closure. - enable32bits ? false, - writeTextFile, shellcheck, pcre, runCommand, linuxPackages, fetchurl, lib, - runtimeShell, bumblebee, libglvnd, vulkan-validation-layers, mesa_drivers, - pkgsi686Linux,zlib, libdrm, xorg, wayland, gcc -}: - -let - _nvidiaVersionFile = - if nvidiaVersionFile != null then - nvidiaVersionFile - else - # HACK: Get the version from /proc. It turns out that /proc is mounted - # inside of the build sandbox and varies from machine to machine. - # - # builtins.readFile is not able to read /proc files. See - # https://github.com/NixOS/nix/issues/3539. - runCommand "impure-nvidia-version-file" { - # To avoid sharing the build result over time or between machine, - # Add an impure parameter to force the rebuild on each access. - time = builtins.currentTime; - preferLocalBuild = true; - allowSubstitutes = false; - } - "cp /proc/driver/nvidia/version $out || touch $out"; - - # The nvidia version. Either fixed by the `nvidiaVersion` argument, or - # auto-detected. Auto-detection is impure. - _nvidiaVersion = - if nvidiaVersion != null then - nvidiaVersion - else - # Get if from the nvidiaVersionFile - let - data = builtins.readFile _nvidiaVersionFile; - versionMatch = builtins.match ".*Module +([0-9]+(\\.[0-9]+)+).*" data; - in - if versionMatch != null then - builtins.head versionMatch - else - null; - - addNvidiaVersion = drv: drv.overrideAttrs(oldAttrs: { - name = oldAttrs.name + "-${_nvidiaVersion}"; - }); - - writeExecutable = { name, text } : writeTextFile { - inherit name text; - - executable = true; - destination = "/bin/${name}"; - - - checkPhase = '' - ${shellcheck}/bin/shellcheck "$out/bin/${name}" - - # Check that all the files listed in the output binary exists - for i in $(${pcre}/bin/pcregrep -o0 '/nix/store/.*?/[^ ":]+' $out/bin/${name}) - do - ls $i > /dev/null || (echo "File $i, referenced in $out/bin/${name} does not exists."; exit -1) - done - ''; - }; -in - rec { - nvidia = (linuxPackages.nvidia_x11.override { - }).overrideAttrs(oldAttrs: rec { - name = "nvidia-${_nvidiaVersion}"; - src = let url ="http://download.nvidia.com/XFree86/Linux-x86_64/${_nvidiaVersion}/NVIDIA-Linux-x86_64-${_nvidiaVersion}.run"; - in if nvidiaHash != null - then fetchurl { - inherit url; - sha256 = nvidiaHash; - } else - builtins.fetchurl url; - useGLVND = true; - }); - - nvidiaLibsOnly = nvidia.override { - libsOnly = true; - kernel = null; - }; - - getFirstFile = path: path + builtins.head (builtins.attrNames (builtins.readDir path)); - json = getFirstFile "${nvidiaLibsOnly}/share/vulkan/icd.d/"; - json32 = getFirstFile "${nvidiaLibsOnly.lib32}/share/vulkan/icd.d/"; - - - nixGLNvidiaBumblebee = addNvidiaVersion (writeExecutable { - name = "nixGLNvidiaBumblebee"; - text = '' - #!${runtimeShell} - export LD_LIBRARY_PATH=${lib.makeLibraryPath [nvidia]}:$LD_LIBRARY_PATH - ${bumblebee.override {nvidia_x11 = nvidia; nvidia_x11_i686 = nvidia.lib32;}}/bin/optirun --ldpath ${lib.makeLibraryPath ([libglvnd nvidia] ++ lib.optionals enable32bits [nvidia.lib32 pkgsi686Linux.libglvnd])} "$@" - ''; - }); - - # TODO: 32bit version? Not tested. - nixNvidiaWrapper = api: addNvidiaVersion (writeExecutable { - name = "nix${api}Nvidia"; - text = '' - #!${runtimeShell} - ${lib.optionalString (api == "Vulkan") ''export VK_LAYER_PATH=${vulkan-validation-layers}/share/vulkan/explicit_layer.d''} - - ${lib.optionalString (api == "Vulkan") ''export VK_ICD_FILENAMES=${json}${lib.optionalString enable32bits ":${json32}"}:$VK_ICD_FILENAMES''} - export LD_LIBRARY_PATH=${lib.makeLibraryPath ([ - libglvnd - nvidiaLibsOnly - ] ++ lib.optional (api == "Vulkan") vulkan-validation-layers - ++ lib.optionals enable32bits [nvidiaLibsOnly.lib32 pkgsi686Linux.libglvnd]) - }:''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} - "$@" - ''; - }); - - # TODO: 32bit version? Not tested. - nixGLNvidia = nixNvidiaWrapper "GL"; - - # TODO: 32bit version? Not tested. - nixVulkanNvidia = nixNvidiaWrapper "Vulkan"; - - nixGLIntel = writeExecutable { - name = "nixGLIntel"; - # add the 32 bits drivers if needed - text = let - drivers = [mesa_drivers] ++ lib.optional enable32bits pkgsi686Linux.mesa_drivers; - in '' - #!${runtimeShell} - export LIBGL_DRIVERS_PATH=${lib.makeSearchPathOutput "lib" "lib/dri" drivers} - export LD_LIBRARY_PATH=${ - lib.makeLibraryPath drivers - }:$LD_LIBRARY_PATH - "$@" - ''; - }; - - nixVulkanIntel = writeExecutable { - name = "nixVulkanIntel"; - text = let - # generate a file with the listing of all the icd files - icd = runCommand "mesa_icd" {} - ( - # 64 bits icd - ''ls ${mesa_drivers}/share/vulkan/icd.d/*.json > f - '' - # 32 bits ones - + lib.optionalString enable32bits ''ls ${pkgsi686Linux.mesa_drivers}/share/vulkan/icd.d/*.json >> f - '' - # concat everything as a one line string with ":" as seperator - + ''cat f | xargs | sed "s/ /:/g" > $out'' - ); - in '' - #!${runtimeShell} - if [ -n "$LD_LIBRARY_PATH" ]; then - echo "Warning, nixVulkanIntel overwriting existing LD_LIBRARY_PATH" 1>&2 - fi - export VK_LAYER_PATH=${vulkan-validation-layers}/share/vulkan/explicit_layer.d - ICDS=$(cat ${icd}) - export VK_ICD_FILENAMES=$ICDS:$VK_ICD_FILENAMES - export LD_LIBRARY_PATH=${lib.makeLibraryPath [ - zlib - libdrm - xorg.libX11 - xorg.libxcb - xorg.libxshmfence - wayland - gcc.cc - ]}:$LD_LIBRARY_PATH - exec "$@" - ''; - }; - - nixGLCommon = nixGL: - runCommand "nixGLCommon" { - buildInuts = [nixGL]; - } - '' - mkdir -p "$out/bin" - # star because nixGLNvidia... have version prefixed name - cp ${nixGL}/bin/* "$out/bin/nixGL"; - ''; - - # The output derivation contains nixGL which point either to - # nixGLNvidia or nixGLIntel using an heuristic. - nixGLDefault = - if _nvidiaVersion != null then - nixGLCommon nixGLNvidia - else - nixGLCommon nixGLIntel - ; -} diff --git a/nixGLDefault.nix b/nixGLDefault.nix deleted file mode 100644 index abc4a8b09201..000000000000 --- a/nixGLDefault.nix +++ /dev/null @@ -1 +0,0 @@ -((import ../../pinned-nixpkgs.nix {}).callPackage ./nixGL.nix { }) diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 5b3a553b1e67..cd66307135c5 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -343,6 +343,7 @@ def configure(env): if env["udev"]: if os.system("pkg-config --exists libudev") == 0: # 0 means found env.Append(CPPDEFINES=["UDEV_ENABLED"]) + env.ParseConfig("pkg-config --cflags libudev") else: print("Warning: libudev development libraries not found. Disabling controller hotplugging support.") else: diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 9c17052a4c09..000000000000 --- a/shell.nix +++ /dev/null @@ -1,2 +0,0 @@ -{ onNixOS ? false, devBuild ? true }: -(import ../../pinned-nixpkgs.nix {}).callPackage ./godot.nix { onNixOS = onNixOS; devBuild = devBuild; pkgs = (import ../../pinned-nixpkgs.nix); } diff --git a/xvfb-run.nix b/xvfb-run.nix deleted file mode 100644 index 4a2c1748956c..000000000000 --- a/xvfb-run.nix +++ /dev/null @@ -1,32 +0,0 @@ -{ stdenv, fetchurl, makeWrapper, xorgserver, getopt, lib -, xauth, utillinux, makeFontsConf, gawk, coreutils, freefont_ttf }: -let - fontsConf = makeFontsConf { - fontDirectories = [ freefont_ttf ]; - }; - xvfb_run = fetchurl { - name = "xvfb-run"; - # https://git.archlinux.org/svntogit/packages.git/?h=packages/xorg-server - url = https://git.archlinux.org/svntogit/packages.git/plain/trunk/xvfb-run?h=packages/xorg-server&id=9cb733cefa92af3fca608fb051d5251160c9bbff; - sha256 = "1307mz4nr8ga3qz73i8hbcdphky75rq8lrvfk2zm4kmv6pkbk611"; - }; - -in -stdenv.mkDerivation { - name = "xvfb-run"; - buildInputs = [makeWrapper]; - buildCommand = '' - mkdir -p $out/bin - cp ${xvfb_run} $out/bin/xvfb-run - chmod a+x $out/bin/xvfb-run - patchShebangs $out/bin/xvfb-run - wrapProgram $out/bin/xvfb-run \ - --set FONTCONFIG_FILE "${fontsConf}" \ - --prefix PATH : ${lib.makeBinPath [ getopt xorgserver xauth utillinux gawk coreutils ]} # remove which to avoid godot-haskell-plugin issue - ''; - - meta = with lib; { - platforms = platforms.linux; - license = licenses.gpl2; - }; -}