about summary refs log tree commit diff stats
path: root/rust/flake.nix
diff options
context:
space:
mode:
authorSoispha <soispha@vhack.eu>2023-05-27 16:47:17 +0200
committerSoispha <soispha@vhack.eu>2023-05-27 16:47:17 +0200
commit1f263a83a6f7d7dd1898326b04b2491b78e845b1 (patch)
treee56f9e121b8d904033fc9b21065ab0c9b242fb74 /rust/flake.nix
parentChore: Initial Commit (diff)
downloadflake-templates-1f263a83a6f7d7dd1898326b04b2491b78e845b1.tar.gz
flake-templates-1f263a83a6f7d7dd1898326b04b2491b78e845b1.zip
Feat(rust): Update
Diffstat (limited to 'rust/flake.nix')
-rw-r--r--rust/flake.nix87
1 files changed, 87 insertions, 0 deletions
diff --git a/rust/flake.nix b/rust/flake.nix
new file mode 100644
index 0000000..e68d2d8
--- /dev/null
+++ b/rust/flake.nix
@@ -0,0 +1,87 @@
+{
+  description = "<app_description>"; # TODO
+
+  inputs = {
+    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
+
+    # inputs for following
+    systems = {
+      url = "github:nix-systems/x86_64-linux"; # only evaluate for this system
+    };
+    flake-compat = {
+      url = "github:edolstra/flake-compat";
+      flake = false;
+    };
+    crane = {
+      url = "github:ipetkov/crane";
+      inputs = {
+        nixpkgs.follows = "nixpkgs";
+        flake-compat.follows = "flake-compat";
+        flake-utils.follows = "flake-utils";
+        rust-overlay.follows = "rust-overlay";
+      };
+    };
+    flake-utils = {
+      url = "github:numtide/flake-utils";
+      inputs = {
+        systems.follows = "systems";
+      };
+    };
+    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)];
+      };
+
+      #rust-nightly = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default);
+      rust-stable = pkgs.rust-bin.stable.latest.default;
+
+      craneLib = (crane.mkLib pkgs).overrideToolchain rust-stable;
+
+      craneBuild = craneLib.buildPackage {
+        src = craneLib.cleanCargoSource ./.;
+
+        doCheck = true;
+      };
+    in {
+      packages.default = craneBuild;
+
+      app.default = {
+        type = "app";
+        program = "${self.packages.${system}.default}/bin/<app_name>"; # TODO
+      };
+
+      devShells.default = pkgs.mkShell {
+        packages = with pkgs; [
+          nil
+          alejandra
+          statix
+          ltex-ls
+          cocogitto
+
+          rust-stable
+          rust-analyzer
+          cargo-edit
+        ];
+      };
+    });
+}
+# vim: ts=2
+