nix: move build support to dir, add .envrc for using nix dev env

This commit is contained in:
71rd 2024-06-06 15:26:38 +00:00
parent e25a563555
commit c98931959f
9 changed files with 90 additions and 176 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.

View file

@ -27,7 +27,7 @@ assert (platform == "linux" ) -> (enableVulkan || enableOpenGL);
rustPlatform.buildRustPackage rec {
name = "outfly";
inherit buildType;
src = ./.;
src = ./../..;
version = if (self ? rev) then self.rev else "dirty";
buildNoDefaultFeatures = true;
@ -50,12 +50,17 @@ rustPlatform.buildRustPackage rec {
--add-rpath ${lib.makeLibraryPath runtimeInputs}
'';
cargoLock = { lockFile = ./Cargo.lock; };
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 @@
{
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}
'';
}
with import <nixpkgs> { }; callPackage ./build.nix { version = "0.7.1"; }

View file

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

View file

@ -1,17 +1,48 @@
{
description = "A breathtaking 3D space game in the rings of Jupiter";
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 { version = "0.7.0"; };
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
pkgs = import nixpkgs { system = "x86_64-linux"; };
in pkgs.callPackage ./default.nix {};
devShells.default = let
buildInputs = [
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}";
};
});
}

View file

@ -1 +0,0 @@
with import <nixpkgs> { }; callPackage ./build.nix { version = "0.7.1"; }

View file

@ -1,61 +0,0 @@
{
"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": 1713248628,
"narHash": "sha256-NLznXB5AOnniUtZsyy/aPWOk8ussTuePp2acb9U+ISA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5672bc9dbf9d88246ddab5ac454e82318d094bb8",
"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
}

View file

@ -1,48 +0,0 @@
{
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
overlays = [ ];
pkgs = import nixpkgs { inherit system overlays; };
in {
packages.outfly = pkgs.callPackage ./build.nix { version = "0.7.0"; };
packages.default = self.packages.${system}.outfly;
apps.outfly = {
type = "app";
program = "${self.packages.${system}.outfly}/bin/outfly";
};
apps.default = self.apps.${system}.outfly;
devShells.default = let
buildInputs = [
pkgs.alsa-lib.dev
#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}";
};
});
}