-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge 'Full flake overhaul' from Levy A.
Improvements: - Use [rust-overlay](https://github.com/oxalica/rust-overlay), better maintained than fenix and allows for: - Use `rust-toolchain.toml` as the source of truth for the current rust version, instead of tracking with stable. Preventing conflicting versions with non-nix users. - Add flake checks, could be useful for CI in the future, together with crane and cachix. - Add package, allow people to add limbo as a regular nix package. Now we can `nix build .#`, `nix run .#` and `nix shell .#` (this one adds `limbo` to the current `PATH`) - Use [new `apple-sdk` pattern](https://discourse.nixos.org/t/the- darwin-sdks-have-been-updated/55295), no need to declare each framework now. Closes #835
- Loading branch information
Showing
2 changed files
with
124 additions
and
66 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,73 @@ | ||
{ | ||
inputs = { | ||
nixpkgs = { | ||
url = "github:nixos/nixpkgs"; | ||
}; | ||
fenix = { | ||
url = "github:nix-community/fenix"; | ||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
crane.url = "github:ipetkov/crane"; | ||
rust-overlay = { | ||
url = "github:oxalica/rust-overlay"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
}; | ||
|
||
outputs = { | ||
nixpkgs, | ||
fenix, | ||
... | ||
}: let | ||
systems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"]; | ||
forAllSystems = nixpkgs.lib.genAttrs systems; | ||
in { | ||
devShells = forAllSystems ( | ||
system: let | ||
pkgs = nixpkgs.legacyPackages.${system}; | ||
rustStable = fenix.packages.${system}.stable.toolchain; | ||
wasmTarget = fenix.packages.${system}.targets.wasm32-wasi.latest.rust-std; | ||
extraDarwinInputs = | ||
if pkgs.stdenv.isDarwin | ||
then [pkgs.darwin.apple_sdk.frameworks.CoreFoundation] | ||
else []; | ||
in { | ||
default = with pkgs; | ||
mkShell { | ||
buildInputs = | ||
[ | ||
clang | ||
libiconv | ||
sqlite | ||
gnumake | ||
rustup # not used to install the toolchain, but the makefile uses it | ||
rustStable | ||
wasmTarget | ||
tcl | ||
] | ||
++ extraDarwinInputs; | ||
}; | ||
outputs = { nixpkgs, flake-utils, rust-overlay, crane, ... }: | ||
flake-utils.lib.eachDefaultSystem (system: | ||
let | ||
pkgs = import nixpkgs { | ||
inherit system; | ||
overlays = [ (import rust-overlay) ]; | ||
}; | ||
|
||
toolchain = break ((pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml).override { | ||
extensions = [ "rust-analyzer" "rust-src" ]; | ||
targets = [ "wasm32-unknown-unknown" ]; | ||
}); | ||
|
||
lib = pkgs.lib; | ||
|
||
cargoArtifacts = craneLib.buildDepsOnly { | ||
src = ./.; | ||
pname = "limbo"; | ||
stritcDeps = true; | ||
nativeBuildInputs = with pkgs; [ python3 ]; | ||
}; | ||
|
||
commonArgs = { | ||
inherit cargoArtifacts; | ||
pname = "limbo"; | ||
src = ./.; | ||
nativeBuildInputs = with pkgs; [ python3 ]; | ||
strictDeps = true; | ||
}; | ||
|
||
craneLib = ((crane.mkLib pkgs).overrideToolchain toolchain); | ||
in | ||
rec { | ||
formatter = pkgs.nixpkgs-fmt; | ||
checks = { | ||
doc = craneLib.cargoDoc commonArgs; | ||
fmt = craneLib.cargoFmt commonArgs; | ||
clippy = craneLib.cargoClippy (commonArgs // { | ||
# TODO: maybe add `-- --deny warnings` | ||
cargoClippyExtraArgs = "--all-targets"; | ||
}); | ||
}; | ||
packages.limbo = craneLib.buildPackage (commonArgs // { | ||
cargoExtraArgs = "--bin limbo"; | ||
}); | ||
packages.default = packages.limbo; | ||
devShells.default = with pkgs; mkShell { | ||
nativeBuildInputs = [ | ||
clang | ||
sqlite | ||
gnumake | ||
tcl | ||
python3 | ||
nodejs | ||
toolchain | ||
] ++ lib.optionals pkgs.stdenv.isDarwin [ | ||
apple-sdk | ||
]; | ||
}; | ||
} | ||
); | ||
}; | ||
} |