chore(nix): add Nix flake

master
yvt 2022-07-02 23:24:02 +09:00
parent 6844e7100c
commit ada6a8e739
5 changed files with 136 additions and 17 deletions

4
.gitignore vendored
View File

@ -63,6 +63,10 @@ OpenSpades.msvc/
# Linux build path
openspades.mk/
# Nix
/outputs
/result
# fltk / fluid output leftovers
Sources/Gui/DetailConfigWindow.txt
Sources/Gui/MainWindow.txt

View File

@ -110,6 +110,26 @@ Alternatively, to install the game to a different directory, take the following
After successful installation, optionally you can remove the source code and build outputs to save disk space (~100MB).
#### On Linux (from source, by Nix Flakes)
To build and run OpenSpades from the latest source code:
```bash
nix shell github:yvt/openspades -c openspades
```
To build and run OpenSpades for development:
```bash
git clone https://github.com/yvt/openspades.git && cd openspades
nix develop
# note: this will patch CMake files in the source tree
cmakeBuildType=RelWithDebInfo cmakeConfigurePhase
buildPhase
bin/openspades
```
**note**: Nix Flakes are an experimental feature of Nix and must be enabled manually. See [this wiki article](https://nixos.wiki/wiki/Flakes) for how to do that.
### On Windows (with Visual Studio)
1. Get the required software if you haven't already:
* CMake 2.8+

41
flake.lock Normal file
View File

@ -0,0 +1,41 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1656065134,
"narHash": "sha256-oc6E6ByIw3oJaIyc67maaFcnjYOz1mMcOtHxbEf9NwQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "bee6a7250dd1b01844a2de7e02e4df7d8a0a206c",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1656633783,
"narHash": "sha256-nXMIGtQXBGzO57nkPxgEOx8HLRwVQ+d1WkOnE01JG4A=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "95e79164be1f7d883ed9ffda8b7d4ad3a17e6c1e",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

63
flake.nix Normal file
View File

@ -0,0 +1,63 @@
{
description = "A compatible client of Ace of Spades 0.75";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) stdenv;
# Non-GPL assets - please see `PakLocation.txt` for the terms of use
# and issue #424 for the situation
devPackage = pkgs.fetchurl {
url = https://github.com/yvt/openspades-paks/releases/download/r33/OpenSpadesDevPackage-r33.zip;
sha256 = "CSfcMjoLOroO6NHWjWtUSwD+ZUdA/q1tH6rTeqx3oq0=";
};
# Google Noto Fonts, licensed under the SIL Open Font License
notoFontPak = pkgs.fetchurl {
url = https://github.com/yvt/openspades/releases/download/v0.1.1b/NotoFonts.pak;
sha256 = "VQYMZNYqNBZ9+01YCcabqqIfck/mU/BRcFZKXpBEX00=";
};
in rec {
packages.default = packages.openspades;
packages.openspades = stdenv.mkDerivation rec {
pname = "openspades";
version = "0.1.5-beta";
src = ./.;
nativeBuildInputs = with pkgs; [ cmake imagemagick unzip zip file ];
buildInputs = with pkgs;
([
freetype SDL2 SDL2_image libGL zlib curl glew opusfile openal libogg
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
darwin.apple_sdk.frameworks.Cocoa
]);
cmakeFlags = [ "-DOPENSPADES_INSTALL_BINARY=bin" ];
inherit notoFontPak;
# Used by `downloadpak.sh`. Instructs the script to copy the
# development package from this path instead of downloading it.
OPENSPADES_DEVPAK_PATH = devPackage;
postPatch = ''
patchShebangs Resources
'';
postInstall = ''
cp $notoFontPak $out/share/games/openspades/Resources/
'';
NIX_CFLAGS_LINK = "-lopenal";
};
});
}

View File

@ -1,17 +1,8 @@
with import <nixpkgs> {};
with pkgs.xorg;
runCommand "dummy" rec {
nativeBuildInputs = [ cmake imagemagick unzip zip file gcc ];
buildInputs = [
freetype SDL2 SDL2_image libGL zlib curl glew opusfile openal libogg pkgconfig libopus libGLU
libXext pkg-config
];
NIX_CFLAGS_LINK = [ "-L${libXext}/lib" ];
NIX_CFLAGS_COMPILE= ["-I${libogg.dev}/include" "-I${libopus.dev}/include" "-I${libGLU.dev}/include" ];
LD_LIBRARY_PATH = [ "${openal}/lib" ];
} ""
# Flake's devShell for non-flake-enabled nix instances
let
compat = builtins.fetchGit {
url = "https://github.com/edolstra/flake-compat.git";
rev = "b4a34015c698c7793d592d66adbab377907a2be8";
};
in
(import compat {src = ./.;}).shellNix.default