diff --git a/flake.nix b/flake.nix index 27db015..e2f6866 100644 --- a/flake.nix +++ b/flake.nix @@ -70,5 +70,6 @@ lib = self-lib; overlays.default = import ./overlay { inherit flake self inputs nixpkgs; }; nixosModules = import ./nixos/module { inherit flake self inputs nixpkgs; }; + templates = import ./template { inherit flake self inputs nixpkgs; }; }; } diff --git a/template/default.nix b/template/default.nix new file mode 100644 index 0000000..d394780 --- /dev/null +++ b/template/default.nix @@ -0,0 +1,6 @@ +{ ... }: { + rust = { + path = ./rust; + description = "rust dev flake template"; + }; +} diff --git a/template/rust/devshell/default.nix b/template/rust/devshell/default.nix new file mode 100644 index 0000000..4d947d3 --- /dev/null +++ b/template/rust/devshell/default.nix @@ -0,0 +1,14 @@ +{ pkgs }: let + dev-help = pkgs.writeShellScriptBin "dev-help" /* sh */ '' + printf '%s\n' \ + 'phph' + ''; + rustToolchain = pkgs.pkgsBuildHost.rust-bin.stable."1.87.0".default; +in +pkgs.mkShell { + buildInputs = [ dev-help ]; + nativeBuildInputs = [ rustToolchain pkgs.pkg-config ]; + + # environment + PAGER="${pkgs.hectic.nvim-pager}/bin/pager"; +} diff --git a/template/rust/flake.lock b/template/rust/flake.lock new file mode 100644 index 0000000..72b7c9f --- /dev/null +++ b/template/rust/flake.lock @@ -0,0 +1,109 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1754292888, + "narHash": "sha256-1ziydHSiDuSnaiPzCQh1mRFBsM2d2yRX9I+5OPGEmIE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ce01daebf8489ba97bd1609d185ea276efdeb121", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-25.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1739451785, + "narHash": "sha256-3ebRdThRic9bHMuNi2IAA/ek9b32bsy8F5R4SvGTIog=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1128e89fd5e11bb25aedbfc287733c6502202ea9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay", + "util": "util" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1754362243, + "narHash": "sha256-QHNTUdI6oIYuuazGuKGhVk5RCOM1nIzDUc/AGgL7Szw=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "3ec3244ffb877f1b7f5d2dbff19241982ab25ff2", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "rust-overlay_2": { + "inputs": { + "nixpkgs": [ + "util", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1738290352, + "narHash": "sha256-YKOHUmc0Clm4tMV8grnxYL4IIwtjTayoq/3nqk0QM7k=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "b031b584125d33d23a0182f91ddbaf3ab4880236", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "util": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-unstable": "nixpkgs-unstable", + "rust-overlay": "rust-overlay_2" + }, + "locked": { + "lastModified": 1751301064, + "narHash": "sha256-/fYo5Emc7Ahvdx2u2o+6lyQxe+ECP0808q4gI5tfAGA=", + "owner": "hectic-lab", + "repo": "util.nix", + "rev": "5e112f5df8b977c64fa026ff1bc31a47eb48ec02", + "type": "github" + }, + "original": { + "owner": "hectic-lab", + "ref": "fix/postgres-extension", + "repo": "util.nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/template/rust/flake.nix b/template/rust/flake.nix new file mode 100644 index 0000000..9ec7ee8 --- /dev/null +++ b/template/rust/flake.nix @@ -0,0 +1,34 @@ +{ + description = ""; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs = { + nixpkgs.follows = "nixpkgs"; + }; + }; + util = { + url = "github:hectic-lab/util.nix?ref=fix/postgres-extension"; + inputs = { + nixpkgs.follows = "nixpkgs"; + }; + }; + }; + + outputs = { self, nixpkgs, rust-overlay, util }: + let + overlays = [ (import rust-overlay) util.overlays.default ]; + in + util.lib.forAllSystemsWithPkgs overlays ({ system, pkgs }: + let + lib = pkgs.lib; + in + { + ### DEV SHELL ### + devShells.${system} = { + default = import ./devshell/default.nix { inherit pkgs; }; + }; + } + ); +}