diff --git a/flake.nix b/flake.nix index 3440ba5..668d493 100644 --- a/flake.nix +++ b/flake.nix @@ -7,6 +7,10 @@ path = ./base-flake; description = "An empty flake for each default system"; }; + rust-flake = { + path = ./rust-flake; + description = "Flake to develop, build and run a rust application"; + }; }; defaultTemplate = self.templates.base-flake; }; diff --git a/rust-flake/.envrc b/rust-flake/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/rust-flake/.envrc @@ -0,0 +1 @@ +use flake diff --git a/rust-flake/flake.nix b/rust-flake/flake.nix new file mode 100644 index 0000000..7be1d0b --- /dev/null +++ b/rust-flake/flake.nix @@ -0,0 +1,31 @@ +{ + inputs = { + nixpkgs.url = github:NixOS/nixpkgs/nixpkgs-unstable; + utils.url = github:numtide/flake-utils; + }; + + outputs = { self, nixpkgs, utils }: + utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + cargoToml = with builtins; (fromTOML (readFile ./dexios/Cargo.toml)); + in + { + packages.default = pkgs.rustPlatform.buildRustPackage { + inherit (cargoToml.package) name version; + src = nixpkgs.lib.cleanSource ./.; + doCheck = true; + cargoLock.lockFile = ./Cargo.lock; + }; + + apps.default = utils.lib.mkApp { + inherit (cargoToml.package) name; + drv = packages.default; + }; + + devShell = with pkgs; mkShell { + packages = [ cargo rustc rustfmt clippy rust-analyzer ]; + RUST_SRC_PATH = rustPlatform.rustLibSrc; + }; + }); +}