diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..1972867 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake ./build/nix diff --git a/build/nix/README.md b/build/nix/README.md deleted file mode 100644 index e424bd6..0000000 --- a/build/nix/README.md +++ /dev/null @@ -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. diff --git a/build.nix b/build/nix/build.nix similarity index 88% rename from build.nix rename to build/nix/build.nix index 62e067c..f4cd23e 100644 --- a/build.nix +++ b/build/nix/build.nix @@ -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" ]; }) diff --git a/build/nix/default.nix b/build/nix/default.nix index af58bda..3eb8439 100644 --- a/build/nix/default.nix +++ b/build/nix/default.nix @@ -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 { }; callPackage ./build.nix { version = "0.7.1"; } diff --git a/build/nix/flake.lock b/build/nix/flake.lock index a8dd10e..f3856ec 100644 --- a/build/nix/flake.lock +++ b/build/nix/flake.lock @@ -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", diff --git a/build/nix/flake.nix b/build/nix/flake.nix index 09f2afd..00bfec2 100644 --- a/build/nix/flake.nix +++ b/build/nix/flake.nix @@ -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}"; + }; + }); } diff --git a/default.nix b/default.nix deleted file mode 100644 index 3eb8439..0000000 --- a/default.nix +++ /dev/null @@ -1 +0,0 @@ -with import { }; callPackage ./build.nix { version = "0.7.1"; } diff --git a/flake.lock b/flake.lock deleted file mode 100644 index f3856ec..0000000 --- a/flake.lock +++ /dev/null @@ -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 -} diff --git a/flake.nix b/flake.nix deleted file mode 100644 index 00bfec2..0000000 --- a/flake.nix +++ /dev/null @@ -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}"; - }; - }); -}