linuxPackages_latest.broadcom_sta: add patch to compile on Kernel 6.12 (#359484)
[NixPkgs.git] / pkgs / by-name / ve / veloren / package.nix
blobfff47f2583fa355e64e190152af6ce6fab1d9edb
2   lib,
3   rustPlatform,
4   fetchFromGitLab,
5   pkg-config,
6   vulkan-loader,
7   alsa-lib,
8   udev,
9   shaderc,
10   xorg,
11   libxkbcommon,
14 let
15   # Note: use this to get the release metadata
16   # https://gitlab.com/api/v4/projects/10174980/repository/tags/v{version}
17   version = "0.16.0";
18   date = "2023-03-30-03:28";
19   rev = "80fe5ca64b40fbf3e0e393a44f8880a79a6a5380";
22 rustPlatform.buildRustPackage {
23   pname = "veloren";
24   inherit version;
26   src = fetchFromGitLab {
27     owner = "veloren";
28     repo = "veloren";
29     inherit rev;
30     hash = "sha256-h2hLO227aeK2oEFfdGMgmtMkA9cn9AgQ9w6myb+8W8c=";
31   };
33   cargoLock.lockFile = ./Cargo.lock;
34   cargoLock.outputHashes = {
35     # Hashes of dependencies pinned to a git commit
36     "auth-common-0.1.0" = "sha256-6tUutHLY309xSBT2D7YueAmsAWyVn410XNKFT8yuTgA=";
37     "conrod_core-0.63.0" = "sha256-GxakbJBVTFgbtUsa2QB105xgd+aULuWLBlv719MIzQY=";
38     "egui_wgpu_backend-0.26.0" = "sha256-47XZoE7bFRv/TG4EmM2qit5L21qsKT6Nt/t1y/NMneQ=";
39     "fluent-0.16.0" = "sha256-xN+DwObqoToqprLDy3yvTiqclIIOsuUtpAQ6W1mdf0I=";
40     "iced_core-0.4.0" = "sha256-5s6IXcitoGcHS0FUx/cujx9KLBpaUuMnugmBged1cLA=";
41     "keyboard-keynames-0.1.2" = "sha256-5I70zT+Lwt0JXJgTAy/VygHdxIBuE/u3pq8LP8NkRdE=";
42     "naga-0.14.2" = "sha256-yyLrJNhbu/RIVr0hM7D7Rwd7vH3xX8Dns+u6m8NEU2M=";
43     "portpicker-0.1.0" = "sha256-or1907XdrDIyFzHNmW6me2EIyEQ8sjVIowfGsypa4jU=";
44     "shaderc-0.8.0" = "sha256-BU736g075i3GqlyyB9oyoVlQqNcWbZEGa8cdge1aMq0=";
45     "specs-0.20.0" = "sha256-OHnlag6SJ1rlAYnlmVD+uqY+kFNsbQ42W21RrEa8Xn0=";
46   };
47   cargoPatches = [
48     ./fix-on-rust-stable.patch
49     ./fix-assets-path.patch
50   ];
52   postPatch = ''
53     # Use our Cargo.lock
54     cp ${./Cargo.lock} Cargo.lock
56     # Force vek to build in unstable mode
57     cat <<'EOF' | tee "$cargoDepsCopy"/vek-*/build.rs
58     fn main() {
59       println!("cargo:rustc-check-cfg=cfg(nightly)");
60       println!("cargo:rustc-cfg=nightly");
61     }
62     EOF
63   '';
65   nativeBuildInputs = [ pkg-config ];
66   buildInputs = [
67     alsa-lib
68     udev
69     xorg.libxcb
70     libxkbcommon
71   ];
73   buildNoDefaultFeatures = true;
74   buildFeatures = [ "default-publish" ];
76   env = {
77     # Enable unstable features, see https://gitlab.com/veloren/veloren/-/issues/264
78     RUSTC_BOOTSTRAP = true;
80     # Set version info, required by veloren-common
81     NIX_GIT_TAG = "v${version}";
82     NIX_GIT_HASH = "${lib.substring 0 7 rev}/${date}";
84     # Save game data under user's home directory,
85     # otherwise it defaults to $out/bin/../userdata
86     VELOREN_USERDATA_STRATEGY = "system";
88     # Use system shaderc
89     SHADERC_LIB_DIR = "${shaderc.lib}/lib";
90   };
92   # Some tests require internet access
93   doCheck = false;
95   postFixup = ''
96     # Add required but not explicitly requested libraries
97     patchelf --add-rpath '${
98       lib.makeLibraryPath [
99         xorg.libX11
100         xorg.libXi
101         xorg.libXcursor
102         xorg.libXrandr
103         vulkan-loader
104       ]
105     }' "$out/bin/veloren-voxygen"
106   '';
108   postInstall = ''
109     # Icons
110     install -Dm644 assets/voxygen/net.veloren.veloren.desktop -t "$out/share/applications"
111     install -Dm644 assets/voxygen/net.veloren.veloren.png "$out/share/pixmaps"
112     install -Dm644 assets/voxygen/net.veloren.veloren.metainfo.xml "$out/share/metainfo"
113     # Assets directory
114     mkdir -p "$out/share/veloren"; cp -ar assets "$out/share/veloren/"
115   '';
117   meta = with lib; {
118     description = "An open world, open source voxel RPG";
119     homepage = "https://www.veloren.net";
120     license = licenses.gpl3;
121     mainProgram = "veloren-voxygen";
122     platforms = platforms.linux;
123     maintainers = with maintainers; [ rnhmjoj tomodachi94 ];
124   };