From a1491e5a9e6c29559216654223e3490f9d64523c Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Tue, 10 Nov 2020 20:03:04 +0100 Subject: [PATCH] nix cleanup, instructions to run editor from nix --- BUILDING_FROM_SOURCE.md | 28 +++++++++++++- shell.nix | 82 +++++++++++++++++++++-------------------- 2 files changed, 69 insertions(+), 41 deletions(-) diff --git a/BUILDING_FROM_SOURCE.md b/BUILDING_FROM_SOURCE.md index ddec8b0d2f..b2be961d75 100644 --- a/BUILDING_FROM_SOURCE.md +++ b/BUILDING_FROM_SOURCE.md @@ -80,7 +80,7 @@ If MacOS and using a version >= 10.15: You may prefer to setup up the volume manually by following nix documentation. -> You my need to restart your terminal +> You may need to restart your terminal ### Usage @@ -96,6 +96,32 @@ You should be in a shell with everything needed to build already installed. Next You should be in a repl now. Have fun! +### Editor + +When you want to run the editor from Ubuntu inside nix you need to install [nixGL](https://github.com/guibou/nixGL) as well: + +```bash +nix-shell +git clone https://github.com/guibou/nixGL +cd nixGL +``` + +If you have an Nvidia graphics card, run: +``` +nix-env -f ./ -iA nixVulkanNvidia +``` +If you have integrated intel graphics, run +``` +nix-env -f ./ -iA nixVulkanIntel +``` +Check the [nixGL repo](https://github.com/guibou/nixGL) for other configurations. + +Next you should be able to run the editor: +```bash +cd roc +nixVulkanNvidia cargo run edit `# replace Nvidia with the config you chose in the previous step` +``` + ## Troubleshooting Create an issue if you run into problems not listed here. diff --git a/shell.nix b/shell.nix index ab28a63924..adc4219105 100644 --- a/shell.nix +++ b/shell.nix @@ -13,6 +13,8 @@ with { isMacOS = builtins.currentSystem == "x86_64-darwin"; }; +with (pkgs); + let darwin-frameworks = if isMacOS then @@ -27,58 +29,58 @@ let ] else [ ]; - llvm = pkgs.llvm_10; - lld = pkgs.lld_10; # this should match llvm's version - clang = pkgs.clang_10; # this should match llvm's version + llvmPkg = pkgs.llvm_10; + lldPkg = pkgs.lld_10; # this should match llvm's version + clangPkg = pkgs.clang_10; # this should match llvm's version zig = import ./nix/zig.nix { inherit pkgs isMacOS; }; inputs = [ # build libraries - pkgs.rustc - pkgs.cargo - pkgs.clippy - pkgs.rustfmt - pkgs.cmake - pkgs.git - pkgs.python3 - llvm - clang - pkgs.valgrind - pkgs.pkg-config + rustc + cargo + clippy + rustfmt + cmake + git + python3 + llvmPkg + clangPkg + valgrind + pkg-config zig # llb deps - pkgs.libffi - pkgs.libxml2 - pkgs.xorg.libX11 - pkgs.zlib - pkgs.vulkan-headers - pkgs.vulkan-loader - pkgs.vulkan-tools - pkgs.vulkan-validation-layers + libffi + libxml2 + xorg.libX11 + zlib + vulkan-headers + vulkan-loader + vulkan-tools + vulkan-validation-layers # faster builds - see https://github.com/rtfeldman/roc/blob/trunk/BUILDING_FROM_SOURCE.md#use-lld-for-the-linker - lld + lldPkg # dev tools - pkgs.rust-analyzer + rust-analyzer # (import ./nix/zls.nix { inherit pkgs zig; }) - pkgs.ccls + ccls ]; -in pkgs.mkShell { +in mkShell { buildInputs = inputs ++ darwin-frameworks; - LLVM_SYS_100_PREFIX = "${llvm}"; + LLVM_SYS_100_PREFIX = "${llvmPkg}"; - APPEND_LIBRARY_PATH = pkgs.stdenv.lib.makeLibraryPath [ - pkgs.pkgconfig - pkgs.vulkan-headers - pkgs.vulkan-loader - pkgs.vulkan-tools - pkgs.vulkan-validation-layers - pkgs.xorg.libX11 - pkgs.xorg.libXcursor - pkgs.xorg.libXrandr - pkgs.xorg.libXi - pkgs.libcxx - pkgs.libcxxabi - pkgs.libunwind + APPEND_LIBRARY_PATH = stdenv.lib.makeLibraryPath [ + pkgconfig + vulkan-headers + vulkan-loader + vulkan-tools + vulkan-validation-layers + xorg.libX11 + xorg.libXcursor + xorg.libXrandr + xorg.libXi + libcxx + libcxxabi + libunwind ]; # Aliases don't work cross shell, so we do this