mirror of
https://github.com/roc-lang/roc.git
synced 2024-08-16 22:30:58 +03:00
cleaner way to run editor from nix
This commit is contained in:
parent
c583112497
commit
0d16cdcfa3
@ -1,23 +1,23 @@
|
||||
# Building the Roc compiler from source
|
||||
|
||||
Installation should be a smooth process, let us now if anything does not work perfectly on [Roc Zulip](https://roc.zulipchat.com) or by creating an issue.
|
||||
|
||||
## Using Nix
|
||||
|
||||
### On Linux/MacOS/NixOS x86_64/aarch64/arm64
|
||||
### On Linux x86_64/aarch64 or MacOS aarch64/arm64/x86_64
|
||||
|
||||
#### Install
|
||||
|
||||
We highly recommend Using [nix](https://nixos.org/download.html) to automatically install all dependencies necessary to build roc.
|
||||
We highly recommend Using [nix](https://nixos.org/download.html) to quickly install all dependencies necessary to build roc.
|
||||
|
||||
If you are running ArchLinux or a derivative like Manjaro, you'll need to run `sudo sysctl -w kernel.unprivileged_userns_clone=1` before installing nix.
|
||||
|
||||
Install nix (not necessary on NixOS):
|
||||
```
|
||||
curl -L https://nixos.org/nix/install | sh
|
||||
sh <(curl -L https://nixos.org/nix/install) --daemon
|
||||
```
|
||||
|
||||
Start a fresh terminal session (= open a new terminal).
|
||||
|
||||
install nixFlakes in your environment:
|
||||
Open a new terminal and install nixFlakes in your environment:
|
||||
```
|
||||
nix-env -iA nixpkgs.nixFlakes
|
||||
```
|
||||
@ -27,8 +27,8 @@ Edit either `~/.config/nix/nix.conf` or `/etc/nix/nix.conf` and add:
|
||||
experimental-features = nix-command flakes
|
||||
```
|
||||
|
||||
If Nix was installed in multi-user mode, make sure to restart the nix-daemon.
|
||||
If you don't know how to do this, restarting your computer will also do the job.
|
||||
If Nix was installed in multi-user mode, make sure to restart the nix-daemon.
|
||||
If you don't know how to do this, restarting your computer will also do the job.
|
||||
|
||||
#### Usage
|
||||
|
||||
@ -43,39 +43,19 @@ Use `cargo build` to build the whole project.
|
||||
|
||||
#### Extra tips
|
||||
|
||||
If you want to load all dependencies automatically whenever you `cd` into `roc`, check out [direnv](https://direnv.net/) and [lorri](https://github.com/nix-community/lorri).
|
||||
If you want to load all dependencies automatically whenever you `cd` into `roc`, check out [direnv](https://direnv.net/).
|
||||
Then you will no longer need to execute `nix develop` first.
|
||||
|
||||
### Editor
|
||||
|
||||
The editor is a :construction:WIP:construction: and not ready yet to replace your favorite editor, although if you want to try it out on nix, read on.
|
||||
`cargo run edit` should work from NixOS, if you use another OS, follow the instructions below.
|
||||
|
||||
#### Nvidia GPU
|
||||
`cargo run edit` should work on NixOS and MacOS. If you use Linux x86_64, follow the instructions below.
|
||||
|
||||
If you're not already in a nix shell, execute `nix develop` at the the root of the repo folder and then execute:
|
||||
```
|
||||
nix run --override-input nixpkgs nixpkgs/nixos-21.11 --impure github:guibou/nixGL#nixVulkanNvidia -- cargo run edit
|
||||
nixVulkanIntel cargo run edit
|
||||
```
|
||||
|
||||
If you get an error like:
|
||||
```
|
||||
error: unable to execute '/nix/store/qk6...wjla-nixVulkanNvidia-470.103.01/bin/nixVulkanNvidia': No such file or directory
|
||||
```
|
||||
The intel command should work:
|
||||
```
|
||||
nix run --override-input nixpkgs nixpkgs/nixos-21.11 --impure github:guibou/nixGL#nixVulkanIntel -- cargo run edit
|
||||
```
|
||||
|
||||
##### Integrated Intel Graphics
|
||||
|
||||
```
|
||||
nix run --override-input nixpkgs nixpkgs/nixos-21.11 --impure github:guibou/nixGL#nixVulkanIntel -- cargo run edit
|
||||
```
|
||||
|
||||
##### Other configs
|
||||
|
||||
Check the [nixGL repo](https://github.com/guibou/nixGL) for other graphics configurations. Feel free to ask us for help if you get stuck.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
Create an issue if you run into problems not listed here.
|
||||
|
43
flake.lock
43
flake.lock
@ -45,7 +45,39 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixgl": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1654775507,
|
||||
"narHash": "sha256-NPkQiaz6Oo5EuWj5hRXMKebAhAfiVtnklii0imR85dE=",
|
||||
"owner": "guibou",
|
||||
"repo": "nixGL",
|
||||
"rev": "1cce2dd704829504d057dacc71daf1c00951460d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "guibou",
|
||||
"repo": "nixGL",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1655122334,
|
||||
"narHash": "sha256-Rwwvo9TDCH0a4m/Jvoq5wZ3FLSLiVLBD1FFfN/3XawA=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "e1a1cfb56504d1b82a3953bfb0632b37a1ca8d30",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1647282937,
|
||||
"narHash": "sha256-K8Oo6QyFCfiEWTRpQVfzcwI3YNMKlz6Tu8rr+o3rzRQ=",
|
||||
@ -61,7 +93,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1637453606,
|
||||
"narHash": "sha256-Gy6cwUswft9xqsjWxFYEnx/63/qzaFUwatcbV5GF/GQ=",
|
||||
@ -77,7 +109,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"nixpkgs_4": {
|
||||
"locked": {
|
||||
"lastModified": 1631288242,
|
||||
"narHash": "sha256-sXm4KiKs7qSIf5oTAmrlsEvBW193sFj+tKYVirBaXz0=",
|
||||
@ -96,7 +128,8 @@
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"nixgl": "nixgl",
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"rust-overlay": "rust-overlay",
|
||||
"zig": "zig"
|
||||
}
|
||||
@ -104,7 +137,7 @@
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_2",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
"nixpkgs": "nixpkgs_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1651459928,
|
||||
@ -123,7 +156,7 @@
|
||||
"zig": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_3",
|
||||
"nixpkgs": "nixpkgs_3"
|
||||
"nixpkgs": "nixpkgs_4"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1651452199,
|
||||
|
@ -6,15 +6,16 @@
|
||||
rust-overlay.url = "github:oxalica/rust-overlay"; # rust from nixpkgs has some libc problems, this is patched in the rust-overlay
|
||||
zig.url = "github:roarkanize/zig-overlay"; # using an overlay allows for quick updates after zig releases
|
||||
flake-utils.url = "github:numtide/flake-utils"; # to easily make configs for multiple architectures
|
||||
nixgl.url = "github:guibou/nixGL"; # to be able to use vulkan system libs for editor graphics
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, rust-overlay, zig, flake-utils }:
|
||||
outputs = { self, nixpkgs, rust-overlay, zig, flake-utils, nixgl }:
|
||||
let
|
||||
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
|
||||
in
|
||||
flake-utils.lib.eachSystem supportedSystems (system:
|
||||
let
|
||||
overlays = [ (import rust-overlay) ];
|
||||
overlays = [ (import rust-overlay) ] ++ (if system == "x86_64-linux" then [ nixgl.overlay ] else []);
|
||||
pkgs = import nixpkgs {
|
||||
inherit system overlays;
|
||||
};
|
||||
@ -95,6 +96,7 @@
|
||||
|
||||
# faster builds - see https://github.com/rtfeldman/roc/blob/trunk/BUILDING_FROM_SOURCE.md#use-lld-for-the-linker
|
||||
llvmPkgs.lld
|
||||
llvmPkgs.lldb
|
||||
debugir
|
||||
rust
|
||||
]);
|
||||
@ -102,7 +104,7 @@
|
||||
{
|
||||
|
||||
devShell = pkgs.mkShell {
|
||||
buildInputs = sharedInputs ++ darwinInputs ++ linuxInputs;
|
||||
buildInputs = sharedInputs ++ darwinInputs ++ linuxInputs ++ (if system == "x86_64-linux" then [ pkgs.nixgl.nixVulkanIntel ] else []);
|
||||
|
||||
LLVM_SYS_130_PREFIX = "${llvmPkgs.llvm.dev}";
|
||||
NIX_GLIBC_PATH = if pkgs.stdenv.isLinux then "${pkgs.glibc.out}/lib" else "";
|
||||
|
Loading…
Reference in New Issue
Block a user