diff --git a/examples/hello-flake/.gitignore b/examples/hello-flake/.gitignore new file mode 100644 index 00000000..eb5a316c --- /dev/null +++ b/examples/hello-flake/.gitignore @@ -0,0 +1 @@ +target diff --git a/examples/hello-flake/Cargo.toml b/examples/hello-flake/Cargo.toml new file mode 100644 index 00000000..0658a981 --- /dev/null +++ b/examples/hello-flake/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "hello-flake" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/examples/hello-flake/flake.nix b/examples/hello-flake/flake.nix new file mode 100644 index 00000000..5c4f01c3 --- /dev/null +++ b/examples/hello-flake/flake.nix @@ -0,0 +1,27 @@ +{ + description = "An example devShell with flakes"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { + inherit system overlays; + }; + in + devShells.default = mkShell { + buildInputs = with pkgs; [ + rust-bin.stable.latest.default + ] + } + ); +} diff --git a/examples/hello-flake/src/main.rs b/examples/hello-flake/src/main.rs new file mode 100644 index 00000000..e7a11a96 --- /dev/null +++ b/examples/hello-flake/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/flake.nix b/flake.nix index 3b3ea13b..e2d078e6 100644 --- a/flake.nix +++ b/flake.nix @@ -51,6 +51,18 @@ # TODO: Flake outputs except `overlay[s]` are not stabilized yet. + templates = + let + hello-flake = { + path = ./examples/hello-flake; + description = "An example devShell with flakes"; + }; + in + { + default = hello-flake; + inherit hello-flake; + }; + packages = let select = version: comps: