Skip to content

Commit

Permalink
Merge pull request #985 from candy-lang/support-nix
Browse files Browse the repository at this point in the history
Support Nix
  • Loading branch information
jwbot authored Mar 14, 2024
2 parents a948951 + 6a4aaf8 commit ed3bf74
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 51 deletions.
3 changes: 3 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://direnv.net

use flake
4 changes: 2 additions & 2 deletions compiler/backend_inkwell/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ impl<'ctx> LlvmCandyModule<'ctx> {
pub fn compile_obj_and_link(
&self,
path: &str,
build_rt: bool,
build_runtime: bool,
debug: bool,
linker: &str,
) -> Result<(), std::io::Error> {
if build_rt {
if build_runtime {
std::process::Command::new("make")
.args(["-C", "compiler/backend_inkwell/candy_runtime/", "clean"])
.spawn()?
Expand Down
2 changes: 1 addition & 1 deletion compiler/cli/src/inkwell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub fn compile(options: &Options) -> ProgramResult {
llvm_candy_module
.compile_obj_and_link(&path, options.build_runtime, options.debug, &options.linker)
.map_err(|err| {
error!("Failed to compile and link executable: {}", err);
error!("Failed to compile and link executable: {err}");
Exit::ExternalError
})?;

Expand Down
116 changes: 116 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
description = "Development environment for working on the Candy compiler";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, flake-utils, rust-overlay }:
let
overlays = [
rust-overlay.overlays.default
(final: prev: {
rustToolchain =
prev.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
})
];
in flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit overlays system;
config = { };
};
in {
devShell = with pkgs;
mkShell {
LLVM_SYS_150_PREFIX = "${pkgs.llvmPackages_15.llvm.dev}";
RUSTC_WRAPPER = "sccache";
RUSTFLAGS = "-C link-arg=-fuse-ld=mold";
buildInputs = [
libffi
llvmPackages_15.bintools
llvmPackages_15.clangUseLLVM
llvmPackages_15.llvm
mold
rustToolchain
rust-analyzer
sccache
];
};
});
}
46 changes: 3 additions & 43 deletions old-packages/name_checker/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,8 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.10.0"
basics:
dependency: "direct main"
description:
name: basics
sha256: a80dc3eab04567380c76ff2533ae56ba13874c77ee547cef956893aed9375c2e
url: "https://pub.dev"
source: hosted
version: "0.4.0+1"
characters:
dependency: "direct main"
description:
name: characters
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
url: "https://pub.dev"
source: hosted
version: "1.3.0"
collection:
dependency: "direct main"
dependency: transitive
description:
name: collection
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
Expand Down Expand Up @@ -185,16 +169,8 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.1"
matcher:
dependency: transitive
description:
name: matcher
sha256: c94db23593b89766cda57aab9ac311e3616cf87c6fa4e9749df032f66f30dcb8
url: "https://pub.dev"
source: hosted
version: "0.12.14"
meta:
dependency: "direct main"
dependency: transitive
description:
name: meta
sha256: "12307e7f0605ce3da64cf0db90e5fcab0869f3ca03f76be6bb2991ce0a55e82b"
Expand Down Expand Up @@ -257,14 +233,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.2.4"
quiver:
dependency: transitive
description:
name: quiver
sha256: e83f7ad1e6375da1400b54eea8793bba804d1731d68c5694490bf9296cd3ca24
url: "https://pub.dev"
source: hosted
version: "2.1.5"
retry:
dependency: "direct main"
description:
Expand All @@ -281,14 +249,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.9.1"
stack_trace:
dependency: transitive
description:
name: stack_trace
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
url: "https://pub.dev"
source: hosted
version: "1.11.0"
string_scanner:
dependency: transitive
description:
Expand Down Expand Up @@ -338,4 +298,4 @@ packages:
source: hosted
version: "3.1.1"
sdks:
dart: ">=2.19.0 <3.0.0"
dart: ">=2.19.0 <4.0.0"
4 changes: 0 additions & 4 deletions old-packages/name_checker/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ environment:
sdk: '>=2.18.0 <3.0.0'

dependencies:
basics: ^0.4.0
characters: ^1.0.0
collection: ^1.14.12
http: ^0.13.5
meta: ^1.1.8
retry: ^3.1.0

dev_dependencies:
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "nightly-2024-02-22"
profile = "minimal"
components = ["clippy", "rustfmt"]
components = ["clippy", "rust-src", "rustfmt"]

0 comments on commit ed3bf74

Please sign in to comment.