summaryrefslogtreecommitdiff
path: root/common/templates/rust/flake.nix
diff options
context:
space:
mode:
Diffstat (limited to 'common/templates/rust/flake.nix')
-rw-r--r--common/templates/rust/flake.nix50
1 files changed, 50 insertions, 0 deletions
diff --git a/common/templates/rust/flake.nix b/common/templates/rust/flake.nix
new file mode 100644
index 0000000..afe2601
--- /dev/null
+++ b/common/templates/rust/flake.nix
@@ -0,0 +1,50 @@
+{
+ inputs = {
+ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
+ naersk.url = "github:nix-community/naersk";
+ naersk.inputs.nixpkgs.follows = "nixpkgs";
+ };
+
+ outputs =
+ {
+ self,
+ nixpkgs,
+ naersk,
+ ...
+ }:
+ let
+ inherit (nixpkgs) lib;
+ forAllSystems = lib.genAttrs lib.systems.flakeExposed;
+ in
+ {
+ devShells = forAllSystems (
+ system:
+ let
+ pkgs = nixpkgs.legacyPackages.${system};
+ in
+ {
+ default = pkgs.mkShell {
+ buildInputs = with pkgs; [
+ cargo
+ clippy
+ rustc
+ rustfmt
+ rust-analyzer
+ ];
+ RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc;
+ };
+ }
+ );
+
+ packages = forAllSystems (
+ system:
+ let
+ pkgs = nixpkgs.legacyPackages.${system};
+ naersk-lib = pkgs.callPackage naersk { };
+ in
+ {
+ default = naersk-lib.buildPackage self;
+ }
+ );
+ };
+}