diff options
author | Soispha <soispha@vhack.eu> | 2023-05-27 16:45:31 +0200 |
---|---|---|
committer | Soispha <soispha@vhack.eu> | 2023-05-27 16:45:31 +0200 |
commit | be36f2c7e68ca0a7f555b24316aaa6340769171d (patch) | |
tree | d8137c12f8602c1218f78f47dfaaf21f6b792d43 /rust/toolchain.nix | |
download | flake-templates-be36f2c7e68ca0a7f555b24316aaa6340769171d.tar.gz flake-templates-be36f2c7e68ca0a7f555b24316aaa6340769171d.zip |
Chore: Initial Commit
Diffstat (limited to 'rust/toolchain.nix')
-rw-r--r-- | rust/toolchain.nix | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/rust/toolchain.nix b/rust/toolchain.nix new file mode 100644 index 0000000..5fdb336 --- /dev/null +++ b/rust/toolchain.nix @@ -0,0 +1,57 @@ +{ + description = "Build a cargo project with a custom toolchain"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + + crane = { + url = "github:ipetkov/crane"; + inputs = { + inputs.nixpkgs.follows = "nixpkgs"; + flake-utils.follows = "flake-utils"; + }; + }; + + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs = { + nixpkgs.follows = "nixpkgs"; + flake-utils.follows = "flake-utils"; + }; + }; + }; + + outputs = { + self, + nixpkgs, + crane, + flake-utils, + rust-overlay, + ... + }: + flake-utils.lib.eachDefaultSystem (system: let + pkgs = import nixpkgs { + inherit system; + overlays = [(import rust-overlay)]; + }; + + craneLib = (crane.mkLib pkgs).overrideToolchain (pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default)); # TODO select toolchain + + craneBuild = craneLib.buildPackage { + src = craneLib.cleanCargoSource ./.; + + doCheck = true; + }; + appName = ""; # TODO fill + in { + packages.default = craneBuild; + + app.default = { + type = "app"; + program = "${self.packages.${system}.default}/bin/${appName}"; + }; + }); +} +# vim: ts=2 + |