mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
default.nix, shell.nix: init
This commit inits the `default.nix` and `shell.nix`. They support `nix build` and `nix-shell`, respectively. * `nix-shell` sets up the build environment for Veloren so that you can manually build it using `cargo build`. This is for developping as it speeds up subsequent compilations because intermediate compilation artifacts are reused. * `nix build` builds Veloren, stores the result in the Nix store and creates a `result` symlink to it. Make sure that the LFS files are checked out before using `nix build`.
This commit is contained in:
committed by
Forest Anderson
parent
2f1c62d2ed
commit
b12b7bb615
76
default.nix
Normal file
76
default.nix
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
let
|
||||||
|
fallbackPkgs = import <nixpkgs> {};
|
||||||
|
in
|
||||||
|
|
||||||
|
{
|
||||||
|
alsaLib ? fallbackPkgs.alsaLib,
|
||||||
|
atk ? fallbackPkgs.atk,
|
||||||
|
cairo ? fallbackPkgs.cairo,
|
||||||
|
fetchFromGitHub ? fallbackPkgs.fetchFromGitHub,
|
||||||
|
git ? fallbackPkgs.git,
|
||||||
|
git-lfs ? fallbackPkgs.git-lfs,
|
||||||
|
glib ? fallbackPkgs.glib,
|
||||||
|
gnuplot ? fallbackPkgs.gnuplot,
|
||||||
|
gtk3 ? fallbackPkgs.gtk3,
|
||||||
|
makeRustPlatform ? fallbackPkgs.makeRustPlatform,
|
||||||
|
nix-gitignore ? fallbackPkgs.nix-gitignore,
|
||||||
|
pango ? fallbackPkgs.pango,
|
||||||
|
pkg-config ? fallbackPkgs.pkg-config,
|
||||||
|
pkgs ? fallbackPkgs,
|
||||||
|
rustup ? fallbackPkgs.rustup,
|
||||||
|
stdenv ? fallbackPkgs.stdenv,
|
||||||
|
veloren-src ? null,
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
mozRepo = fetchFromGitHub {
|
||||||
|
owner = "mozilla";
|
||||||
|
repo = "nixpkgs-mozilla";
|
||||||
|
rev = "ac8e9d7bbda8fb5e45cae20c5b7e44c52da3ac0c";
|
||||||
|
sha256 = "1irlkqc0jdkxdfznq7r52ycnf0kcvvrz416qc7346xhmilrx2gy6";
|
||||||
|
};
|
||||||
|
# `mozPkgs` is the package set of `mozRepo`; this differs from their README
|
||||||
|
# where they use it as an overlay rather than a separate package set
|
||||||
|
mozPkgs = import "${mozRepo}/package-set.nix" { inherit pkgs; };
|
||||||
|
channel = mozPkgs.rustChannelOf { date = "2019-07-03"; channel = "nightly"; };
|
||||||
|
nightlyRustPlatform = makeRustPlatform {
|
||||||
|
rustc = channel.rust;
|
||||||
|
cargo = channel.cargo;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
|
||||||
|
nightlyRustPlatform.buildRustPackage rec {
|
||||||
|
name = "veloren";
|
||||||
|
version = "unstable";
|
||||||
|
# For information on how to automatically fetch the source from GitLab, please
|
||||||
|
# ask @haslersn
|
||||||
|
src = if veloren-src == null then (nix-gitignore.gitignoreSource [] ./.) else veloren-src;
|
||||||
|
nativeBuildInputs = [
|
||||||
|
pkg-config
|
||||||
|
# convenience for nix-shell:
|
||||||
|
git
|
||||||
|
git-lfs
|
||||||
|
gnuplot
|
||||||
|
rustup # Needed for RLS integration in some IDEs such as vscode
|
||||||
|
];
|
||||||
|
buildInputs = [
|
||||||
|
alsaLib
|
||||||
|
atk
|
||||||
|
cairo
|
||||||
|
glib
|
||||||
|
gtk3
|
||||||
|
pango
|
||||||
|
];
|
||||||
|
preConfigure = ''
|
||||||
|
export HOME=`mktemp -d`
|
||||||
|
'';
|
||||||
|
postInstall = ''
|
||||||
|
cp -R $src/assets $out/bin/assets
|
||||||
|
'';
|
||||||
|
CARGO_INCREMENTAL = 1;
|
||||||
|
cargoSha256 = "1zhsn69171wazigxxqggwqb5j8qllr5245y2w92dpnrgmdbjqyga";
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
platforms = stdenv.lib.platforms.linux;
|
||||||
|
};
|
||||||
|
}
|
28
shell.nix
Normal file
28
shell.nix
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
with import <nixpkgs> {};
|
||||||
|
|
||||||
|
import ./default.nix {
|
||||||
|
# The source is copied to the nix store. We don't want to do this (including assets) for every
|
||||||
|
# time the `nix-shell` is entered. Therefore we create a source which contains only the files
|
||||||
|
# necessary to evaluate `buildRustPackage` successfully:
|
||||||
|
veloren-src = runCommand "veloren-shell" {} (lib.concatMapStrings
|
||||||
|
(p: "mkdir -p $(dirname $out/${p}); cp ${./. + "/${p}"} $out/${p}\n")
|
||||||
|
[
|
||||||
|
"Cargo.lock"
|
||||||
|
"Cargo.toml"
|
||||||
|
"chat-cli/Cargo.toml"
|
||||||
|
"chat-cli/src/main.rs"
|
||||||
|
"client/Cargo.toml"
|
||||||
|
"client/src/lib.rs"
|
||||||
|
"common/Cargo.toml"
|
||||||
|
"common/src/lib.rs"
|
||||||
|
"server-cli/Cargo.toml"
|
||||||
|
"server-cli/src/main.rs"
|
||||||
|
"server/Cargo.toml"
|
||||||
|
"server/src/lib.rs"
|
||||||
|
"voxygen/Cargo.toml"
|
||||||
|
"voxygen/src/main.rs"
|
||||||
|
"world/Cargo.toml"
|
||||||
|
"world/src/lib.rs"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
Reference in New Issue
Block a user