veloren/nix/devShell.nix
Ludvig Böklin 3f498522db flake-compat (unify flake and non-flake build process/environment)
The only user-facing changes is the process for version pinning, which will be
slightly less convenient without access to the `nix flake` feature. This is
justified by it rarely being necessary, for the benefit of relying on an
upcoming built-in nix feature rather than a non-standard third-party tool.

- deprecate `niv` for version pinning
- legacy nix now uses the flake via `flake-compat`
  - remove `sources.{nix,json}` (versions now pinned in `flake.lock`)
  - move contents of `nix/default.nix` to `nix/veloren.nix`
  - make `nix-build nix/default.nix` produce the same output as `flake build`
  - move contents of `nix/shell.nix` into `nix/devShell.nix`
  - make `nix-shell nix/shell.nix` produce the same environment as `flake develop`
- Move `tag` parameter into `sourceInfo`
- Tidy up and autoformat with `nixpkgs-fmt`
- update README to reflect new usage
- revert input versions to match those previously specified in nix/sources.json
2020-12-11 12:00:04 +00:00

52 lines
1.5 KiB
Nix

{ nixpkgs, sources, system, nvidia ? false }:
with import ./common.nix
{
inherit
nixpkgs
sources
system
;
};
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
crate2nix
git
git-lfs
nixpkgs-fmt
rustc
rustfmt
] ++ nixGLPackages ++ (getAllCratesDeps "nativeBuildInputs");
buildInputs = getAllCratesDeps "buildInputs";
shellHook = ''
# Setup our cachix "substituter"
export NIX_CONFIG="
substituters = https://cache.nixos.org https://veloren-nix.cachix.org
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= veloren-nix.cachix.org-1:zokfKJqVsNV6kI/oJdLF6TYBdNPYGSb+diMVQPn/5Rc=
"
# Add libraries Voxygen needs so that it runs
export LD_LIBRARY_PATH=${lib.makeLibraryPath voxygenNeededLibs}
# No need to install git-lfs and run fetch / checkout commands if we have it setup
[ "$(${file}/bin/file --mime-type ${gitLfsCheckFile})" = "${gitLfsCheckFile}: image/png" ] || (git lfs install --local && git lfs fetch && git lfs checkout)
'';
}