-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
231 additions
and
4 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
watch_file nix | ||
|
||
use flake |
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,3 +1,4 @@ | ||
target | ||
|
||
/.env | ||
|
||
/.direnv |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
inputs = { | ||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixpkgs-unstable"; | ||
flake-parts.url = "github:hercules-ci/flake-parts"; | ||
fenix.url = "github:nix-community/fenix"; | ||
fenix.inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
|
||
outputs = | ||
inputs@{ flake-parts, ... }: | ||
flake-parts.lib.mkFlake { inherit inputs; } { | ||
systems = [ | ||
"aarch64-linux" | ||
"aarch64-darwin" | ||
"x86_64-linux" | ||
]; | ||
perSystem = { | ||
imports = [ | ||
./nix/devshells.nix | ||
./nix/packages.nix | ||
]; | ||
}; | ||
}; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,97 @@ | ||
{ | ||
inputs', | ||
pkgs, | ||
lib, | ||
... | ||
}: | ||
|
||
let | ||
fenix = inputs'.fenix.packages; | ||
|
||
# creates list of components taken from a toolchain for given channel | ||
rustComponents = | ||
channel: | ||
[ | ||
"rustc" | ||
"cargo" | ||
"clippy" | ||
"rustfmt" | ||
] | ||
++ lib.optionals (channel == "stable") [ | ||
"rust-analyzer" | ||
]; | ||
|
||
# creates list of the extra targets to be installed for given channel | ||
rustExtraTargets = | ||
channel: | ||
[ | ||
"wasm32-unknown-unknown" | ||
] | ||
++ lib.optionals (channel == "stable") [ | ||
# android | ||
"aarch64-linux-android" | ||
"armv7-linux-androideabi" | ||
"x86_64-linux-android" | ||
"i686-linux-android" | ||
# ios | ||
"aarch64-apple-ios" | ||
"aarch64-apple-ios-sim" | ||
]; | ||
|
||
# creates toolchain configuration for given channel | ||
rustToolchain = | ||
channel: | ||
fenix.combine [ | ||
# components | ||
(fenix."${channel}".withComponents (rustComponents channel)) | ||
# extra targets | ||
(lib.lists.map (target: fenix.targets."${target}"."${channel}".rust-std) (rustExtraTargets channel)) | ||
]; | ||
|
||
# wrapper for cargo to allow `+channel` syntax | ||
cargoWrapper = pkgs.writeShellScriptBin "cargo" '' | ||
case "$1" in | ||
"+stable") | ||
shift | ||
exec env PATH="${rustToolchain "stable"}/bin:$PATH" cargo "$@" | ||
;; | ||
"+nightly") | ||
shift | ||
exec env PATH="${rustToolchain "latest"}/bin:$PATH" cargo "$@" | ||
;; | ||
"+"*) | ||
echo "Channel $1 not installed. You may need to add it to the devShell" >&2 | ||
exit 1 | ||
;; | ||
*) | ||
exec env PATH="${rustToolchain "stable"}/bin:$PATH" cargo "$@" | ||
;; | ||
esac | ||
''; | ||
in | ||
{ | ||
devShells.default = pkgs.mkShell { | ||
packages = with pkgs; [ | ||
# c/gnu base | ||
gnumake | ||
pkg-config | ||
stdenv | ||
|
||
# rust - toolchain | ||
cargoWrapper # first in PATH, to be invoked instead one from toolchain | ||
(rustToolchain "stable") | ||
# rust - wasm | ||
binaryen # wasm-opt | ||
wasm-bindgen-cli_0_2_100 | ||
wasm-pack | ||
# rust - other | ||
cargo-edit | ||
cargo-ndk | ||
cargo-udeps | ||
|
||
# javascript | ||
nodejs | ||
nodePackages.typescript-language-server | ||
]; | ||
}; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ ... }: | ||
|
||
{ | ||
packages.default = { }; | ||
} |