diff --git a/devtools/flake.lock b/devtools/flake.lock index 4d880925a3c..11b30cd5d98 100644 --- a/devtools/flake.lock +++ b/devtools/flake.lock @@ -101,8 +101,8 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1712750088, - "narHash": "sha256-qao1J0xx+eCuCdOTCf4wPkkKmwHdJy1uof4QKhO/yOc=", + "lastModified": 1722362288, + "narHash": "sha256-tjwYO8AH2Skwhynm/fwOTodN/EqLgAbvKzhE/xxQ2r8=", "path": "/home/username/gitrepos/roc", "type": "path" }, @@ -129,11 +129,11 @@ ] }, "locked": { - "lastModified": 1712369449, - "narHash": "sha256-tbWug3uXPlSm1j0xD80Y3xbP+otT6gLnQo1e/vQat48=", + "lastModified": 1713150335, + "narHash": "sha256-Ic7zCPfiSYc9nFFp+E44WFk3TBJ99J/uPZ4QXX+uPPw=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "41b3b080cc3e4b3a48e933b87fc15a05f1870779", + "rev": "b186d85e747e2b7bee220ec95839fb66c868dc47", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index b8e952c3f95..8487f2bd822 100644 --- a/flake.nix +++ b/flake.nix @@ -150,7 +150,10 @@ full = rocBuild.roc-full; # only the CLI crate = executable provided in nightly releases cli = rocBuild.roc-cli; + cli-debug = rocBuild.roc-cli-debug; + lang-server = rocBuild.roc-lang-server; + lang-server-debug = rocBuild.roc-lang-server-debug; }; apps = { diff --git a/nix/builder.nix b/nix/builder.nix index 31fc1df6821..48782e54c5a 100644 --- a/nix/builder.nix +++ b/nix/builder.nix @@ -5,92 +5,98 @@ let subPackagePath = if subPackage != null then "crates/${subPackage}" else null; mainBin = if subPackage == "language_server" then "roc_language_server" else "roc"; filteredSource = pkgs.callPackage ./fileFilter.nix { }; -in -rustPlatform.buildRustPackage { - pname = "roc" + lib.optionalString (subPackage != null) "_${subPackage}"; - version = "0.0.1"; + buildRoc = buildTypeStr: + rustPlatform.buildRustPackage { + pname = "roc" + lib.optionalString (subPackage != null) "_${subPackage}"; + version = "0.0.1"; + buildType = buildTypeStr; - buildAndTestSubdir = subPackagePath; + buildAndTestSubdir = subPackagePath; - src = filteredSource; + src = filteredSource; - cargoLock = { - lockFile = ../Cargo.lock; - outputHashes = { - "criterion-0.3.5" = "sha256-+FibPQGiR45g28xCHcM0pMN+C+Q8gO8206Wb5fiTy+k="; - "inkwell-0.2.0" = "sha256-VhTapYGonoSQ4hnDoLl4AAgj0BppAhPNA+UPuAJSuAU="; - "plotters-0.3.1" = "sha256-noy/RSjoEPZZbOJTZw1yxGcX5S+2q/7mxnUrzDyxOFw="; - "rustyline-9.1.1" = "sha256-aqQqz6nSp+Qn44gm3jXmmQUO6/fYTx7iLph2tbA24Bs="; - }; - }; + cargoLock = { + lockFile = ../Cargo.lock; + outputHashes = { + "criterion-0.3.5" = "sha256-+FibPQGiR45g28xCHcM0pMN+C+Q8gO8206Wb5fiTy+k="; + "inkwell-0.2.0" = "sha256-VhTapYGonoSQ4hnDoLl4AAgj0BppAhPNA+UPuAJSuAU="; + "plotters-0.3.1" = "sha256-noy/RSjoEPZZbOJTZw1yxGcX5S+2q/7mxnUrzDyxOFw="; + "rustyline-9.1.1" = "sha256-aqQqz6nSp+Qn44gm3jXmmQUO6/fYTx7iLph2tbA24Bs="; + }; + }; - shellHook = '' - export LLVM_SYS_${llvmMajorMinorStr}_PREFIX="${llvmPkgs.llvm.dev}" - ''; + shellHook = '' + export LLVM_SYS_${llvmMajorMinorStr}_PREFIX="${llvmPkgs.llvm.dev}" + ''; - # required for zig - XDG_CACHE_HOME = - "xdg_cache"; # prevents zig AccessDenied error github.com/ziglang/zig/issues/6810 - # want to see backtrace in case of failure - RUST_BACKTRACE = 1; + # required for zig + XDG_CACHE_HOME = + "xdg_cache"; # prevents zig AccessDenied error github.com/ziglang/zig/issues/6810 + # want to see backtrace in case of failure + RUST_BACKTRACE = 1; - # skip running rust tests, problems: - # building of example platforms requires network: Could not resolve host - # zig AccessDenied error github.com/ziglang/zig/issues/6810 - # Once instance has previously been poisoned ?? - doCheck = false; + # skip running rust tests, problems: + # building of example platforms requires network: Could not resolve host + # zig AccessDenied error github.com/ziglang/zig/issues/6810 + # Once instance has previously been poisoned ?? + doCheck = false; - nativeBuildInputs = (with pkgs; [ - cmake - git - pkg-config - python3 - llvmPkgs.clang - llvmPkgs.llvm.dev - llvmPkgs.bintools-unwrapped # contains lld - zigPkg - ]); + nativeBuildInputs = (with pkgs; [ + cmake + git + pkg-config + python3 + llvmPkgs.clang + llvmPkgs.llvm.dev + llvmPkgs.bintools-unwrapped # contains lld + zigPkg + ]); - buildInputs = (with pkgs; - [ - libffi - libxml2 - ncurses - zlib - cargo - makeWrapper # necessary for postBuild wrapProgram - ] ++ lib.optionals pkgs.stdenv.isDarwin - (with pkgs.darwin.apple_sdk.frameworks; - [ - AppKit - CoreFoundation - CoreServices - Foundation - Security - ])); + buildInputs = (with pkgs; + [ + libffi + libxml2 + ncurses + zlib + cargo + makeWrapper # necessary for postBuild wrapProgram + ] ++ lib.optionals pkgs.stdenv.isDarwin + (with pkgs.darwin.apple_sdk.frameworks; + [ + AppKit + CoreFoundation + CoreServices + Foundation + Security + ])); - # cp: to copy str.zig,list.zig... - # wrapProgram pkgs.stdenv.cc: to make ld available for compiler/build/src/link.rs - postInstall = - let - binPath = - lib.makeBinPath [ pkgs.stdenv.cc ]; - linuxArgs = lib.optionalString pkgs.stdenv.isLinux - "--set NIX_GLIBC_PATH ${glibcPath} --set NIX_LIBGCC_S_PATH ${libGccSPath}"; - rocPath = "$out/bin/roc"; - wrapRoc = "wrapProgram ${rocPath} ${linuxArgs} --prefix PATH : ${binPath}"; - in - # need to check if roc bin exists since it might not if subPackage is set - '' - if test -f ${rocPath}; then - ${wrapRoc} - fi - ''; + # cp: to copy str.zig,list.zig... + # wrapProgram pkgs.stdenv.cc: to make ld available for compiler/build/src/link.rs + postInstall = + let + binPath = + lib.makeBinPath [ pkgs.stdenv.cc ]; + linuxArgs = lib.optionalString pkgs.stdenv.isLinux + "--set NIX_GLIBC_PATH ${glibcPath} --set NIX_LIBGCC_S_PATH ${libGccSPath}"; + rocPath = "$out/bin/roc"; + wrapRoc = "wrapProgram ${rocPath} ${linuxArgs} --prefix PATH : ${binPath}"; + in + # need to check if roc bin exists since it might not if subPackage is set + '' + if test -f ${rocPath}; then + ${wrapRoc} + fi + ''; - # https://ryantm.github.io/nixpkgs/stdenv/meta/ - meta = { - homepage = "https://www.roc-lang.org/"; - license = lib.licenses.upl; - mainProgram = mainBin; - }; + # https://ryantm.github.io/nixpkgs/stdenv/meta/ + meta = { + homepage = "https://www.roc-lang.org/"; + license = lib.licenses.upl; + mainProgram = mainBin; + }; + }; +in +{ + roc-debug = buildRoc "debug"; + roc-release = buildRoc "release"; } diff --git a/nix/default.nix b/nix/default.nix index 8a9e167816b..e54aa8a2acf 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -16,11 +16,16 @@ let rust-shell = (rustVersion.override { extensions = [ "rust-src" "rust-analyzer" ]; }); - # all rust crates in workspace.members of Cargo.toml - roc-full = callPackage ./builder.nix { }; - roc-lang-server = callPackage ./builder.nix { subPackage = "language_server"; }; + # contains all rust crates in workspace.members of Cargo.toml + roc-full = (callPackage ./builder.nix { }).roc-release; + roc-full-debug = (callPackage ./builder.nix { }).roc-debug; + + roc-lang-server = (callPackage ./builder.nix { subPackage = "language_server"; }).roc-release; + roc-lang-server-debug = (callPackage ./builder.nix { subPackage = "language_server"; }).roc-debug; + # only the CLI crate = executable provided in nightly releases - roc-cli = callPackage ./builder.nix { subPackage = "cli"; }; + roc-cli = (callPackage ./builder.nix { subPackage = "cli"; }).roc-release; + roc-cli-debug = (callPackage ./builder.nix { subPackage = "cli"; }).roc-debug; }; in diff --git a/nix/fileFilter.nix b/nix/fileFilter.nix index 8f974f85b21..a8c0fb7cab5 100644 --- a/nix/fileFilter.nix +++ b/nix/fileFilter.nix @@ -37,6 +37,8 @@ let ../Cargo.toml ../Cargo.lock ../version.txt + ../rust-toolchain.toml + ../.cargo/config.toml onlyCratesFolder ];