mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'yusdacra/fix-nix-veloren-version-string' into 'master'
More Nix fixes, better Nix README among other UX See merge request veloren/veloren!1614
This commit is contained in:
commit
74c095b778
18
flake.lock
18
flake.lock
@ -32,23 +32,6 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixGL": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1604138361,
|
||||
"narHash": "sha256-I9/myywtqh9xrxC94molYpwN4c92dw1jUmfS2+pHwws=",
|
||||
"owner": "guibou",
|
||||
"repo": "nixGL",
|
||||
"rev": "7d6bc1b21316bab6cf4a6520c2639a11c25a220e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "guibou",
|
||||
"repo": "nixGL",
|
||||
"rev": "7d6bc1b21316bab6cf4a6520c2639a11c25a220e",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1606744648,
|
||||
@ -85,7 +68,6 @@
|
||||
"inputs": {
|
||||
"crate2nix": "crate2nix",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixGL": "nixGL",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"nixpkgsMoz": "nixpkgsMoz"
|
||||
}
|
||||
|
@ -11,22 +11,15 @@
|
||||
url = "github:mozilla/nixpkgs-mozilla";
|
||||
flake = false;
|
||||
};
|
||||
nixGL = {
|
||||
url = "github:guibou/nixGL?rev=7d6bc1b21316bab6cf4a6520c2639a11c25a220e";
|
||||
flake = false;
|
||||
};
|
||||
nixpkgs.url = "github:NixOS/nixpkgs?rev=c00959877fb06b09468562518b408acda886c79e";
|
||||
};
|
||||
|
||||
outputs = inputs: with inputs;
|
||||
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
|
||||
let
|
||||
pkgs = inputs.nixpkgs.legacyPackages."${system}";
|
||||
|
||||
sources = {
|
||||
inherit
|
||||
crate2nix
|
||||
nixGL
|
||||
nixpkgs
|
||||
nixpkgsMoz
|
||||
;
|
||||
|
204
nix/Cargo.nix
204
nix/Cargo.nix
@ -33,26 +33,6 @@ rec {
|
||||
# You can override the features with
|
||||
# workspaceMembers."${crateName}".build.override { features = [ "default" "feature1" ... ]; }.
|
||||
workspaceMembers = {
|
||||
"tools" = rec {
|
||||
packageId = "tools";
|
||||
build = internal.buildRustCrateWithFeatures {
|
||||
packageId = "tools";
|
||||
};
|
||||
|
||||
# Debug support which might change between releases.
|
||||
# File a bug if you depend on any for non-debug work!
|
||||
debug = internal.debugCrate { inherit packageId; };
|
||||
};
|
||||
"veloren-chat-cli" = rec {
|
||||
packageId = "veloren-chat-cli";
|
||||
build = internal.buildRustCrateWithFeatures {
|
||||
packageId = "veloren-chat-cli";
|
||||
};
|
||||
|
||||
# Debug support which might change between releases.
|
||||
# File a bug if you depend on any for non-debug work!
|
||||
debug = internal.debugCrate { inherit packageId; };
|
||||
};
|
||||
"veloren-client" = rec {
|
||||
packageId = "veloren-client";
|
||||
build = internal.buildRustCrateWithFeatures {
|
||||
@ -4141,62 +4121,6 @@ rec {
|
||||
};
|
||||
resolvedDefaultFeatures = [ "default" "std" ];
|
||||
};
|
||||
"failure" = rec {
|
||||
crateName = "failure";
|
||||
version = "0.1.8";
|
||||
edition = "2015";
|
||||
sha256 = "11jg1wmbkijrs6bk9fqnbrm9zf0850whnqpgnxyswbn0dk8rnbnk";
|
||||
authors = [
|
||||
"Without Boats <boats@mozilla.com>"
|
||||
];
|
||||
dependencies = [
|
||||
{
|
||||
name = "backtrace";
|
||||
packageId = "backtrace";
|
||||
optional = true;
|
||||
}
|
||||
{
|
||||
name = "failure_derive";
|
||||
packageId = "failure_derive";
|
||||
optional = true;
|
||||
}
|
||||
];
|
||||
features = {
|
||||
"default" = [ "std" "derive" ];
|
||||
"derive" = [ "failure_derive" ];
|
||||
"std" = [ "backtrace" ];
|
||||
};
|
||||
resolvedDefaultFeatures = [ "backtrace" "default" "derive" "failure_derive" "std" ];
|
||||
};
|
||||
"failure_derive" = rec {
|
||||
crateName = "failure_derive";
|
||||
version = "0.1.8";
|
||||
edition = "2015";
|
||||
sha256 = "1936adqqk080439kx2bjf1bds7h89sg6wcif4jw0syndcv3s6kda";
|
||||
procMacro = true;
|
||||
authors = [
|
||||
"Without Boats <woboats@gmail.com>"
|
||||
];
|
||||
dependencies = [
|
||||
{
|
||||
name = "proc-macro2";
|
||||
packageId = "proc-macro2 1.0.23";
|
||||
}
|
||||
{
|
||||
name = "quote";
|
||||
packageId = "quote 1.0.7";
|
||||
}
|
||||
{
|
||||
name = "syn";
|
||||
packageId = "syn 1.0.42";
|
||||
}
|
||||
{
|
||||
name = "synstructure";
|
||||
packageId = "synstructure";
|
||||
}
|
||||
];
|
||||
features = { };
|
||||
};
|
||||
"fehler" = rec {
|
||||
crateName = "fehler";
|
||||
version = "1.0.0";
|
||||
@ -12502,42 +12426,6 @@ rec {
|
||||
};
|
||||
resolvedDefaultFeatures = [ "clone-impls" "default" "derive" "extra-traits" "fold" "full" "parsing" "printing" "proc-macro" "quote" "visit" "visit-mut" ];
|
||||
};
|
||||
"synstructure" = rec {
|
||||
crateName = "synstructure";
|
||||
version = "0.12.4";
|
||||
edition = "2018";
|
||||
sha256 = "00c72ij813xsilssgya6m6f73d0s5zzsld1y26bvhk3kdzbg4d5q";
|
||||
authors = [
|
||||
"Nika Layzell <nika@thelayzells.com>"
|
||||
];
|
||||
dependencies = [
|
||||
{
|
||||
name = "proc-macro2";
|
||||
packageId = "proc-macro2 1.0.23";
|
||||
usesDefaultFeatures = false;
|
||||
}
|
||||
{
|
||||
name = "quote";
|
||||
packageId = "quote 1.0.7";
|
||||
usesDefaultFeatures = false;
|
||||
}
|
||||
{
|
||||
name = "syn";
|
||||
packageId = "syn 1.0.42";
|
||||
usesDefaultFeatures = false;
|
||||
features = [ "derive" "parsing" "printing" "clone-impls" "visit" "extra-traits" ];
|
||||
}
|
||||
{
|
||||
name = "unicode-xid";
|
||||
packageId = "unicode-xid 0.2.1";
|
||||
}
|
||||
];
|
||||
features = {
|
||||
"default" = [ "proc-macro" ];
|
||||
"proc-macro" = [ "proc-macro2/proc-macro" "syn/proc-macro" "quote/proc-macro" ];
|
||||
};
|
||||
resolvedDefaultFeatures = [ "default" "proc-macro" ];
|
||||
};
|
||||
"take_mut" = rec {
|
||||
crateName = "take_mut";
|
||||
version = "0.2.2";
|
||||
@ -13250,34 +13138,6 @@ rec {
|
||||
};
|
||||
resolvedDefaultFeatures = [ "default" ];
|
||||
};
|
||||
"tools" = rec {
|
||||
crateName = "tools";
|
||||
version = "0.1.0";
|
||||
edition = "2018";
|
||||
crateBin = [
|
||||
{ name = "tools"; path = "src/main.rs"; }
|
||||
];
|
||||
src = lib.cleanSourceWith { filter = sourceFilter; src = ../tools; };
|
||||
authors = [
|
||||
"Sam <samuelkeiffer@gmail.com>"
|
||||
];
|
||||
dependencies = [
|
||||
{
|
||||
name = "csv";
|
||||
packageId = "csv";
|
||||
}
|
||||
{
|
||||
name = "structopt";
|
||||
packageId = "structopt";
|
||||
}
|
||||
{
|
||||
name = "veloren-common";
|
||||
packageId = "veloren-common";
|
||||
rename = "common";
|
||||
}
|
||||
];
|
||||
|
||||
};
|
||||
"tracing" = rec {
|
||||
crateName = "tracing";
|
||||
version = "0.1.21";
|
||||
@ -14294,42 +14154,6 @@ rec {
|
||||
};
|
||||
resolvedDefaultFeatures = [ "default" "platform_intrinsics" "repr_simd" "rgb" "rgba" "serde" "std" ];
|
||||
};
|
||||
"veloren-chat-cli" = rec {
|
||||
crateName = "veloren-chat-cli";
|
||||
version = "0.8.0";
|
||||
edition = "2018";
|
||||
crateBin = [
|
||||
{ name = "veloren-chat-cli"; path = "src/main.rs"; }
|
||||
];
|
||||
src = lib.cleanSourceWith { filter = sourceFilter; src = ../chat-cli; };
|
||||
authors = [
|
||||
"Joshua Barretto <joshua.s.barretto@gmail.com>"
|
||||
];
|
||||
dependencies = [
|
||||
{
|
||||
name = "tracing";
|
||||
packageId = "tracing";
|
||||
usesDefaultFeatures = false;
|
||||
}
|
||||
{
|
||||
name = "tracing-subscriber";
|
||||
packageId = "tracing-subscriber";
|
||||
usesDefaultFeatures = false;
|
||||
features = [ "fmt" "chrono" "ansi" "smallvec" ];
|
||||
}
|
||||
{
|
||||
name = "veloren-client";
|
||||
packageId = "veloren-client";
|
||||
rename = "client";
|
||||
}
|
||||
{
|
||||
name = "veloren-common";
|
||||
packageId = "veloren-common";
|
||||
rename = "common";
|
||||
}
|
||||
];
|
||||
|
||||
};
|
||||
"veloren-client" = rec {
|
||||
crateName = "veloren-client";
|
||||
version = "0.8.0";
|
||||
@ -14420,6 +14244,14 @@ rec {
|
||||
features = [ "compression" ];
|
||||
}
|
||||
];
|
||||
devDependencies = [
|
||||
{
|
||||
name = "tracing-subscriber";
|
||||
packageId = "tracing-subscriber";
|
||||
usesDefaultFeatures = false;
|
||||
features = [ "fmt" "chrono" "ansi" "smallvec" ];
|
||||
}
|
||||
];
|
||||
features = {
|
||||
"default" = [ "simd" ];
|
||||
"simd" = [ "vek/platform_intrinsics" ];
|
||||
@ -14430,6 +14262,9 @@ rec {
|
||||
crateName = "veloren-common";
|
||||
version = "0.8.0";
|
||||
edition = "2018";
|
||||
crateBin = [
|
||||
{ name = "csv_export"; path = "src/bin/csv_export/main.rs"; }
|
||||
];
|
||||
src = lib.cleanSourceWith { filter = sourceFilter; src = ../common; };
|
||||
authors = [
|
||||
"Joshua Barretto <joshua.s.barretto@gmail.com>"
|
||||
@ -14449,6 +14284,11 @@ rec {
|
||||
name = "crossbeam";
|
||||
packageId = "crossbeam";
|
||||
}
|
||||
{
|
||||
name = "csv";
|
||||
packageId = "csv";
|
||||
# optional = true;
|
||||
}
|
||||
{
|
||||
name = "directories-next";
|
||||
packageId = "directories-next";
|
||||
@ -14553,6 +14393,11 @@ rec {
|
||||
name = "spin_sleep";
|
||||
packageId = "spin_sleep";
|
||||
}
|
||||
{
|
||||
name = "structopt";
|
||||
packageId = "structopt";
|
||||
# optional = true;
|
||||
}
|
||||
{
|
||||
name = "sum_type";
|
||||
packageId = "sum_type";
|
||||
@ -14580,11 +14425,12 @@ rec {
|
||||
}
|
||||
];
|
||||
features = {
|
||||
"bin_csv_export" = [ "csv" "structopt" ];
|
||||
"default" = [ "simd" ];
|
||||
"simd" = [ "vek/platform_intrinsics" ];
|
||||
"tracy" = [ "tracy-client" ];
|
||||
};
|
||||
resolvedDefaultFeatures = [ "default" "no-assets" "simd" "tracy" "tracy-client" ];
|
||||
resolvedDefaultFeatures = [ "bin_csv_export" "csv" "default" "no-assets" "simd" "structopt" "tracy" "tracy-client" ];
|
||||
};
|
||||
"veloren-server" = rec {
|
||||
crateName = "veloren-server";
|
||||
@ -14907,10 +14753,6 @@ rec {
|
||||
name = "euc";
|
||||
packageId = "euc";
|
||||
}
|
||||
{
|
||||
name = "failure";
|
||||
packageId = "failure";
|
||||
}
|
||||
{
|
||||
name = "gfx";
|
||||
packageId = "gfx";
|
||||
|
6
nix/Cargo.nix_patches.md
Normal file
6
nix/Cargo.nix_patches.md
Normal file
@ -0,0 +1,6 @@
|
||||
Apply these instructions after generating the `Cargo.nix` file.
|
||||
|
||||
- Find `veloren-common` crate in `Cargo.nix`:
|
||||
- Comment the `optional = true;` line for "structopt" and "csv" dependencies.
|
||||
- See [this issue](https://github.com/kolloch/crate2nix/issues/129) on `crate2nix` repository for more info.
|
||||
- Note that the suggested workaround in the issue **does not** work for us.
|
187
nix/README.md
187
nix/README.md
@ -1,71 +1,52 @@
|
||||
## Important
|
||||
## Read this first!
|
||||
|
||||
If you are going to call the derivations with a custom `nixpkgs` argument, make sure that the `nixpkgs` you pass is on at least the same commit or newer than it.
|
||||
Unexpected errors may pop up if you use an older version. Same goes for the `sources` argument.
|
||||
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.
|
||||
|
||||
### How to use
|
||||
See the [NixOS wiki](https://nixos.wiki/wiki/Flakes) for information on how to enable and use flakes.
|
||||
|
||||
To enter the development shell (which includes all tools mentioned in this readme + tools you'll need to develop Veloren), run:
|
||||
It is recommended to first setup the [Cachix](https://cachix.org) cache to save time with builds:
|
||||
```shell
|
||||
nix-shell nix/shell.nix
|
||||
```
|
||||
It is recommended that you enter the dev shell before starting to build using `nix-build` or `nix-env` (anything which build stuff),
|
||||
since it will setup a Cachix cache for you. (you can configure this for your user's `nix.conf` by running `cachix use veloren-nix` once in the dev shell,
|
||||
which will make the cache available when you run commands outside of the dev shell).
|
||||
|
||||
If you have [direnv](https://direnv.net) setup on your system, it is also recommended to copy the `envrc`
|
||||
(or `envrc-nvidia`, if you have an Nvidia GPU) file to the root of the repository as `.envrc`:
|
||||
```shell
|
||||
cp nix/envrc .envrc
|
||||
```
|
||||
This will make your env have the dev env setup automatically.
|
||||
|
||||
To build and install Voxygen and the server CLI into user profile, run:
|
||||
```shell
|
||||
nix-env -f nix/default.nix -i
|
||||
```
|
||||
You can configure what to install by changing the `cratesToBuild` argument:
|
||||
```shell
|
||||
nix-env -f nix/default.nix --arg cratesToBuild '["veloren-voxygen"]'
|
||||
```
|
||||
For example, this will install Voxygen only.
|
||||
|
||||
You can configure the crates to be built with debug mode (not recommended, equals to `opt-level = 0`):
|
||||
```shell
|
||||
nix-env -f nix/default.nix --arg release false
|
||||
nix shell nixpkgs#cachix -c cachix use veloren-nix
|
||||
# or if you don't have flakes:
|
||||
nix-shell -p cachix --run "cachix use veloren-nix"
|
||||
```
|
||||
|
||||
If you aren't on NixOS, you can run `veloren-voxygen` using the provided `nixGLIntel` in the dev shell:
|
||||
As this repository uses `git-lfs`, please make sure `git-lfs` is in your path.
|
||||
If you have a locally cloned repo, you can make sure it is setup with:
|
||||
```shell
|
||||
nixGLIntel veloren-voxygen
|
||||
git lfs install --local && git lfs fetch && git lfs checkout
|
||||
```
|
||||
If you have an Nvidia GPU, you can enter the dev shell like so:
|
||||
```shell
|
||||
nix-shell nix/shell.nix --arg nvidia true
|
||||
```
|
||||
And you'll be able to use `nixGLNvidia` and `nixGLNvidiaBumblebee`.
|
||||
This should be automatically done if you use the development shell.
|
||||
|
||||
#### Using the flake
|
||||
## Usage for players
|
||||
|
||||
Due to the nature of flakes' reliance on git and the way `git-lfs` is configured for this repo, you must already have `git-lfs` in your environment when running nix commands on a local checkout. Run this to enter a shell environment with `git-lfs` in your path:
|
||||
```shell
|
||||
nix shell nixpkgs#git-lfs
|
||||
```
|
||||
### With flakes
|
||||
|
||||
To enter a shell environment with the necessary tools:
|
||||
```shell
|
||||
nix develop
|
||||
```
|
||||
|
||||
If you simply want to run the latest version without necessarily installing it, you can do so with
|
||||
If you just want to run the game without installing it, you can do so with:
|
||||
```shell
|
||||
# Voxygen (the default):
|
||||
nix run gitlab:veloren/veloren
|
||||
# Server CLI:
|
||||
nix run gitlab:veloren/veloren#veloren-server-cli
|
||||
# or if you have a local repo
|
||||
nix run .
|
||||
nix run .#veloren-server-cli
|
||||
```
|
||||
|
||||
To install (for example) the game client on your system, the configuration could look something like this:
|
||||
To install the game into your user profile:
|
||||
```shell
|
||||
# Voxygen:
|
||||
nix profile install gitlab:veloren/veloren
|
||||
# Server CLI:
|
||||
nix profile install giltab:veloren/veloren#veloren-server-cli
|
||||
# or if you have a local repo:
|
||||
nix profile install .
|
||||
nix profile install .#veloren-server-cli
|
||||
```
|
||||
|
||||
To install (for example) Voxygen on your system, the NixOS configuration (if you use a flake based setup) could look something like this:
|
||||
```nix
|
||||
{ description = "NixOS configuration with flakes";
|
||||
|
||||
@ -106,18 +87,86 @@ To install (for example) the game client on your system, the configuration could
|
||||
}
|
||||
```
|
||||
|
||||
### Managing Cargo.nix
|
||||
### Without flakes
|
||||
|
||||
Enter the development shell.
|
||||
|
||||
To update `Cargo.nix` (and `crate-hashes.json`) using latest `Cargo.lock`, run:
|
||||
You can do this to run the game without installing it (you will need a local clone of the repo though):
|
||||
```shell
|
||||
crate2nix generate -f ../Cargo.toml
|
||||
# build the game
|
||||
nix-build nix/default.nix
|
||||
# run it
|
||||
./result/bin/veloren-voxygen
|
||||
# or for server cli
|
||||
./result-2/bin/veloren-server-cli
|
||||
```
|
||||
|
||||
### Managing dependencies
|
||||
To install Voxygen and server CLI into user profile:
|
||||
```shell
|
||||
nix-env -f nix/default.nix -i
|
||||
```
|
||||
|
||||
#### Nix with flakes enabled
|
||||
### Notes for non-NixOS setups
|
||||
|
||||
You'll need to use [nixGL](https://github.com/guibou/nixGL) to be able to run the game (after installing it):
|
||||
```shell
|
||||
## For Intel and AMD:
|
||||
# Install it (sadly no flake yet)
|
||||
nix-env -f https://github.com/guibou/nixGL/archive/master.tar.gz -iA nixGLIntel
|
||||
nixGLIntel veloren-voxygen
|
||||
## For Nvidia:
|
||||
# Install it
|
||||
nix-env -f https://github.com/guibou/nixGL/archive/master.tar.gz -iA nixGLNvidia
|
||||
nixGLNvidia veloren-voxygen
|
||||
## For Nvidia driver on hybrid hardware:
|
||||
# Install it
|
||||
nix-env -f https://github.com/guibou/nixGL/archive/master.tar.gz -iA nixGLNvidiaBumblebee
|
||||
nixGLNvidiaBumblebee veloren-voxygen
|
||||
```
|
||||
|
||||
## Usage for developers
|
||||
|
||||
The development shell automatically setups the Cachix cache for you, so it is recommended to be in the dev shell always.
|
||||
If you have the Cachix cache setup in `~/.config/nix/nix.conf` (as described in the beginning of this document), then this isn't a necessity.
|
||||
|
||||
### With flakes
|
||||
|
||||
To enter a shell environment with the necessary tools:
|
||||
```shell
|
||||
nix develop
|
||||
```
|
||||
|
||||
You can use the `bundle` subcommand to bundle the game into a single distro-agnostic executable file:
|
||||
```shell
|
||||
## bundling latest commit to master
|
||||
# Voxygen:
|
||||
nix bundle gitlab:veloren/veloren
|
||||
# Server CLI:
|
||||
nix bundle gitlab:veloren/veloren#veloren-server-cli
|
||||
## for local repo:
|
||||
# Voxygen:
|
||||
nix bundle .#veloren-voxygen
|
||||
# Server CLI:
|
||||
nix bundle .#veloren-server-cli
|
||||
```
|
||||
|
||||
### Without flakes
|
||||
|
||||
To enter the development shell:
|
||||
```shell
|
||||
nix-shell nix/shell.nix
|
||||
```
|
||||
|
||||
### Direnv
|
||||
|
||||
This only works if you have flakes. There is an issue with the git-lfs hook in `shellHook` erroring out with `use nix`, so you'll have to enable flakes if you want to use the `envrc` file included.
|
||||
|
||||
If you have [direnv](https://direnv.net) and [nix-direnv](https://github.com/nix-community/nix-direnv) on your system, you can copy the `envrc` file to the root of the repository as `.envrc`:
|
||||
```shell
|
||||
cp nix/envrc .envrc
|
||||
```
|
||||
|
||||
## Managing dependencies
|
||||
|
||||
### With flakes
|
||||
|
||||
If a specific revision is specified in `flake.nix`, you will have to update that first, either by specifying a new desired revision or by removing it.
|
||||
|
||||
@ -129,19 +178,35 @@ nix flake update --update-input nixpkgs
|
||||
nix flake update --recreate-lock-file
|
||||
```
|
||||
|
||||
See the [NixOS wiki](https://nixos.wiki/wiki/Flakes) for more information on how to use flakes.
|
||||
|
||||
#### Legacy nix
|
||||
### Without flakes
|
||||
|
||||
It is inadvised to update revisions without the use of `nix flake update` as it's both tedious and error-prone to attempt setting all fields to their correct values in both `flake.nix` and `flake.lock`, but if you need to do it for testing, `flake.lock` is where legacy nix commands get the input revisions from (through `flake-compat`), regardless of what is specified in `flake.nix` (see https://github.com/edolstra/flake-compat/issues/10).
|
||||
|
||||
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.
|
||||
|
||||
### Formatting
|
||||
### 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
|
||||
```
|
||||
Then follow the instructions in the `Cargo.nix_patches.md` file.
|
||||
|
||||
### Rust toolchain
|
||||
|
||||
If the `rust-toolchain` file is updated, you will need to update the `sha256` hash in the `nix/rustPkgs.nix` file.
|
||||
|
||||
Trying to build the derivation should give you the correct hash to put in.
|
||||
|
||||
## Formatting
|
||||
|
||||
Use [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt) to format files.
|
||||
|
||||
To format every Nix file:
|
||||
```shell
|
||||
nixpkgs-fmt flake.nix nix/*.nix
|
||||
# or
|
||||
nixpkgs-fmt **/**.nix
|
||||
```
|
||||
|
@ -11,46 +11,28 @@ let
|
||||
(final: prev: {
|
||||
rustc = rustChannel.rust;
|
||||
crate2nix = prev.callPackage sources.crate2nix { pkgs = prev; };
|
||||
nixGL = prev.callPackage sources.nixGL { pkgs = prev; };
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
in
|
||||
with pkgs;
|
||||
let
|
||||
{
|
||||
inherit pkgs;
|
||||
# deps that crates need (for compiling)
|
||||
crateDeps = {
|
||||
libudev-sys = {
|
||||
buildInputs = [ libudev ];
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
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 ];
|
||||
};
|
||||
alsa-sys = {
|
||||
buildInputs = [ alsaLib ];
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
};
|
||||
veloren-network = {
|
||||
buildInputs = [ openssl ];
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
};
|
||||
veloren-voxygen = {
|
||||
buildInputs = [ xorg.libxcb ];
|
||||
nativeBuildInputs = [ ];
|
||||
};
|
||||
};
|
||||
|
||||
# deps that voxygen needs to function
|
||||
# FIXME: Wayland doesn't work (adding libxkbcommon, wayland and wayland-protocols results in a panic)
|
||||
voxygenNeededLibs = (with xorg; [ libX11 libXcursor libXrandr libXi ])
|
||||
++ [ libGL ];
|
||||
|
||||
gitLfsCheckFile = ../assets/voxygen/background/bg_main.png;
|
||||
in
|
||||
{
|
||||
inherit
|
||||
crateDeps
|
||||
gitLfsCheckFile
|
||||
pkgs
|
||||
voxygenNeededLibs
|
||||
;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ nixpkgs, sources, system, nvidia ? false }:
|
||||
{ nixpkgs, sources, system }:
|
||||
with import ./common.nix
|
||||
{
|
||||
inherit
|
||||
@ -9,22 +9,13 @@ with import ./common.nix
|
||||
};
|
||||
with pkgs;
|
||||
let
|
||||
nixGLPackages = ((with nixGL; [ nixGLIntel ]) ++ (lib.optional nvidia
|
||||
(with nixGL; [ nixGLNvidia nixGLNvidiaBumblebee ])));
|
||||
|
||||
getAllCratesDeps = name:
|
||||
(lib.concatLists
|
||||
(map (attrset: attrset."${name}") (lib.attrValues crateDeps)));
|
||||
|
||||
bundleCrate = writeScriptBin "bundleCrate" ''
|
||||
#!${stdenv.shell}
|
||||
${nix-bundle}/bin/nix-bundle "(pkgs.callPackage ./nix/veloren.nix { cratesToBuild = [ \"$1\" ]; }).$1" /bin/$1
|
||||
'';
|
||||
in
|
||||
mkShell {
|
||||
name = "veloren-shell";
|
||||
nativeBuildInputs = [
|
||||
bundleCrate
|
||||
cachix
|
||||
cargo
|
||||
clippy
|
||||
@ -34,7 +25,7 @@ mkShell {
|
||||
nixpkgs-fmt
|
||||
rustc
|
||||
rustfmt
|
||||
] ++ nixGLPackages ++ (getAllCratesDeps "nativeBuildInputs");
|
||||
] ++ (getAllCratesDeps "nativeBuildInputs");
|
||||
buildInputs = getAllCratesDeps "buildInputs";
|
||||
shellHook = ''
|
||||
# Setup our cachix "substituter"
|
||||
|
@ -5,4 +5,5 @@ watch_file nix/devShell.nix
|
||||
watch_file nix/rustPkgs.nix
|
||||
watch_file nix/shell.nix
|
||||
watch_file nix/utils.nix
|
||||
use nix nix/shell.nix
|
||||
|
||||
use flake
|
||||
|
@ -1,8 +0,0 @@
|
||||
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 nix nix/shell.nix --arg nvidia true
|
@ -8,7 +8,6 @@ let
|
||||
rustToolchain = ../rust-toolchain;
|
||||
sha256 = "sha256-kDtMqYvrTbahqYHYFQOWyvT0+F5o4UVcqkMZt0c43kc=";
|
||||
};
|
||||
|
||||
in
|
||||
channel // {
|
||||
rust = channel.rust.override { extensions = [ "rust-src" ]; };
|
||||
|
@ -1,5 +1,4 @@
|
||||
{ pkgs }: {
|
||||
|
||||
isGitLfsSetup = checkFile:
|
||||
let
|
||||
gitLfsCheckOutput =
|
||||
@ -44,32 +43,4 @@
|
||||
pad = s: if builtins.stringLength s < 2 then "0" + s else s;
|
||||
in
|
||||
"${toString y'}-${pad (toString m)}-${pad (toString d)}-${pad (toString hours)}:${pad (toString minutes)}";
|
||||
|
||||
getGitInfo = dotGitPath:
|
||||
let
|
||||
makeGitCommand = subcommands: name:
|
||||
builtins.readFile (pkgs.runCommand name { } ''
|
||||
cd ${
|
||||
# Only copy the `.git` directory to nix store, anything else is a waste.
|
||||
builtins.path {
|
||||
path = ../.git;
|
||||
# Nix store path names don't accept names that start with a dot.
|
||||
name = "dotgit-dir";
|
||||
}
|
||||
}
|
||||
(${pkgs.git}/bin/git ${subcommands}) > $out
|
||||
'');
|
||||
|
||||
in
|
||||
{
|
||||
gitHash = makeGitCommand
|
||||
"log -n 1 --pretty=format:%h/%cd --date=format:%Y-%m-%d-%H:%M --abbrev=8"
|
||||
"getGitHash";
|
||||
|
||||
gitTag =
|
||||
# If the git command errors out we feed an empty string
|
||||
makeGitCommand "describe --exact-match --tags HEAD || printf ''"
|
||||
"getGitTag";
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -37,18 +37,21 @@ let
|
||||
prettyRev = with sourceInfo;
|
||||
if sourceInfo ? rev && sourceInfo ? lastModified
|
||||
then builtins.substring 0 8 rev + "/" + utils.dateTimeFormat lastModified
|
||||
else (utils.getGitInfo ../.git).gitHash;
|
||||
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 sourceInfo ? tag then sourceInfo.tag
|
||||
if tag != "" then tag
|
||||
else if prettyRev != "" then prettyRev
|
||||
else throw "Need a tag or at least revision + lastModified in order to determine version";
|
||||
# Sanitize version string since it might contain illegal characters for a Nix store path
|
||||
# Used in the derivation(s) name
|
||||
sanitizedVersion = pkgs.stdenv.lib.strings.sanitizeDerivationName version;
|
||||
else throw "Need a tag or pretty revision in order to determine version";
|
||||
|
||||
veloren-assets = pkgs.runCommand "makeAssetsDir" { } ''
|
||||
mkdir $out
|
||||
@ -68,24 +71,18 @@ let
|
||||
|
||||
veloren-crates = with pkgs;
|
||||
callPackage ./Cargo.nix {
|
||||
defaultCrateOverrides = with common;
|
||||
defaultCrateOverrides = with common; with crateDeps;
|
||||
defaultCrateOverrides // {
|
||||
libudev-sys = _: crateDeps.libudev-sys;
|
||||
alsa-sys = _: crateDeps.alsa-sys;
|
||||
veloren-network = _: crateDeps.veloren-network;
|
||||
veloren-common = _: {
|
||||
# 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;
|
||||
# if we have a tag (meaning the commit we are on is a *release*),
|
||||
# use it as version, else use the prettified hash we have;
|
||||
# if we don't have it the build fails
|
||||
NIX_GIT_TAG = version;
|
||||
NIX_GIT_TAG = tag;
|
||||
};
|
||||
veloren-server-cli = _: {
|
||||
name = "veloren-server-cli_${sanitizedVersion}";
|
||||
name = "veloren-server-cli";
|
||||
inherit version;
|
||||
VELOREN_USERDATA_STRATEGY = "system";
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
@ -100,11 +97,11 @@ let
|
||||
};
|
||||
};
|
||||
veloren-voxygen = _: {
|
||||
name = "veloren-voxygen_${sanitizedVersion}";
|
||||
name = "veloren-voxygen";
|
||||
inherit version;
|
||||
VELOREN_USERDATA_STRATEGY = "system";
|
||||
inherit (crateDeps.veloren-voxygen) buildInputs;
|
||||
nativeBuildInputs = crateDeps.veloren-voxygen.nativeBuildInputs
|
||||
inherit (veloren-voxygen) buildInputs;
|
||||
nativeBuildInputs = veloren-voxygen.nativeBuildInputs
|
||||
++ [ makeWrapper copyDesktopItems ];
|
||||
desktopItems = [ velorenVoxygenDesktopFile ];
|
||||
postInstall = ''
|
||||
@ -121,6 +118,11 @@ let
|
||||
'';
|
||||
};
|
||||
};
|
||||
} // {
|
||||
xcb = _: xcb;
|
||||
libudev-sys = _: libudev-sys;
|
||||
alsa-sys = _: alsa-sys;
|
||||
veloren-network = _: veloren-network;
|
||||
};
|
||||
inherit release pkgs;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user