Add a Nix flake (#2097)

Adds a Nix flake, allowing easy building and running of melonDS using the Nix package manager, as well as potentially very stable and reproducible CI in the future.
This commit is contained in:
Nadia Holmquist Pedersen 2024-08-08 05:36:06 +02:00 committed by GitHub
parent 53c58bd777
commit ec71b15505
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 135 additions and 0 deletions

61
flake.lock Normal file
View File

@ -0,0 +1,61 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1722813957,
"narHash": "sha256-IAoYyYnED7P8zrBFMnmp7ydaJfwTnwcnqxUElC1I26Y=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "cb9a96f23c491c081b38eab96d22fa958043c9fa",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

72
flake.nix Normal file
View File

@ -0,0 +1,72 @@
{
description = "Nintendo DS emulator";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
inherit (pkgs.lib) cmakeBool optionals makeLibraryPath;
inherit (pkgs.stdenv) isLinux isDarwin;
versionSuffix = with self; if sourceInfo?dirtyShortRev
then sourceInfo.dirtyShortRev
else sourceInfo.shortRev;
melonDS = pkgs.stdenv.mkDerivation {
pname = "melonDS";
version = "0.9.5-${versionSuffix}";
src = ./.;
nativeBuildInputs = with pkgs; [
cmake
ninja
pkg-config
kdePackages.wrapQtAppsHook
];
buildInputs = (with pkgs; [
kdePackages.qtbase
kdePackages.qtmultimedia
extra-cmake-modules
SDL2
zstd
libarchive
libGL
libslirp
]) ++ optionals isLinux [
pkgs.wayland
pkgs.kdePackages.qtwayland
];
cmakeFlags = [
(cmakeBool "USE_QT6" true)
(cmakeBool "USE_SYSTEM_LIBSLIRP" true)
];
qtWrapperArgs = optionals isLinux [
"--prefix LD_LIBRARY_PATH : ${makeLibraryPath [ pkgs.libpcap ]}"
] ++ optionals isDarwin [
"--prefix DYLD_LIBRARY_PATH : ${makeLibraryPath [ pkgs.libpcap ]}"
];
passthru = {
exePath = if isDarwin then
"/Applications/melonDS.app/Contents/MacOS/melonDS"
else "/bin/melonDS";
};
};
in {
packages.default = melonDS;
apps.default = flake-utils.lib.mkApp {
drv = self.packages.${system}.default;
};
devShells.default = pkgs.mkShell {
inputsFrom = [ self.packages.${system}.default ];
};
}
);
}

View File

@ -240,6 +240,8 @@ if (UNIX AND NOT APPLE)
INTERPROCEDURAL_OPTIMIZATION OFF INTERPROCEDURAL_OPTIMIZATION OFF
INTERPROCEDURAL_OPTIMIZATION_RELEASE OFF) INTERPROCEDURAL_OPTIMIZATION_RELEASE OFF)
endif() endif()
elseif(APPLE)
install(TARGETS melonDS BUNDLE DESTINATION "${CMAKE_INSTALL_PREFIX}/Applications")
endif() endif()
if (ENABLE_OGLRENDERER) if (ENABLE_OGLRENDERER)