From f259cf90e03b5b1242c9211041635b2520df1171 Mon Sep 17 00:00:00 2001 From: MichaelFisher1997 Date: Fri, 4 Oct 2024 19:36:50 +0100 Subject: [PATCH 1/9] Added a Nix flake containing everything needed to build, dev and run redot --- .envrc | 1 + flake.lock | 25 +++++++++++++++++++ flake.nix | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 00000000000..3550a30f2de --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000000..86ed220ac24 --- /dev/null +++ b/flake.lock @@ -0,0 +1,25 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1721379653, + "narHash": "sha256-8MUgifkJ7lkZs3u99UDZMB4kbOxvMEXQZ31FO3SopZ0=", + "rev": "1d9c2c9b3e71b9ee663d11c5d298727dace8d374", + "revCount": 655136, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.1.655136%2Brev-1d9c2c9b3e71b9ee663d11c5d298727dace8d374/0190cd4f-c0eb-72cb-834b-ac854aa282dc/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/NixOS/nixpkgs/0.1.%2A.tar.gz" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000000..63783fa97f3 --- /dev/null +++ b/flake.nix @@ -0,0 +1,71 @@ +{ + description = "A Nix-flake-based C/C++ development environment"; + + inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz"; + + outputs = { + self, + nixpkgs, + }: let + supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"]; + forEachSupportedSystem = f: + nixpkgs.lib.genAttrs supportedSystems (system: + f rec { + pkgs = import nixpkgs {inherit system;}; + deps = with pkgs; [ + pkg-config + autoPatchelfHook + installShellFiles + python3 + speechd + wayland-scanner + makeWrapper + mono + dotnet-sdk_8 + dotnet-runtime_8 + vulkan-loader + libGL + xorg.libX11 + xorg.libXcursor + xorg.libXinerama + xorg.libXext + xorg.libXrandr + xorg.libXrender + xorg.libXi + xorg.libXfixes + libxkbcommon + alsa-lib + mono + wayland-scanner + wayland + libdecor + libpulseaudio + dbus + dbus.lib + speechd + fontconfig + fontconfig.lib + udev + dotnet-sdk_8 + dotnet-runtime_8 + scons + ]; + }); + in { + devShells = forEachSupportedSystem ({ + pkgs, + deps, + }: { + default = + pkgs.mkShell.override + { + # Override stdenv in order to change compiler: + # stdenv = pkgs.clangStdenv; + } + { + packages = deps; + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath deps; + }; + }); + }; +} From 9f5ddf5046e5cb6e7b818b1471b02f644994ae5c Mon Sep 17 00:00:00 2001 From: MichaelFisher1997 Date: Sat, 5 Oct 2024 11:32:22 +0100 Subject: [PATCH 2/9] Trigger Build From ca87bcf201d1e5acb446bd9e4e08fffd98c2dcc8 Mon Sep 17 00:00:00 2001 From: MichaelFisher1997 Date: Sun, 4 Jan 2026 18:13:59 +0000 Subject: [PATCH 3/9] Update nixpkgs URL to GitHub and remove duplicate dependencies --- flake.lock | 18 ++++++++++-------- flake.nix | 7 +------ 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/flake.lock b/flake.lock index 86ed220ac24..644277dbb3f 100644 --- a/flake.lock +++ b/flake.lock @@ -2,16 +2,18 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1721379653, - "narHash": "sha256-8MUgifkJ7lkZs3u99UDZMB4kbOxvMEXQZ31FO3SopZ0=", - "rev": "1d9c2c9b3e71b9ee663d11c5d298727dace8d374", - "revCount": 655136, - "type": "tarball", - "url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.1.655136%2Brev-1d9c2c9b3e71b9ee663d11c5d298727dace8d374/0190cd4f-c0eb-72cb-834b-ac854aa282dc/source.tar.gz" + "lastModified": 1767364772, + "narHash": "sha256-fFUnEYMla8b7UKjijLnMe+oVFOz6HjijGGNS1l7dYaQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "16c7794d0a28b5a37904d55bcca36003b9109aaa", + "type": "github" }, "original": { - "type": "tarball", - "url": "https://flakehub.com/f/NixOS/nixpkgs/0.1.%2A.tar.gz" + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" } }, "root": { diff --git a/flake.nix b/flake.nix index 63783fa97f3..bc4f549349f 100644 --- a/flake.nix +++ b/flake.nix @@ -1,7 +1,7 @@ { description = "A Nix-flake-based C/C++ development environment"; - inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz"; + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; outputs = { self, @@ -35,19 +35,14 @@ xorg.libXfixes libxkbcommon alsa-lib - mono - wayland-scanner wayland libdecor libpulseaudio dbus dbus.lib - speechd fontconfig fontconfig.lib udev - dotnet-sdk_8 - dotnet-runtime_8 scons ]; }); From abb3c4a241811f3709aa9e2e1c53ea9ff4ad4d6a Mon Sep 17 00:00:00 2001 From: MichaelFisher1997 Date: Sun, 4 Jan 2026 18:26:46 +0000 Subject: [PATCH 4/9] Add app to build and run Redot in one command --- flake.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/flake.nix b/flake.nix index bc4f549349f..8601b3c8ecf 100644 --- a/flake.nix +++ b/flake.nix @@ -47,6 +47,23 @@ ]; }); in { + apps = forEachSupportedSystem ({ + pkgs, + deps, + }: { + default = { + type = "app"; + program = pkgs.writeShellScript "redot" '' + export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath deps} + if [ ! -f ./bin/redot.linuxbsd.editor.x86_64 ]; then + echo "Building Redot..." + scons platform=linuxbsd + fi + exec ./bin/redot.linuxbsd.editor.x86_64 "$@" + ''; + }; + }); + devShells = forEachSupportedSystem ({ pkgs, deps, From 749428e0622873e6a2735f108c01fd7c1ea562c6 Mon Sep 17 00:00:00 2001 From: MichaelFisher1997 Date: Sun, 4 Jan 2026 18:27:29 +0000 Subject: [PATCH 5/9] Fix app program path reference --- flake.nix | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/flake.nix b/flake.nix index 8601b3c8ecf..1143ac79149 100644 --- a/flake.nix +++ b/flake.nix @@ -50,17 +50,19 @@ apps = forEachSupportedSystem ({ pkgs, deps, - }: { + }: let + script = pkgs.writeShellScript "redot" '' + export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath deps} + if [ ! -f ./bin/redot.linuxbsd.editor.x86_64 ]; then + echo "Building Redot..." + scons platform=linuxbsd + fi + exec ./bin/redot.linuxbsd.editor.x86_64 "$@" + ''; + in { default = { type = "app"; - program = pkgs.writeShellScript "redot" '' - export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath deps} - if [ ! -f ./bin/redot.linuxbsd.editor.x86_64 ]; then - echo "Building Redot..." - scons platform=linuxbsd - fi - exec ./bin/redot.linuxbsd.editor.x86_64 "$@" - ''; + program = "${script}"; }; }); From e55f2b93b52dcb9a5b84646b100c34fcc81e3033 Mon Sep 17 00:00:00 2001 From: MichaelFisher1997 Date: Sun, 4 Jan 2026 18:31:11 +0000 Subject: [PATCH 6/9] Add Nix build instructions to README --- README.md | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4ea568e280d..2a033544702 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,35 @@ Official binaries for the Redot editor and the export templates will be found ### Compiling from source -[For the time being, see the official Godot docs](https://docs.godotengine.org/en/latest/contributing/development/compiling) -for compilation instructions for every supported platform. +#### Using Nix (recommended) + +If you have the Nix package manager installed, you can build and run the editor in one command: + +```bash +nix run . +``` + +This will automatically install all build dependencies and compile Redot if the binary doesn't exist. + +For manual control over the build process: + +```bash +# Enter the Nix development environment +nix develop + +# Build Redot +scons platform=linuxbsd + +# Run the editor +./bin/redot.linuxbsd.editor.x86_64 +``` + +Nix works on Linux and macOS, and is available at [nixos.org/download.html](https://nixos.org/download.html). + +#### Other platforms + +[For time being, see official Godot docs](https://docs.godotengine.org/en/latest/contributing/development/compiling) +for compilation instructions for other platforms. ## Community and contributing From 6d42da856b3b47feafd19c9234898329bbf92a57 Mon Sep 17 00:00:00 2001 From: MichaelFisher1997 Date: Sun, 4 Jan 2026 18:32:57 +0000 Subject: [PATCH 7/9] Remove outdated other platforms compilation link --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 2a033544702..4056904adad 100644 --- a/README.md +++ b/README.md @@ -73,10 +73,6 @@ scons platform=linuxbsd Nix works on Linux and macOS, and is available at [nixos.org/download.html](https://nixos.org/download.html). -#### Other platforms - -[For time being, see official Godot docs](https://docs.godotengine.org/en/latest/contributing/development/compiling) -for compilation instructions for other platforms. ## Community and contributing From 97e7db3d215ade925489c133251b11f3d33343b1 Mon Sep 17 00:00:00 2001 From: MichaelFisher1997 Date: Sun, 4 Jan 2026 18:37:33 +0000 Subject: [PATCH 8/9] Add proper macOS/Darwin support with platform-specific dependencies --- flake.nix | 61 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/flake.nix b/flake.nix index 1143ac79149..2a9636703c7 100644 --- a/flake.nix +++ b/flake.nix @@ -12,19 +12,10 @@ nixpkgs.lib.genAttrs supportedSystems (system: f rec { pkgs = import nixpkgs {inherit system;}; - deps = with pkgs; [ - pkg-config + isDarwin = pkgs.lib.hasSuffix system "darwin"; + + linuxDeps = with pkgs; [ autoPatchelfHook - installShellFiles - python3 - speechd - wayland-scanner - makeWrapper - mono - dotnet-sdk_8 - dotnet-runtime_8 - vulkan-loader - libGL xorg.libX11 xorg.libXcursor xorg.libXinerama @@ -34,30 +25,61 @@ xorg.libXi xorg.libXfixes libxkbcommon - alsa-lib + wayland-scanner wayland libdecor + alsa-lib libpulseaudio + udev dbus dbus.lib + ]; + + darwinDeps = with pkgs; [ + Foundation + Cocoa + AudioToolbox + CoreAudio + CoreVideo + AVFoundation + ]; + + commonDeps = with pkgs; [ + pkg-config + installShellFiles + python3 + speechd + makeWrapper + mono + dotnet-sdk_8 + dotnet-runtime_8 + vulkan-loader + libGL fontconfig fontconfig.lib - udev scons ]; + + deps = if isDarwin then darwinDeps ++ commonDeps else linuxDeps ++ commonDeps; + libraryPathVar = if isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH"; + platform = if isDarwin then "macos" else "linuxbsd"; + binary = if isDarwin then "redot.macos.editor.x86_64" else "redot.linuxbsd.editor.x86_64"; }); in { apps = forEachSupportedSystem ({ pkgs, deps, + libraryPathVar, + platform, + binary, }: let script = pkgs.writeShellScript "redot" '' - export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath deps} - if [ ! -f ./bin/redot.linuxbsd.editor.x86_64 ]; then + export ${libraryPathVar}=${pkgs.lib.makeLibraryPath deps} + if [ ! -f ./bin/${binary} ]; then echo "Building Redot..." - scons platform=linuxbsd + scons platform=${platform} fi - exec ./bin/redot.linuxbsd.editor.x86_64 "$@" + exec ./bin/${binary} "$@" ''; in { default = { @@ -69,6 +91,7 @@ devShells = forEachSupportedSystem ({ pkgs, deps, + libraryPathVar, }: { default = pkgs.mkShell.override @@ -78,7 +101,7 @@ } { packages = deps; - LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath deps; + ${libraryPathVar} = pkgs.lib.makeLibraryPath deps; }; }); }; From 312cbc06562ccf54394ba9878e4bc2b543803ed0 Mon Sep 17 00:00:00 2001 From: MichaelFisher1997 Date: Sun, 4 Jan 2026 19:08:17 +0000 Subject: [PATCH 9/9] Fix architecture detection for ARM64 systems in Nix flake - Add dynamic arch detection using pkgs.stdenv.hostPlatform.isAarch64 - Update binary naming to use detected architecture instead of hardcoded x86_64 - Update README manual instructions to show platform/arch-agnostic guidance This fixes nix run . on ARM64 systems (Apple Silicon, ARM Linux). --- README.md | 11 ++++++----- flake.nix | 6 +++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4056904adad..af45646f250 100644 --- a/README.md +++ b/README.md @@ -64,14 +64,15 @@ For manual control over the build process: # Enter the Nix development environment nix develop -# Build Redot -scons platform=linuxbsd +# Build Redot (use 'macos' on macOS, 'linuxbsd' on Linux) +scons platform=linuxbsd # or: scons platform=macos -# Run the editor -./bin/redot.linuxbsd.editor.x86_64 +# Run the editor - binary name reflects your platform and architecture +# Examples: redot.linuxbsd.editor.x86_64, redot.macos.editor.arm64 +./bin/redot..editor. ``` -Nix works on Linux and macOS, and is available at [nixos.org/download.html](https://nixos.org/download.html). +Nix works on Linux and macOS, and is available at [nixos.org/download.html](https://nixos.org/download.html). The `nix run .` command automatically detects your platform and architecture. ## Community and contributing diff --git a/flake.nix b/flake.nix index 2a9636703c7..79456bcba3e 100644 --- a/flake.nix +++ b/flake.nix @@ -13,6 +13,7 @@ f rec { pkgs = import nixpkgs {inherit system;}; isDarwin = pkgs.lib.hasSuffix system "darwin"; + arch = if pkgs.stdenv.hostPlatform.isAarch64 then "arm64" else "x86_64"; linuxDeps = with pkgs; [ autoPatchelfHook @@ -63,7 +64,7 @@ deps = if isDarwin then darwinDeps ++ commonDeps else linuxDeps ++ commonDeps; libraryPathVar = if isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH"; platform = if isDarwin then "macos" else "linuxbsd"; - binary = if isDarwin then "redot.macos.editor.x86_64" else "redot.linuxbsd.editor.x86_64"; + binary = if isDarwin then "redot.macos.editor.${arch}" else "redot.linuxbsd.editor.${arch}"; }); in { apps = forEachSupportedSystem ({ @@ -72,6 +73,8 @@ libraryPathVar, platform, binary, + arch, + ... }: let script = pkgs.writeShellScript "redot" '' export ${libraryPathVar}=${pkgs.lib.makeLibraryPath deps} @@ -92,6 +95,7 @@ pkgs, deps, libraryPathVar, + ... }: { default = pkgs.mkShell.override