diff --git a/nix/common.nix b/nix/common.nix index 650758e28b..6aec85a00f 100644 --- a/nix/common.nix +++ b/nix/common.nix @@ -1,5 +1,24 @@ -{ pkgs }: -with pkgs; +{ system, sources ? import ./sources.nix { inherit system; } +, nixpkgs ? sources.nixpkgs }: +let + mozPkgs = import "${sources.nixpkgsMoz}/package-set.nix" { + pkgs = import nixpkgs { inherit system; }; + }; + rustChannel = mozPkgs.rustChannelOf { + rustToolchain = ../rust-toolchain; + hash = "sha256-P4FTKRe0nM1FRDV0Q+QY2WcC8M9IR7aPMMLWDfv+rEk="; + }; + pkgs = import nixpkgs { + inherit system; + overlays = [ + (self: super: { + rustc = rustChannel.rust; + inherit (rustChannel) + ; + }) + ]; + }; +in with pkgs; let xorgLibraries = with xorg; [ libX11 libXcursor libXrandr libXi ]; otherLibraries = [ @@ -19,4 +38,4 @@ let veloren-network = [ pkg-config openssl ]; veloren-voxygen = [ atk cairo glib gtk3 pango ]; }; -in { inherit neededLibPaths crateDeps; } +in { inherit pkgs neededLibPaths crateDeps; } diff --git a/nix/default.nix b/nix/default.nix index 011d2d0878..7ea2892696 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -12,8 +12,8 @@ let isBuildingVoxygen = isBuildingCrate "veloren-voxygen"; isBuildingServerCli = isBuildingCrate "veloren-server-cli"; - pkgs = import ./nixpkgs.nix { inherit sources system; }; - common = import ./common.nix { inherit pkgs; }; + common = import ./common.nix { inherit sources system; }; + inherit (common) pkgs; meta = with pkgs; { description = "Veloren is a multiplayer voxel RPG written in Rust."; @@ -42,7 +42,7 @@ let name = "git"; } } - ${pkgs.git}/bin/git ${subcommands} > $out + (${pkgs.git}/bin/git ${subcommands}) > $out '') else abort '' diff --git a/nix/nixpkgs.nix b/nix/nixpkgs.nix deleted file mode 100644 index f32c965e51..0000000000 --- a/nix/nixpkgs.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ system, sources ? import ./sources.nix { inherit system; } -, nixpkgs ? sources.nixpkgs }: - -let - mozPkgs = import "${sources.nixpkgsMoz}/package-set.nix" { - pkgs = import nixpkgs { inherit system; }; - }; - rustChannel = mozPkgs.rustChannelOf { - rustToolchain = ../rust-toolchain; - hash = "sha256-P4FTKRe0nM1FRDV0Q+QY2WcC8M9IR7aPMMLWDfv+rEk="; - }; -in import nixpkgs { - inherit system; - overlays = [ - (self: super: { - rustc = rustChannel.rust; - inherit (rustChannel) - ; - }) - ]; -} diff --git a/nix/shell.nix b/nix/shell.nix index 5b1c7dc95c..0ec72ed7b1 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -1,13 +1,14 @@ { nixpkgs ? , sources ? import ./sources.nix { } , system ? builtins.currentSystem }: let - pkgs = import ./nixpkgs.nix { inherit sources nixpkgs system; }; - common = import ./common.nix { inherit pkgs; }; + common = import ./common.nix { inherit nixpkgs sources system; }; + inherit (common) pkgs; crate2nix = pkgs.callPackage sources.crate2nix { inherit pkgs; }; in with pkgs; mkShell { name = "veloren-shell"; - nativeBuildInputs = [ git git-lfs niv nixfmt crate2nix cargo rustc ]; + nativeBuildInputs = + [ git git-lfs niv nixfmt crate2nix cargo rustc rustfmt clippy ]; buildInputs = lib.concatLists (lib.attrValues common.crateDeps); shellHook = '' export LD_LIBRARY_PATH=${common.neededLibPaths}