diff --git a/flake.nix b/flake.nix index b2418bd..2f1f9e3 100644 --- a/flake.nix +++ b/flake.nix @@ -42,6 +42,8 @@ program = "${helix}/bin/hx"; }; }); + + templates = import ./templates; }; inputs = { # Unstable nixpkgs baby! diff --git a/templates/default.nix b/templates/default.nix new file mode 100644 index 0000000..0dea28b --- /dev/null +++ b/templates/default.nix @@ -0,0 +1,6 @@ +{ + rust = { + path = ./rust; + description = "Rust project template"; + }; +} diff --git a/templates/rust/.envrc b/templates/rust/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/templates/rust/.envrc @@ -0,0 +1 @@ +use flake diff --git a/templates/rust/Cargo.toml b/templates/rust/Cargo.toml new file mode 100644 index 0000000..892d1eb --- /dev/null +++ b/templates/rust/Cargo.toml @@ -0,0 +1,5 @@ +[package] +name = "sample-rust" +version = "0.0.1" +license = "GPL-3.0-only" +edition = "2024" diff --git a/templates/rust/default.nix b/templates/rust/default.nix new file mode 100644 index 0000000..69ea5e5 --- /dev/null +++ b/templates/rust/default.nix @@ -0,0 +1,8 @@ +{rustPlatform}: +rustPlatform.buildRustPackage { + pname = "some-rust-package"; + version = "0.0.1"; + + src = ./.; + cargoLock.lockFile = ./Cargo.lock; +} diff --git a/templates/rust/flake.nix b/templates/rust/flake.nix new file mode 100644 index 0000000..738ae57 --- /dev/null +++ b/templates/rust/flake.nix @@ -0,0 +1,35 @@ +{ + description = "Rust project template"; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + systems.url = "github:nix-systems/default-linux"; + }; + + outputs = inputs: let + inherit (inputs.nixpkgs) lib; + inherit (lib.attrsets) genAttrs mapAttrs; + + eachSystem = genAttrs (import inputs.systems); + pkgsFor = inputs.nixpkgs.legacyPackages; + in { + packages = eachSystem (system: { + default = inputs.self.packages.${system}.ralc; + ralc = pkgsFor.${system}.callPackage ./nix/package.nix {}; + }); + + devShells = + mapAttrs (system: pkgs: { + default = pkgs.mkShell { + packages = with pkgs; [ + cargo + rustc + rustfmt + bacon + rust-analyzer + rustPackages.clippy + ]; + }; + }) + pkgsFor; + }; +} diff --git a/templates/rust/src/main.rs b/templates/rust/src/main.rs new file mode 100644 index 0000000..47ad8c6 --- /dev/null +++ b/templates/rust/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello World!"); +}