Merge remote-tracking branch '71rd/flake-0.10'

This commit is contained in:
yuni 2024-08-01 19:48:47 +02:00
commit b46b3bb284
6 changed files with 152 additions and 64 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake ./build/nix

View file

@ -1 +0,0 @@
This is a work-in-progress nix package. It successfully worked on one NixOS system, but failed on another due to obscure errors. It also failed using "nix build" on ArchLinux.

69
build/nix/build.nix Normal file
View file

@ -0,0 +1,69 @@
{ lib
, self ? null
, buildType ? "release"
, platform ? "linux"
, enableWayland ? true
, enableXorg ? true
, enableOpenGL ? true
, enableVulkan ? true
, rustPlatform
, makeDesktopItem
, pkg-config
, libxkbcommon
, alsa-lib
, libGL
, vulkan-loader
, wayland
, libXrandr
, libXcursor
, libX11
, libXi
, ...
}:
assert (platform == "linux" ) -> (enableWayland || enableXorg);
assert (platform == "linux" ) -> (enableVulkan || enableOpenGL);
rustPlatform.buildRustPackage rec {
name = "outfly";
inherit buildType;
src = ./../..;
version = if (self ? rev) then self.rev else "dirty";
buildNoDefaultFeatures = true;
buildFeatures = [ "embed_assets" ] ++ lib.optionals enableXorg [ "x11" ]
++ lib.optionals enableWayland [ "wayland" ];
runtimeInputs = [ libxkbcommon ]
++ lib.optionals enableOpenGL [ libGL ]
++ lib.optionals enableXorg [ libXrandr libX11 ]
++ lib.optionals enableVulkan [ vulkan-loader ];
buildInputs = [ alsa-lib.dev libXcursor libXi ]
++ lib.optionals enableWayland [ wayland ];
nativeBuildInputs = [ pkg-config ];
doCheck = false;
postFixup = ''
patchelf $out/bin/outfly \
--add-rpath ${lib.makeLibraryPath runtimeInputs}
'';
postPatch = ''
find ../cargo-vendor-dir -name Cargo.toml -exec sed -i 's/^workspace = true//' {} +
'';
cargoLock = { lockFile = ./../../Cargo.lock; };
desktopItems = [
(makeDesktopItem {
name = "outfly";
exec = "outfly";
desktopName = "OutFly";
categories = [ "Game" ];
})
];
}

View file

@ -1,47 +1 @@
{ with import <nixpkgs> { }; callPackage ./build.nix { }
rustPlatform,
pkg-config,
alsa-lib,
libcap,
libxkbcommon,
wayland,
udev,
vulkan-loader,
xorg,
lib,
}:
rustPlatform.buildRustPackage rec {
src = ../../..;
pname = "outfly";
version = "0.8.1";
cargoLock = {
lockFile = "${src}/Cargo.lock";
};
nativeBuildInputs = [ pkg-config ];
buildNoDefaultFeatures = true;
buildFeatures = [
"release_linux"
];
buildInputs = [
alsa-lib
libcap
wayland
];
postFixup =
let
runtimeDeps = [
vulkan-loader
libxkbcommon
xorg.libX11
xorg.libXrandr
xorg.libXi
xorg.libXcursor
];
libPath = lib.makeLibraryPath runtimeDeps;
in
''
patchelf $out/bin/outfly \
--add-rpath ${libPath}
'';
}

View file

@ -1,16 +1,34 @@
{ {
"nodes": { "nodes": {
"nixpkgs": { "flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": { "locked": {
"lastModified": 1714076141, "lastModified": 1710146030,
"narHash": "sha256-Drmja/f5MRHZCskS6mvzFqxEaZMeciScCTFxWVLqWEY=", "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "nixos", "owner": "numtide",
"repo": "nixpkgs", "repo": "flake-utils",
"rev": "7bb2ccd8cdc44c91edba16c48d2c8f331fb3d856", "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nixos", "owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1722185531,
"narHash": "sha256-veKR07psFoJjINLC8RK4DiLniGGMgF3QMlS4tb74S6k=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "52ec9ac3b12395ad677e8b62106f0b98c1f8569d",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable", "ref": "nixos-unstable",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
@ -18,8 +36,24 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs" "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", "root": "root",

View file

@ -1,17 +1,48 @@
{ {
description = "A breathtaking 3D space game in the rings of Jupiter";
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; 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
overlays = [ ];
pkgs = import nixpkgs { inherit system overlays; };
in {
packages.outfly = pkgs.callPackage ./build.nix {};
packages.default = self.packages.${system}.outfly;
outputs = { self, nixpkgs }: { apps.outfly = {
type = "app";
program = "${self.packages.${system}.outfly}/bin/outfly";
};
apps.default = self.apps.${system}.outfly;
packages.x86_64-linux.outfly = let devShells.default = let
pkgs = import nixpkgs { system = "x86_64-linux"; }; buildInputs = [
in pkgs.callPackage ./default.nix {}; pkgs.alsa-lib.dev
packages.x86_64-linux.default = self.packages.x86_64-linux.outfly; #opengl
pkgs.libGL
}; pkgs.libxkbcommon
pkgs.xorg.libXcursor
pkgs.xorg.libXi
pkgs.xorg.libXrandr
pkgs.xorg.libX11
pkgs.vulkan-loader
];
nativeBuildInputs = [
pkgs.cargo
pkgs.pkg-config
];
in pkgs.mkShell {
inherit buildInputs nativeBuildInputs;
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath buildInputs}";
};
});
} }