Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NixOS Flake #247

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

88 changes: 88 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
description = "A Nix-flake-based C/C++ development environment";

inputs = {
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz";
systems.url = "github:nix-systems/default";
};

outputs =
{
self,
nixpkgs,
systems,
}:
let
forEachSupportedSystem =
f:
nixpkgs.lib.genAttrs (import systems) (
system:
f {
pkgs = import nixpkgs { inherit system; };
}
);
in
{
packages = forEachSupportedSystem (
{
pkgs,
}:
{
default = pkgs.callPackage ./package.nix {
};
}
);
devShells = forEachSupportedSystem (
{
pkgs,
}:
{
default =
pkgs.mkShell.override
{
# Override stdenv in order to change compiler:
# stdenv = pkgs.clangStdenv;
}
rec {
packages =
with pkgs;
[
pkg-config
autoPatchelfHook
installShellFiles
python3
makeWrapper
dotnet-sdk_8
dotnet-runtime_8
vulkan-loader
vulkan-headers
fontconfig
fontconfig.lib
scons
]
++ pkgs.lib.optionals pkgs.stdenv.targetPlatform.isLinux [
speechd
alsa-lib
xorg.libX11
xorg.libXcursor
xorg.libXinerama
xorg.libXext
xorg.libXrandr
xorg.libXrender
xorg.libXi
xorg.libXfixes
libxkbcommon
dbus
dbus.lib
udev
wayland-scanner
wayland
libdecor
libpulseaudio
];
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath packages;
};
}
);
};
}
101 changes: 101 additions & 0 deletions package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
stdenv,
lib,
enableWayland ? stdenv.targetPlatform.isLinux,
enablePulseAudio ? stdenv.targetPlatform.isLinux,
enableX11 ? stdenv.targetPlatform.isLinux,
enableAlsa ? stdenv.targetPlatform.isLinux,
enableSpeechd ? stdenv.targetPlatform.isLinux,
enableVulkan ? true,
pkg-config,
autoPatchelfHook,
installShellFiles,
python3,
scons,
makeWrapper,
vulkan-loader,
vulkan-headers,
speechd,
fontconfig,
wayland,
wayland-scanner,
wayland-protocols,
libdecor,
libxkbcommon,
libpulseaudio,
xorg,
udev,
alsa-lib,
dbus,
xcbuild,
darwin,
}:

stdenv.mkDerivation {
name = "redot-engine";
src = ./.;

nativeBuildInputs = [
pkg-config
autoPatchelfHook
installShellFiles
makeWrapper
python3
scons
];

buildInputs =
[
fontconfig
]
++ lib.optionals enableSpeechd [ speechd ]
++ lib.optionals enableVulkan [
vulkan-loader
vulkan-headers
]
++ lib.optionals enableWayland [
wayland
wayland-scanner
wayland-protocols
libdecor
libxkbcommon
]
++ lib.optionals enablePulseAudio [ libpulseaudio ]
++ lib.optionals enableX11 [
xorg.libX11
xorg.libXcursor
xorg.libXinerama
xorg.libXext
xorg.libXrandr
xorg.libXrender
xorg.libXi
xorg.libXfixes
]
++ lib.optionals enableAlsa [ alsa-lib ]
++ lib.optionals stdenv.targetPlatform.isLinux [
udev
dbus
]
++ lib.optionals stdenv.targetPlatform.isDarwin [
xcbuild
darwin.moltenvk
]
++ lib.optionals stdenv.targetPlatform.isDarwin (
with darwin.apple_sdk.frameworks;
[
AppKit
]
);

sconsFlags = lib.optionals stdenv.targetPlatform.isDarwin [
"vulkan_sdk_path=${darwin.moltenvk}"
];

installPhase = ''
runHook preInstall
mkdir -p "$out/bin"
cp bin/redot*.* $out/bin/redot

runHook postInstall
'';
}
4 changes: 4 additions & 0 deletions platform_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,12 @@ def detect_mvk(env, osname):
)

for mvk_path in mvk_list:
# FIXME: Iterate over all files in the sdk path
if mvk_path and os.path.isfile(os.path.join(mvk_path, f"{osname}/libMoltenVK.a")):
print(f"MoltenVK found at: {mvk_path}")
return mvk_path
elif mvk_path and os.path.isfile(os.path.join(mvk_path, f"lib/libMoltenVK.dylib")):
print(f"MoltenVK found at: {mvk_path}")
return mvk_path

return ""