Merge pull request #5990 from JRMurr/nix-build-update

Refactor nix file structure and builds
This commit is contained in:
Anton-4 2023-11-17 20:12:07 +01:00 committed by GitHub
commit 44411d53ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 266 additions and 239 deletions

View file

@ -15,25 +15,25 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Only run all steps if flake.lock or flake.nix changed
id: checklock
- name: Only run all steps if a nix file changed
run: |
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep 'flake'; then
echo "A flake file was changed. Testing devtools nix files..."
echo "flake_changed=true" >> $GITHUB_ENV
git fetch origin ${{ github.base_ref }}
if git diff --name-only origin/${{ github.base_ref }} HEAD | grep 'nix'; then
echo "A nix file was changed. Testing devtools nix files..."
echo "nix_changed=true" >> $GITHUB_ENV
else
echo "No flake file was changed. No need to run tests."
echo "flake_changed=false" >> $GITHUB_ENV
echo "A nix file was changed. No need to run tests."
echo "nix_changed=false" >> $GITHUB_ENV
fi
- uses: cachix/install-nix-action@v23
if: env.flake_changed == 'true'
if: env.nix_changed == 'true'
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: test devtools/flake.nix
if: env.flake_changed == 'true'
if: env.nix_changed == 'true'
id: devtools_test_step
run: |
sed -i "s|/home/username/gitrepos/roc|$(realpath .)|g" devtools/flake.nix

View file

@ -15,19 +15,19 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Only run all steps if flake.lock or flake.nix changed
id: checklock
- name: Only run all steps if a nix file changed
run: |
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep 'flake'; then
echo "A flake file was changed. Testing devtools nix files..."
echo "flake_changed=true" >> $GITHUB_ENV
git fetch origin ${{ github.base_ref }}
if git diff --name-only origin/${{ github.base_ref }} HEAD | grep 'nix'; then
echo "A nix file was changed. Testing devtools nix files..."
echo "nix_changed=true" >> $GITHUB_ENV
else
echo "No flake file was changed. No need to run tests."
echo "flake_changed=false" >> $GITHUB_ENV
echo "A nix file was changed. No need to run tests."
echo "nix_changed=false" >> $GITHUB_ENV
fi
- name: test devtools/flake.nix
if: env.flake_changed == 'true'
if: env.nix_changed == 'true'
id: devtools_test_step
run: |
sed -i '' "s|/home/username/gitrepos/roc|$(realpath .)|g" devtools/flake.nix
@ -41,7 +41,7 @@ jobs:
nix develop --show-trace
- name: Print tip on fail
if: env.flake_changed == 'true'
if: steps.devtools_test_step.outcome == 'failure'
run: |
echo "The devtools test failed, this can likely be fixed by"
echo "locally deleting devtools/flake.lock and following the"

View file

@ -1,111 +1,10 @@
{ rev ? (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.nixpkgs.locked.rev
, nixpkgsSource ? builtins.fetchTarball {
url = "https://github.com/nixos/nixpkgs/tarball/${rev}";
sha256 = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.nixpkgs.locked.narHash;
}
, pkgs ? import nixpkgsSource { }
,
}:
# we only use this file to release a nix package, use flake.nix for development
let
desiredRustVersion = (builtins.fromTOML (builtins.readFile (./rust-toolchain.toml))).toolchain.channel;
actualRustVersion = pkgs.rustc;
rustVersionsMatch = pkgs.lib.strings.hasSuffix desiredRustVersion actualRustVersion;
# When updating the zig or llvm version, make sure they stay in sync.
# Also update in flake.nix (TODO: maybe we can use nix code to sync this)
zigPkg = pkgs.zig_0_11;
llvmPkgs = pkgs.llvmPackages_16;
llvmVersion = builtins.splitVersion llvmPkgs.release_version;
llvmMajorMinorStr = builtins.elemAt llvmVersion 0 + builtins.elemAt llvmVersion 1;
# nix does not store libs in /usr/lib or /lib
glibcPath =
if pkgs.stdenv.isLinux then "${pkgs.glibc.out}/lib" else "";
libGccSPath =
if pkgs.stdenv.isLinux then "${pkgs.stdenv.cc.cc.lib}/lib" else "";
in
assert pkgs.lib.assertMsg rustVersionsMatch ''
The rust version changed in rust-toolchain.toml but the rev(commit) in nixpkgs.url in flake.nix was not updated.
1. clone the nixpkgs repo: `git clone --depth 60000 git@github.com:NixOS/nixpkgs.git`
2. `cd nixpkgs`
3. `git log --oneline | rg -A 1 "rustc: <RUST_VERSION_IN_RUST_TOOLCHAIN_TOML>"`
4. Copy the short SHA from the line **after** the commit with the message of for example `rustc: 1.67.1 -> 1.68.0`
5. Find the long SHA by executing `git rev-parse <PASTE>`
6. Copy the long SHA
7. Paste it in place of the old SHA(rev) in flake.nix:inputs:nixpkgs.url
8. execute `nix flake lock --update-input rust-overlay`
'';
pkgs.rustPlatform.buildRustPackage {
pname = "roc";
version = "0.0.1";
src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
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}"
'';
# 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;
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 [
pkgs.darwin.apple_sdk.frameworks.AppKit
pkgs.darwin.apple_sdk.frameworks.CoreFoundation
pkgs.darwin.apple_sdk.frameworks.CoreServices
pkgs.darwin.apple_sdk.frameworks.Foundation
pkgs.darwin.apple_sdk.frameworks.Security
]);
# cp: to copy str.zig,list.zig...
# wrapProgram pkgs.stdenv.cc: to make ld available for compiler/build/src/link.rs
postInstall =
if pkgs.stdenv.isLinux then ''
wrapProgram $out/bin/roc --set NIX_GLIBC_PATH ${glibcPath} --set NIX_LIBGCC_S_PATH ${libGccSPath} --prefix PATH : ${
pkgs.lib.makeBinPath [ pkgs.stdenv.cc ]
}
'' else ''
wrapProgram $out/bin/roc --prefix PATH : ${
pkgs.lib.makeBinPath [ pkgs.stdenv.cc ]
}
'';
}
(import
(
let lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in fetchTarball {
url =
"https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{ src = ./.; }).defaultNix

120
devtools/flake.lock generated Executable file → Normal file
View file

@ -1,21 +1,36 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1692799911,
"narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=",
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
"id": "flake-utils",
"type": "indirect"
}
},
"flake-utils_2": {
@ -23,44 +38,11 @@
"systems": "systems_2"
},
"locked": {
"lastModified": 1681202837,
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_3": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_4": {
"inputs": {
"systems": "systems_3"
},
"locked": {
"lastModified": 1681202837,
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {
@ -71,18 +53,21 @@
},
"nixgl": {
"inputs": {
"flake-utils": "flake-utils_3",
"flake-utils": [
"roc",
"flake-utils"
],
"nixpkgs": [
"roc",
"nixpkgs"
]
},
"locked": {
"lastModified": 1676383589,
"narHash": "sha256-KCkWZXCjH+C4Kn7fUGSrEl5btk+sERHhZueSsvVbPWc=",
"lastModified": 1685908677,
"narHash": "sha256-E4zUPEUFyVWjVm45zICaHRpfGepfkE9Z2OECV9HXfA4=",
"owner": "guibou",
"repo": "nixGL",
"rev": "c917918ab9ebeee27b0dd657263d3f57ba6bb8ad",
"rev": "489d6b095ab9d289fe11af0219a9ff00fe87c7c5",
"type": "github"
},
"original": {
@ -93,35 +78,36 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1690279121,
"narHash": "sha256-XoPGhV1UJQPue6RiehAu7lQwKss3J1B/K0QtVOMD83A=",
"lastModified": 1693140250,
"narHash": "sha256-URyIDETtu1bbxcSl83xp7irEV04dPEgj7O3LjHcD1Sk=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "821c72743ceae44bdd09718d47cab98fd5fd90af",
"rev": "676fe5e01b9a41fa14aaa48d87685677664104b1",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixpkgs",
"rev": "821c72743ceae44bdd09718d47cab98fd5fd90af",
"rev": "676fe5e01b9a41fa14aaa48d87685677664104b1",
"type": "github"
}
},
"roc": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils_2",
"nixgl": "nixgl",
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1694000770,
"narHash": "sha256-92bAbPmwXxD6rwaAViG5O9r91ZBh9bqaZhM3egPCjuw=",
"path": "/home/anton/gitrepos/roc",
"lastModified": 1700241573,
"narHash": "sha256-+hjY1FieVbF8jvRE3Cvo8GBWh1OlFrF+QDFF8OlWM/s=",
"path": "/home/username/gitrepos/JRMurr/roc",
"type": "path"
},
"original": {
"path": "/home/anton/gitrepos/roc",
"path": "/home/username/gitrepos/JRMurr/roc",
"type": "path"
}
},
@ -133,18 +119,21 @@
},
"rust-overlay": {
"inputs": {
"flake-utils": "flake-utils_4",
"flake-utils": [
"roc",
"flake-utils"
],
"nixpkgs": [
"roc",
"nixpkgs"
]
},
"locked": {
"lastModified": 1690252178,
"narHash": "sha256-9oEz822bvbHobfCUjJLDor2BqW3I5tycIauzDlzOALY=",
"lastModified": 1695694299,
"narHash": "sha256-0CucEiOZzOVHwmGDJKNXLj7aDYOqbRtqChp9nbGrh18=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "8d64353ca827002fb8459e44d49116c78d868eba",
"rev": "c89a55d2d91cf55234466934b25deeffa365188a",
"type": "github"
},
"original": {
@ -182,21 +171,6 @@
"repo": "default",
"type": "github"
}
},
"systems_3": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",

17
flake.lock generated
View file

@ -1,5 +1,21 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
@ -59,6 +75,7 @@
},
"root": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"nixgl": "nixgl",
"nixpkgs": "nixpkgs",

View file

@ -18,9 +18,15 @@
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
# for non flake backwards compatibility
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = { self, nixpkgs, rust-overlay, flake-utils, nixgl }:
outputs = { self, nixpkgs, rust-overlay, flake-utils, nixgl, ... }@inputs:
let supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" "aarch64-linux" ];
in flake-utils.lib.eachSystem supportedSystems (system:
let
@ -28,17 +34,11 @@
++ (if system == "x86_64-linux" then [ nixgl.overlay ] else [ ]);
pkgs = import nixpkgs { inherit system overlays; };
# When updating the zig or llvm version, make sure they stay in sync.
# Also update in default.nix (TODO: maybe we can use nix code to sync this)
zigPkg = pkgs.zig_0_11;
llvmPkgs = pkgs.llvmPackages_16;
llvmVersion = builtins.splitVersion llvmPkgs.release_version;
llvmMajorMinorStr = builtins.elemAt llvmVersion 0 + builtins.elemAt llvmVersion 1;
rocBuild = import ./nix { inherit pkgs; };
# get current working directory
cwd = builtins.toString ./.;
rust =
pkgs.rust-bin.fromRustupToolchainFile "${cwd}/rust-toolchain.toml";
compile-deps = rocBuild.compile-deps;
inherit (compile-deps) zigPkg llvmPkgs llvmVersion
llvmMajorMinorStr glibcPath libGccSPath darwinInputs;
# DevInputs are not necessary to build roc as a user
linuxDevInputs = with pkgs;
@ -55,24 +55,14 @@
xorg.libxcb
];
darwinInputs = with pkgs;
lib.optionals stdenv.isDarwin
(with pkgs.darwin.apple_sdk.frameworks; [
AppKit
CoreFoundation
CoreServices
Foundation
Security
]);
# DevInputs are not necessary to build roc as a user
darwinDevInputs = with pkgs;
lib.optionals stdenv.isDarwin
(with pkgs.darwin.apple_sdk.frameworks; [
CoreVideo # for examples/gui
Metal # for examples/gui
curl # for wasm-bindgen-cli libcurl (see ./ci/www-repl.sh)
]);
(with pkgs.darwin.apple_sdk.frameworks; [
CoreVideo # for examples/gui
Metal # for examples/gui
curl # for wasm-bindgen-cli libcurl (see ./ci/www-repl.sh)
]);
# For debugging LLVM IR
debugir = pkgs.stdenv.mkDerivation {
@ -111,7 +101,7 @@
zlib
# faster builds - see https://github.com/roc-lang/roc/blob/main/BUILDING_FROM_SOURCE.md#use-lld-for-the-linker
llvmPkgs.lld
rust
rocBuild.rust-shell
]);
sharedDevInputs = (with pkgs; [
@ -134,14 +124,15 @@
alias fmtc='cargo fmt --all -- --check'
'';
in {
in
{
devShell = pkgs.mkShell {
buildInputs = sharedInputs ++ sharedDevInputs ++ darwinInputs ++ darwinDevInputs++ linuxDevInputs
buildInputs = sharedInputs ++ sharedDevInputs ++ darwinInputs ++ darwinDevInputs ++ linuxDevInputs
++ (if system == "x86_64-linux" then
[ pkgs.nixgl.nixVulkanIntel ]
else
[ ]);
[ pkgs.nixgl.nixVulkanIntel ]
else
[ ]);
# nix does not store libs in /usr/lib or /lib
# for libgcc_s.so.1
@ -153,11 +144,11 @@
LD_LIBRARY_PATH = with pkgs;
lib.makeLibraryPath
([ pkg-config stdenv.cc.cc.lib libffi ncurses zlib ]
++ linuxDevInputs);
([ pkg-config stdenv.cc.cc.lib libffi ncurses zlib ]
++ linuxDevInputs);
NIXPKGS_ALLOW_UNFREE =
1; # to run the GUI examples with NVIDIA's closed source drivers
shellHook = ''
export LLVM_SYS_${llvmMajorMinorStr}_PREFIX="${llvmPkgs.llvm.dev}"
${aliases}
@ -167,6 +158,14 @@
formatter = pkgs.nixpkgs-fmt;
# You can build this package (the roc CLI) with the `nix build` command.
packages.default = import ./. { inherit pkgs; };
packages = {
default = rocBuild.roc-cli;
# all rust crates in workspace.members of Cargo.toml
full = rocBuild.roc-full;
# only the CLI crate = executable provided in nightly releases
cli = rocBuild.roc-cli;
lang-server = rocBuild.roc-lang-server;
};
});
}

87
nix/builder.nix Normal file
View file

@ -0,0 +1,87 @@
{ pkgs, lib, rustPlatform, compile-deps, subPackage ? null }:
let
inherit (compile-deps) zigPkg llvmPkgs llvmVersion llvmMajorMinorStr glibcPath libGccSPath;
subPackagePath = if subPackage != null then "crates/${subPackage}" else null;
in
rustPlatform.buildRustPackage {
pname = "roc" + lib.optionalString (subPackage != null) "_${subPackage}";
version = "0.0.1";
buildAndTestSubdir = subPackagePath;
src = pkgs.nix-gitignore.gitignoreSource [ ] ../.;
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}"
'';
# 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;
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
]));
# 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
'';
}

25
nix/compile-deps.nix Normal file
View file

@ -0,0 +1,25 @@
{ pkgs }:
let
zigPkg = pkgs.zig_0_11;
llvmPkgs = pkgs.llvmPackages_16;
llvmVersion = builtins.splitVersion llvmPkgs.release_version;
llvmMajorMinorStr = builtins.elemAt llvmVersion 0 + builtins.elemAt llvmVersion 1;
# nix does not store libs in /usr/lib or /lib
glibcPath =
if pkgs.stdenv.isLinux then "${pkgs.glibc.out}/lib" else "";
libGccSPath =
if pkgs.stdenv.isLinux then "${pkgs.stdenv.cc.cc.lib}/lib" else "";
in
{
inherit zigPkg llvmPkgs llvmVersion llvmMajorMinorStr glibcPath libGccSPath;
darwinInputs = with pkgs;
lib.optionals stdenv.isDarwin
(with pkgs.darwin.apple_sdk.frameworks; [
AppKit
CoreFoundation
CoreServices
Foundation
Security
]);
}

27
nix/default.nix Normal file
View file

@ -0,0 +1,27 @@
{ pkgs }:
let
rustVersion = (pkgs.rust-bin.fromRustupToolchainFile ../rust-toolchain.toml);
rustPlatform = pkgs.makeRustPlatform {
cargo = rustVersion;
rustc = rustVersion;
};
# this will allow our callPackage to reference our own packages defined below
# mainly helps with passing compile-deps and rustPlatform to builder automatically
callPackage = pkgs.lib.callPackageWith (pkgs // packages);
packages = {
inherit rustPlatform;
compile-deps = callPackage ./compile-deps.nix { };
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 = "lang_srv"; };
# only the CLI crate = executable provided in nightly releases
roc-cli = callPackage ./builder.nix { subPackage = "cli"; };
};
in
packages

View file

@ -9,7 +9,6 @@
# - update nightly-OLD_DATE in .github/workflows/windows_tests.yml
# - update nightly-OLD_DATE in .github/workflows/windows_release_build.yml
# - update nightly-OLD_DATE in crates/compiler/build/src/link.rs
# - Follow instructions in default.nix: `assert pkgs.lib.assertMsg rustVersionsMatch` ...
channel = "1.71.1" # check ^^^ when changing this
#