mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
build(nix): switch to naersk
This commit is contained in:
parent
379ab0f341
commit
e9a7ff7dd7
1
.gitignore
vendored
1
.gitignore
vendored
@ -52,3 +52,4 @@ userdata
|
||||
# Nix
|
||||
nix/result*
|
||||
/result*
|
||||
/shell.nix
|
||||
|
98
flake.lock
98
flake.lock
@ -1,29 +1,27 @@
|
||||
{
|
||||
"nodes": {
|
||||
"crate2nix": {
|
||||
"flake": false,
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1606659997,
|
||||
"narHash": "sha256-wpJOCcbgQNeV2Dq2rvbf9Atjs8So5m7wUaP0xdr4u3w=",
|
||||
"owner": "kolloch",
|
||||
"repo": "crate2nix",
|
||||
"rev": "3701179c8aef0677dab1915457ca0f367f2dc523",
|
||||
"lastModified": 1609246779,
|
||||
"narHash": "sha256-eq6ZXE/VWo3EMC65jmIT6H/rrUc9UWOWVujkzav025k=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "08c7ad4a0844adc4a7f9f5bb3beae482e789afa4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "kolloch",
|
||||
"repo": "crate2nix",
|
||||
"rev": "3701179c8aef0677dab1915457ca0f367f2dc523",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"flakeUtils": {
|
||||
"locked": {
|
||||
"lastModified": 1605370193,
|
||||
"narHash": "sha256-YyMTf3URDL/otKdKgtoMChu4vfVL3vCMkRqpGifhUn0=",
|
||||
"lastModified": 1614513358,
|
||||
"narHash": "sha256-LakhOx3S1dRjnh0b5Dg3mbZyH0ToC9I8Y2wKSkBaTzU=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "5021eac20303a61fafe17224c087f5519baed54d",
|
||||
"rev": "5466c5bbece17adaab2d82fae80b46e807611bf3",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -32,44 +30,70 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"naersk": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1616263753,
|
||||
"narHash": "sha256-wf1naH44D0Z7+JNpD6T/6/d0XaXDi9r4Oi100pBtzhs=",
|
||||
"owner": "yusdacra",
|
||||
"repo": "naersk",
|
||||
"rev": "8cd4d175606de222114c551c85847acb013cc9cb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "yusdacra",
|
||||
"ref": "veloren",
|
||||
"repo": "naersk",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1606744648,
|
||||
"narHash": "sha256-/sBYrKS4uNFeX3cX1qmQ/viyqiDz7Eq/XoX4v2qSVgk=",
|
||||
"lastModified": 1616259034,
|
||||
"narHash": "sha256-WlMIiGIXJm7J+jemzd+ksoun6znWmabCZNz76szV158=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "c00959877fb06b09468562518b408acda886c79e",
|
||||
"rev": "4e0d3868c679da20108db402785f924daa1a7fb5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "c00959877fb06b09468562518b408acda886c79e",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgsMoz": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1603906276,
|
||||
"narHash": "sha256-RsNPnEKd7BcogwkqhaV5kI/HuNC4flH/OQCC/4W5y/8=",
|
||||
"owner": "mozilla",
|
||||
"repo": "nixpkgs-mozilla",
|
||||
"rev": "8c007b60731c07dd7a052cce508de3bb1ae849b4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "mozilla",
|
||||
"repo": "nixpkgs-mozilla",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"crate2nix": "crate2nix",
|
||||
"flake-utils": "flake-utils",
|
||||
"flakeUtils": "flakeUtils",
|
||||
"naersk": "naersk",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"nixpkgsMoz": "nixpkgsMoz"
|
||||
"rustOverlay": "rustOverlay"
|
||||
}
|
||||
},
|
||||
"rustOverlay": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1616467144,
|
||||
"narHash": "sha256-7iGzusiBdQcXGrnQGcLwRoEiKtH3bNGIpXu+TJTD6Gw=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "cdaa20a3e7f97d5fad271464dac7e2725157c6e7",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
72
flake.nix
72
flake.nix
@ -2,59 +2,59 @@
|
||||
description = "Flake providing Veloren, a multiplayer voxel RPG written in Rust.";
|
||||
|
||||
inputs = {
|
||||
crate2nix = {
|
||||
url = "github:kolloch/crate2nix?rev=3701179c8aef0677dab1915457ca0f367f2dc523";
|
||||
flake = false;
|
||||
naersk = {
|
||||
url = "github:yusdacra/naersk/veloren";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
nixpkgsMoz = {
|
||||
url = "github:mozilla/nixpkgs-mozilla";
|
||||
flake = false;
|
||||
flakeUtils.url = "github:numtide/flake-utils";
|
||||
rustOverlay = {
|
||||
url = "github:oxalica/rust-overlay";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
nixpkgs.url = "github:NixOS/nixpkgs?rev=c00959877fb06b09468562518b408acda886c79e";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
};
|
||||
|
||||
outputs = inputs: with inputs;
|
||||
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
|
||||
outputs = inputs: with inputs; with flakeUtils.lib;
|
||||
eachSystem [ "x86_64-linux" ] (system:
|
||||
let
|
||||
sources = {
|
||||
inherit
|
||||
crate2nix
|
||||
nixpkgs
|
||||
nixpkgsMoz
|
||||
;
|
||||
common = import ./nix/common.nix {
|
||||
sources = {
|
||||
inherit
|
||||
naersk
|
||||
nixpkgs
|
||||
rustOverlay
|
||||
;
|
||||
};
|
||||
inherit system;
|
||||
};
|
||||
|
||||
veloren = import ./nix/veloren.nix {
|
||||
inherit
|
||||
nixpkgs
|
||||
sources
|
||||
system
|
||||
;
|
||||
mkPackage = crateName: import ./nix/build.nix {
|
||||
inherit common;
|
||||
crateToBuild = crateName;
|
||||
sourceInfo =
|
||||
if self.sourceInfo ? rev then self.sourceInfo // {
|
||||
if self.sourceInfo ? rev
|
||||
then self.sourceInfo // {
|
||||
# Tag would have to be set manually for stable releases flake
|
||||
# because there's currently no way to get the tag via the interface.
|
||||
# tag = v0.8.0;
|
||||
} else (throw "Can't get revision because the git tree is dirty");
|
||||
}
|
||||
else (throw "Can't get revision because the git tree is dirty");
|
||||
};
|
||||
|
||||
in
|
||||
with flake-utils; rec {
|
||||
apps = builtins.mapAttrs
|
||||
(name: value: lib.mkApp { inherit name; drv = value; })
|
||||
packages;
|
||||
defaultApp = apps.veloren-voxygen;
|
||||
cratesToPackage = [ "veloren-voxygen" "veloren-server-cli" ];
|
||||
|
||||
packages = veloren;
|
||||
genAttrs = names: f:
|
||||
builtins.listToAttrs (map (n: { name = n; value = f n; }) names);
|
||||
in
|
||||
rec {
|
||||
packages = genAttrs cratesToPackage mkPackage;
|
||||
defaultPackage = packages.veloren-voxygen;
|
||||
|
||||
apps = builtins.mapAttrs (n: v: mkApp { name = n; drv = v; }) packages;
|
||||
defaultApp = apps.veloren-voxygen;
|
||||
|
||||
devShell = import ./nix/devShell.nix {
|
||||
inherit
|
||||
nixpkgs
|
||||
sources
|
||||
system
|
||||
;
|
||||
inherit common;
|
||||
};
|
||||
}
|
||||
);
|
||||
|
18816
nix/Cargo.nix
18816
nix/Cargo.nix
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,7 @@
|
||||
## Read this first!
|
||||
|
||||
#### You'll need at least Nix `2.4pre20210317_8a5203d`!
|
||||
|
||||
Since this repo uses a new Nix feature called "Flakes", it is recommended to enable it.
|
||||
It massively improves the `nix` CLI UX, and adds many useful features.
|
||||
We include instructions for Nix without flakes enabled, but using flakes is the recommended way.
|
||||
@ -184,15 +186,6 @@ It is inadvised to update revisions without the use of `nix flake update` as it'
|
||||
|
||||
Modify the relevant `rev` field in `flake.lock` to what you need - you can use `nix-prefetch-git` to find an up-to-date revision. Leave the `narHash` entry as is and attempt a rebuild to find out what its value should be.
|
||||
|
||||
### Generating Cargo.nix
|
||||
|
||||
Enter the development shell.
|
||||
|
||||
To update `Cargo.nix` (and `crate-hashes.json`) using latest `Cargo.lock`, run:
|
||||
```shell
|
||||
crate2nix generate -f ../Cargo.toml
|
||||
```
|
||||
|
||||
### Rust toolchain
|
||||
|
||||
If the `rust-toolchain` file is updated, you will need to update the `sha256` hash in the `nix/rustPkgs.nix` file.
|
||||
|
118
nix/build.nix
Normal file
118
nix/build.nix
Normal file
@ -0,0 +1,118 @@
|
||||
{ common
|
||||
, release ? true
|
||||
, crateToBuild ? "veloren-voxygen"
|
||||
, disableGitLfsCheck ? false
|
||||
, sourceInfo ? { }
|
||||
}:
|
||||
with common;
|
||||
let
|
||||
utils = import ./utils.nix { inherit pkgs; };
|
||||
|
||||
meta = with pkgs.lib; {
|
||||
description = "Veloren is a multiplayer voxel RPG written in Rust.";
|
||||
longDescription = ''
|
||||
Veloren is a multiplayer voxel RPG written in Rust.
|
||||
It is inspired by games such as Cube World, Legend of Zelda: Breath of the Wild, Dwarf Fortress and Minecraft.
|
||||
'';
|
||||
homepage = "https://veloren.net";
|
||||
license = licenses.gpl3;
|
||||
maintainers = [ maintainers.yusdacra ];
|
||||
# TODO: Make this work on BSD and Mac OS
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
|
||||
prettyRev = with sourceInfo; builtins.substring 0 8 rev + "/" + utils.dateTimeFormat lastModified;
|
||||
|
||||
tag = with sourceInfo;
|
||||
if sourceInfo ? tag
|
||||
then sourceInfo.tag
|
||||
else "";
|
||||
|
||||
# If gitTag has a tag (meaning the commit we are on is a *release*), use
|
||||
# it as version, else: just use the prettified hash we have, if we don't
|
||||
# have it the build fails.
|
||||
# Must be in format f4987672/2020-12-10-12:00
|
||||
version =
|
||||
if tag != "" then tag
|
||||
else if prettyRev != "" then prettyRev
|
||||
else throw "Need a tag or pretty revision in order to determine version";
|
||||
|
||||
veloren-assets = pkgs.runCommand "makeAssetsDir" { } ''
|
||||
mkdir $out
|
||||
ln -sf ${../assets} $out/assets
|
||||
'';
|
||||
|
||||
velorenVoxygenDesktopFile = pkgs.makeDesktopItem rec {
|
||||
name = "veloren-voxygen";
|
||||
exec = name;
|
||||
icon = ../assets/voxygen/logo.ico;
|
||||
comment =
|
||||
"Official client for Veloren - the open-world, open-source multiplayer voxel RPG";
|
||||
desktopName = "Voxygen";
|
||||
genericName = "Veloren Client";
|
||||
categories = "Game;";
|
||||
};
|
||||
|
||||
velorenOverride = oldAttr: with pkgs;
|
||||
if crateToBuild == "veloren-voxygen"
|
||||
then
|
||||
{
|
||||
pname = "veloren-voxygen";
|
||||
inherit version;
|
||||
|
||||
nativeBuildInputs = (oldAttr.nativeBuildInputs or [ ]) ++ [ makeWrapper copyDesktopItems ];
|
||||
desktopItems = [ velorenVoxygenDesktopFile ];
|
||||
postInstall = ''
|
||||
wrapProgram $out/bin/veloren-voxygen\
|
||||
--set VELOREN_ASSETS ${veloren-assets}\
|
||||
--set LD_LIBRARY_PATH ${
|
||||
lib.makeLibraryPath common.voxygenNeededLibs
|
||||
}
|
||||
'';
|
||||
meta = meta // {
|
||||
longDescription = ''
|
||||
${meta.longDescription}
|
||||
"This package includes the official client, Voxygen."
|
||||
'';
|
||||
};
|
||||
}
|
||||
else if crateToBuild == "veloren-server-cli"
|
||||
then
|
||||
{
|
||||
pname = "veloren-server-cli";
|
||||
inherit version;
|
||||
|
||||
nativeBuildInputs = (oldAttr.nativeBuildInputs or [ ]) ++ [ makeWrapper ];
|
||||
postInstall = ''
|
||||
wrapProgram $out/bin/veloren-server-cli --set VELOREN_ASSETS ${veloren-assets}
|
||||
'';
|
||||
meta = meta // {
|
||||
longDescription = ''
|
||||
${meta.longDescription}
|
||||
"This package includes the server CLI."
|
||||
'';
|
||||
};
|
||||
}
|
||||
else { };
|
||||
|
||||
velorenPackage =
|
||||
pkgs.naersk.buildPackage {
|
||||
name = crateToBuild;
|
||||
root = ../.;
|
||||
targets = [ crateToBuild ];
|
||||
nativeBuildInputs = common.crateDeps.nativeBuildInputs;
|
||||
buildInputs = common.crateDeps.buildInputs;
|
||||
override = (_: {
|
||||
# Disable `git-lfs` check here since we check it ourselves
|
||||
# We have to include the command output here, otherwise Nix won't run it
|
||||
DISABLE_GIT_LFS_CHECK = utils.isGitLfsSetup common.gitLfsCheckFile;
|
||||
# Declare env values here so that `common/build.rs` sees them
|
||||
NIX_GIT_HASH = prettyRev;
|
||||
NIX_GIT_TAG = tag;
|
||||
VELOREN_USERDATA_STRATEGY = "system";
|
||||
});
|
||||
overrideMain = velorenOverride;
|
||||
inherit release;
|
||||
};
|
||||
in
|
||||
velorenPackage
|
@ -1,16 +1,18 @@
|
||||
{ nixpkgs, sources, system }:
|
||||
{ sources, system }:
|
||||
let
|
||||
rustChannel = import ./rustPkgs.nix {
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
inherit (sources) nixpkgsMoz;
|
||||
pkgz = import sources.nixpkgs { inherit system; overlays = [ sources.rustOverlay.overlay ]; };
|
||||
rust = (pkgz.rust-bin.fromRustupToolchainFile ../rust-toolchain).override {
|
||||
extensions = [ "rust-src" ];
|
||||
};
|
||||
|
||||
pkgs = import nixpkgs {
|
||||
pkgs = import sources.nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
(final: prev: {
|
||||
rustc = rustChannel.rust;
|
||||
crate2nix = prev.callPackage sources.crate2nix { pkgs = prev; };
|
||||
rustc = rust;
|
||||
})
|
||||
(final: prev: {
|
||||
naersk = prev.callPackage sources.naersk { };
|
||||
})
|
||||
];
|
||||
};
|
||||
@ -20,15 +22,9 @@ with pkgs;
|
||||
inherit pkgs;
|
||||
# deps that crates need (for compiling)
|
||||
crateDeps =
|
||||
let
|
||||
makeDeps = b: n: { buildInputs = b; nativeBuildInputs = n; };
|
||||
in
|
||||
{
|
||||
libudev-sys = makeDeps [ libudev ] [ pkg-config ];
|
||||
alsa-sys = makeDeps [ alsaLib ] [ pkg-config ];
|
||||
veloren-network = makeDeps [ openssl ] [ pkg-config ];
|
||||
veloren-voxygen = makeDeps [ xorg.libxcb ] [ ];
|
||||
xcb = makeDeps [ ] [ python3 ];
|
||||
nativeBuildInputs = [ pkg-config python3 ];
|
||||
buildInputs = [ libudev alsaLib openssl xorg.libxcb ];
|
||||
};
|
||||
# deps that voxygen needs to function
|
||||
# FIXME: Wayland doesn't work (adding libxkbcommon, wayland and wayland-protocols results in a panic)
|
||||
|
@ -1,21 +0,0 @@
|
||||
{
|
||||
"auth-common 0.1.0 (git+https://gitlab.com/veloren/auth.git?rev=b943c85e4a38f5ec60cd18c34c73097640162bfe#b943c85e4a38f5ec60cd18c34c73097640162bfe)": "0ckpx36a5gmzirsih03ddfyp4iz23ffwb6sc75smb4srx1ivc7fy",
|
||||
"authc 1.0.0 (git+https://gitlab.com/veloren/auth.git?rev=b943c85e4a38f5ec60cd18c34c73097640162bfe#b943c85e4a38f5ec60cd18c34c73097640162bfe)": "0ckpx36a5gmzirsih03ddfyp4iz23ffwb6sc75smb4srx1ivc7fy",
|
||||
"conrod_core 0.63.0 (git+https://gitlab.com/veloren/conrod.git?branch=copypasta_0.7#1ae5193588fb662a7189d81edd9f2d653c7f1da0)": "14sxyw8si0c2md5p5hssvfl12368hqp1fy6ighd7v4lb8fqwp6zj",
|
||||
"conrod_derive 0.63.0 (git+https://gitlab.com/veloren/conrod.git?branch=copypasta_0.7#1ae5193588fb662a7189d81edd9f2d653c7f1da0)": "14sxyw8si0c2md5p5hssvfl12368hqp1fy6ighd7v4lb8fqwp6zj",
|
||||
"conrod_winit 0.63.0 (git+https://gitlab.com/veloren/conrod.git?branch=copypasta_0.7#1ae5193588fb662a7189d81edd9f2d653c7f1da0)": "14sxyw8si0c2md5p5hssvfl12368hqp1fy6ighd7v4lb8fqwp6zj",
|
||||
"euc 0.5.1 (git+https://github.com/zesterer/euc.git#c9a7c17a03d45fce00caeeca09afa1e1558cd183)": "0qvk0bx1arkgmdc59sip39zszdw2fwv6jcy5jinv18n5m1nrclw4",
|
||||
"iced_core 0.2.1 (git+https://github.com/hecrj/iced?rev=f464316#f46431600cb61d4e83e0ded1ca79525478436be3)": "08ixcznfi6wmznjyg0ahi9zs12x5mlbw1bznifqr66gkpa25kyp1",
|
||||
"iced_futures 0.1.2 (git+https://github.com/hecrj/iced?rev=f464316#f46431600cb61d4e83e0ded1ca79525478436be3)": "08ixcznfi6wmznjyg0ahi9zs12x5mlbw1bznifqr66gkpa25kyp1",
|
||||
"iced_graphics 0.1.0 (git+https://github.com/hecrj/iced?rev=f464316#f46431600cb61d4e83e0ded1ca79525478436be3)": "08ixcznfi6wmznjyg0ahi9zs12x5mlbw1bznifqr66gkpa25kyp1",
|
||||
"iced_native 0.2.2 (git+https://github.com/hecrj/iced?rev=f464316#f46431600cb61d4e83e0ded1ca79525478436be3)": "08ixcznfi6wmznjyg0ahi9zs12x5mlbw1bznifqr66gkpa25kyp1",
|
||||
"iced_style 0.1.0 (git+https://github.com/hecrj/iced?rev=f464316#f46431600cb61d4e83e0ded1ca79525478436be3)": "08ixcznfi6wmznjyg0ahi9zs12x5mlbw1bznifqr66gkpa25kyp1",
|
||||
"iced_winit 0.1.1 (git+https://github.com/hecrj/iced?rev=f464316#f46431600cb61d4e83e0ded1ca79525478436be3)": "08ixcznfi6wmznjyg0ahi9zs12x5mlbw1bznifqr66gkpa25kyp1",
|
||||
"portpicker 0.1.0 (git+https://github.com/xMAC94x/portpicker-rs#9d6df36c53c94684080a64a7212dd6bfc3617ee4)": "00vl2k3xfihxq86kf5rsknjl8dxmrxqhwajwn0hj4gzgnbssr0rx",
|
||||
"scan_fmt 0.2.5 (git+https://github.com/Imberflur/scan_fmt#5f9e8eed73e93e8d19fa864d76e75bb4984cffe7)": "1g36jm3rii6iziqpddszhdk6bqpa7jzsbmrlfzmsmi16zcisrvid",
|
||||
"specs 0.16.1 (git+https://github.com/amethyst/specs.git?rev=7a2e348ab2223818bad487695c66c43db88050a5#7a2e348ab2223818bad487695c66c43db88050a5)": "1z7gjiq7zirg9az3ly1y2ghi5m7s3x1bp35gw5x0cyv50fsi3pjq",
|
||||
"specs-idvs 0.1.0 (git+https://gitlab.com/veloren/specs-idvs.git?branch=specs-git#fcb0b2306b571f62f9f85d89e79e087454d95efd)": "00w4kc60d7mjb5gbkcxrxzarshmhf4idqm3sk8335f7s3pn9q0s5",
|
||||
"tui 0.10.0 (git+https://github.com/fdehau/tui-rs.git?branch=paragraph-scroll#54b841fab6cfdb38e8dc1382176e965787964b4c)": "0si3sp0hkjjrrfvmiynhai35pgjlnflw7qwwh268rpivdl8bd9xz",
|
||||
"vek 0.12.0 (git+https://gitlab.com/veloren/vek.git?branch=fix_intrinsics#237a78528b505f34f6dde5dc77db3b642388fe4a)": "1v3kxjl826zf0zbi9pbwpw75ybidr0cdsgx772l0671zmp3yrkjg",
|
||||
"winit 0.23.0 (git+https://gitlab.com/veloren/winit.git?branch=macos-test-spiffed#7c8c5f21384c898f50d37298d229093549b08803)": "1amfl8xpmyh7a4sy87iz5rybdgfn598crl6y6hxyrmyamg6cbqd4"
|
||||
}
|
@ -1,32 +1,15 @@
|
||||
{ nixpkgs, sources, system }:
|
||||
with import ./common.nix
|
||||
{
|
||||
inherit
|
||||
nixpkgs
|
||||
sources
|
||||
system
|
||||
;
|
||||
};
|
||||
with pkgs;
|
||||
let
|
||||
getAllCratesDeps = name:
|
||||
(lib.concatLists
|
||||
(map (attrset: attrset."${name}") (lib.attrValues crateDeps)));
|
||||
in
|
||||
{ common }:
|
||||
with common; with pkgs;
|
||||
mkShell {
|
||||
name = "veloren-shell";
|
||||
nativeBuildInputs = [
|
||||
cachix
|
||||
cargo
|
||||
clippy
|
||||
crate2nix
|
||||
git
|
||||
git-lfs
|
||||
nixpkgs-fmt
|
||||
rustc
|
||||
rustfmt
|
||||
] ++ (getAllCratesDeps "nativeBuildInputs");
|
||||
buildInputs = getAllCratesDeps "buildInputs";
|
||||
] ++ crateDeps.nativeBuildInputs;
|
||||
buildInputs = crateDeps.buildInputs;
|
||||
shellHook = ''
|
||||
# Setup our cachix "substituter"
|
||||
export NIX_CONFIG="
|
||||
|
@ -2,8 +2,7 @@ watch_file flake.lock
|
||||
watch_file flake.nix
|
||||
watch_file nix/common.nix
|
||||
watch_file nix/devShell.nix
|
||||
watch_file nix/rustPkgs.nix
|
||||
watch_file nix/shell.nix
|
||||
watch_file nix/utils.nix
|
||||
|
||||
use flake
|
||||
use flake || use nix nix/shell.nix
|
||||
|
141
nix/veloren.nix
141
nix/veloren.nix
@ -1,141 +0,0 @@
|
||||
{
|
||||
# `crate2nix` doesn't support profiles in `Cargo.toml`, so default to release.
|
||||
# Otherwise bad performance (non-release is built with opt level 0)
|
||||
release ? true
|
||||
, cratesToBuild ? [ "veloren-voxygen" "veloren-server-cli" ]
|
||||
, disableGitLfsCheck ? false
|
||||
, nixpkgs
|
||||
, sources
|
||||
, system
|
||||
, sourceInfo ? { }
|
||||
}:
|
||||
let
|
||||
common = import ./common.nix {
|
||||
inherit
|
||||
nixpkgs
|
||||
sources
|
||||
system
|
||||
;
|
||||
};
|
||||
inherit (common) pkgs;
|
||||
utils = import ./utils.nix { inherit pkgs; };
|
||||
|
||||
meta = with pkgs.stdenv.lib; {
|
||||
description = "Veloren is a multiplayer voxel RPG written in Rust.";
|
||||
longDescription = ''
|
||||
Veloren is a multiplayer voxel RPG written in Rust.
|
||||
It is inspired by games such as Cube World, Legend of Zelda: Breath of the Wild, Dwarf Fortress and Minecraft.
|
||||
'';
|
||||
homepage = "https://veloren.net";
|
||||
upstream = "https://gitlab.com/veloren/veloren";
|
||||
license = licenses.gpl3;
|
||||
maintainers = [ maintainers.yusdacra ];
|
||||
# TODO: Make this work on BSD and Mac OS
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
|
||||
prettyRev = with sourceInfo;
|
||||
if sourceInfo ? rev && sourceInfo ? lastModified
|
||||
then builtins.substring 0 8 rev + "/" + utils.dateTimeFormat lastModified
|
||||
else throw "Need revision + lastModified to determine pretty revision";
|
||||
|
||||
tag = with sourceInfo;
|
||||
if sourceInfo ? tag
|
||||
then sourceInfo.tag
|
||||
else "";
|
||||
|
||||
# If gitTag has a tag (meaning the commit we are on is a *release*), use
|
||||
# it as version, else: just use the prettified hash we have, if we don't
|
||||
# have it the build fails.
|
||||
# Must be in format f4987672/2020-12-10-12:00
|
||||
version =
|
||||
if tag != "" then tag
|
||||
else if prettyRev != "" then prettyRev
|
||||
else throw "Need a tag or pretty revision in order to determine version";
|
||||
|
||||
veloren-assets = pkgs.runCommand "makeAssetsDir" { } ''
|
||||
mkdir $out
|
||||
ln -sf ${../assets} $out/assets
|
||||
'';
|
||||
|
||||
velorenVoxygenDesktopFile = pkgs.makeDesktopItem rec {
|
||||
name = "veloren-voxygen";
|
||||
exec = name;
|
||||
icon = ../assets/voxygen/logo.ico;
|
||||
comment =
|
||||
"Official client for Veloren - the open-world, open-source multiplayer voxel RPG";
|
||||
desktopName = "Voxygen";
|
||||
genericName = "Veloren Client";
|
||||
categories = "Game;";
|
||||
};
|
||||
|
||||
veloren-crates = with pkgs;
|
||||
callPackage ./Cargo.nix {
|
||||
defaultCrateOverrides = with common; with crateDeps;
|
||||
defaultCrateOverrides // {
|
||||
veloren-common = oldAttrs: {
|
||||
# see: https://github.com/kolloch/crate2nix/issues/129
|
||||
dependencies =
|
||||
map
|
||||
(dep:
|
||||
if dep.name == "csv" || dep.name == "structopt"
|
||||
then builtins.removeAttrs dep [ "optional" ]
|
||||
else dep)
|
||||
oldAttrs.dependencies;
|
||||
|
||||
# Disable `git-lfs` check here since we check it ourselves
|
||||
# We have to include the command output here, otherwise Nix won't run it
|
||||
DISABLE_GIT_LFS_CHECK = utils.isGitLfsSetup common.gitLfsCheckFile;
|
||||
# Declare env values here so that `common/build.rs` sees them
|
||||
NIX_GIT_HASH = prettyRev;
|
||||
NIX_GIT_TAG = tag;
|
||||
};
|
||||
veloren-server-cli = _: {
|
||||
name = "veloren-server-cli";
|
||||
inherit version;
|
||||
VELOREN_USERDATA_STRATEGY = "system";
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
postInstall = ''
|
||||
wrapProgram $out/bin/veloren-server-cli --set VELOREN_ASSETS ${veloren-assets}
|
||||
'';
|
||||
meta = meta // {
|
||||
longDescription = ''
|
||||
${meta.longDescription}
|
||||
"This package includes the server CLI."
|
||||
'';
|
||||
};
|
||||
};
|
||||
veloren-voxygen = _: {
|
||||
name = "veloren-voxygen";
|
||||
inherit version;
|
||||
VELOREN_USERDATA_STRATEGY = "system";
|
||||
inherit (veloren-voxygen) buildInputs;
|
||||
nativeBuildInputs = veloren-voxygen.nativeBuildInputs
|
||||
++ [ makeWrapper copyDesktopItems ];
|
||||
desktopItems = [ velorenVoxygenDesktopFile ];
|
||||
postInstall = ''
|
||||
wrapProgram $out/bin/veloren-voxygen\
|
||||
--set VELOREN_ASSETS ${veloren-assets}\
|
||||
--set LD_LIBRARY_PATH ${
|
||||
lib.makeLibraryPath common.voxygenNeededLibs
|
||||
}
|
||||
'';
|
||||
meta = meta // {
|
||||
longDescription = ''
|
||||
${meta.longDescription}
|
||||
"This package includes the official client, Voxygen."
|
||||
'';
|
||||
};
|
||||
};
|
||||
} // {
|
||||
xcb = _: xcb;
|
||||
libudev-sys = _: libudev-sys;
|
||||
alsa-sys = _: alsa-sys;
|
||||
veloren-network = _: veloren-network;
|
||||
};
|
||||
inherit release pkgs;
|
||||
};
|
||||
|
||||
makePkg = name: veloren-crates.workspaceMembers."${name}".build;
|
||||
in
|
||||
(pkgs.lib.genAttrs cratesToBuild makePkg)
|
Loading…
Reference in New Issue
Block a user