aboutsummaryrefslogtreecommitdiffstats
path: root/templates/rust/flake.nix
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-03-31 17:40:13 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-03-31 23:59:56 +0200
commit8180fca7a1acd0aff84a44e53a5f66181360a216 (patch)
treeb72499eec8256c4090b8031b9eb99cff6324bb58 /templates/rust/flake.nix
parentfeat(awk): Update to my current SOTA (diff)
downloadflake-templates-8180fca7a1acd0aff84a44e53a5f66181360a216.zip
refactor(rust): Move to template dir
Diffstat (limited to 'templates/rust/flake.nix')
-rw-r--r--templates/rust/flake.nix90
1 files changed, 90 insertions, 0 deletions
diff --git a/templates/rust/flake.nix b/templates/rust/flake.nix
new file mode 100644
index 0000000..4512bed
--- /dev/null
+++ b/templates/rust/flake.nix
@@ -0,0 +1,90 @@
+{
+ 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)];
+ };
+
+ nightly = false;
+ rust_minimal =
+ if nightly
+ then pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.minimal)
+ else pkgs.rust-bin.stable.latest.minimal;
+
+ rust_default =
+ if nightly
+ then pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default)
+ else pkgs.rust-bin.stable.latest.default;
+
+ craneLib = (crane.mkLib pkgs).overrideToolchain rust_minimal;
+
+ 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; [
+ cocogitto
+
+ rust_default
+ cargo-edit
+ ];
+ };
+ });
+}
+# vim: ts=2
+