diff options
Diffstat (limited to 'templates/rust/flake.nix')
-rw-r--r-- | templates/rust/flake.nix | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/templates/rust/flake.nix b/templates/rust/flake.nix new file mode 100644 index 0000000..49c2f76 --- /dev/null +++ b/templates/rust/flake.nix @@ -0,0 +1,66 @@ +{ + description = "A CLI to manage public SSH keys for GitHub."; + + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:NixOS/nixpkgs"; + rust-overlay.url = "github:oxalica/rust-overlay"; + naersk.url = "github:nmattia/naersk"; + }; + + outputs = + { self + , flake-utils + , nixpkgs + , naersk + , rust-overlay + }: + + flake-utils.lib.eachDefaultSystem + (system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { inherit system overlays; }; + rust-toolchain = + (pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml).override { + extensions = [ "rust-src" ]; + }; + naersk-lib = naersk.lib."${system}".override { + rustc = rust-toolchain; + }; + in + rec + { + packages.gh-ssh-keys = naersk-lib.buildPackage { + pname = "gh-ssh-keys"; + root = ./.; + buildInputs = with pkgs; [ + pkg-config + openssl + ]; + }; + + defaultPackage = packages.gh-ssh-keys; + + devShell = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + rust-toolchain + openssl + pkg-config + cargo-audit + cargo-deny + cargo-cross + rust-analyzer + ] ++ pkgs.lib.optionals (pkgs.stdenv.isLinux) (with pkgs; [ cargo-watch ]); + + shellHook = '' + cargo --version + ''; + }; + }) + // { + overlay = final: prev: { + gh-ssh-keys = self.defaultPackage.${prev.system}; + }; + }; +} |