diff options
| author | Franck Cuny <franck@fcuny.net> | 2022-10-22 11:16:47 -0700 |
|---|---|---|
| committer | Franck Cuny <franck@fcuny.net> | 2022-10-22 11:19:10 -0700 |
| commit | e787305ee978b5939f67dcea33593bc931a544aa (patch) | |
| tree | d4ec9d2b8072c72dfd4e20eb4b717fb3905c2536 /templates/rust/flake.nix | |
| parent | ref(tools/python): make mypy happy (diff) | |
| download | infra-e787305ee978b5939f67dcea33593bc931a544aa.tar.gz | |
feat(templates): add a template for rust
To use it, run:
```
nix flake init -t github:fcuny/world#rust
```
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}; + }; + }; +} |
