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 | |
parent | ref(tools/python): make mypy happy (diff) | |
download | world-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')
-rw-r--r-- | templates/default.nix | 6 | ||||
-rw-r--r-- | templates/rust/.envrc | 1 | ||||
-rw-r--r-- | templates/rust/.github/dependabot.yml | 11 | ||||
-rw-r--r-- | templates/rust/.github/workflows/build.yml | 73 | ||||
-rw-r--r-- | templates/rust/LICENSE | 20 | ||||
-rw-r--r-- | templates/rust/flake.nix | 66 | ||||
-rw-r--r-- | templates/rust/rust-toolchain.toml | 3 | ||||
-rw-r--r-- | templates/rust/rustfmt.toml | 1 |
8 files changed, 181 insertions, 0 deletions
diff --git a/templates/default.nix b/templates/default.nix new file mode 100644 index 0000000..38c4877 --- /dev/null +++ b/templates/default.nix @@ -0,0 +1,6 @@ +{ + rust = { + description = "Simple rust package"; + path = ./rust; + }; +} diff --git a/templates/rust/.envrc b/templates/rust/.envrc new file mode 100644 index 0000000..a5dbbcb --- /dev/null +++ b/templates/rust/.envrc @@ -0,0 +1 @@ +use flake . diff --git a/templates/rust/.github/dependabot.yml b/templates/rust/.github/dependabot.yml new file mode 100644 index 0000000..2b2ebcf --- /dev/null +++ b/templates/rust/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +updates: +- package-ecosystem: cargo + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 +- package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/templates/rust/.github/workflows/build.yml b/templates/rust/.github/workflows/build.yml new file mode 100644 index 0000000..f449190 --- /dev/null +++ b/templates/rust/.github/workflows/build.yml @@ -0,0 +1,73 @@ +name: gh-ssh-keys CI + +on: + push: + +jobs: + check: + name: Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: actions-rs/cargo@v1 + with: + command: check + - uses: actions-rs/cargo@v1 + with: + command: check + args: --no-default-features + + test: + name: Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: actions-rs/cargo@v1 + with: + command: test + - uses: actions-rs/cargo@v1 + with: + command: test + args: --no-default-features + + fmt: + name: Rustfmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - run: rustup component add rustfmt + - uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - run: rustup component add clippy + - uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D warnings diff --git a/templates/rust/LICENSE b/templates/rust/LICENSE new file mode 100644 index 0000000..ac375e1 --- /dev/null +++ b/templates/rust/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2022 Franck Cuny + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 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}; + }; + }; +} diff --git a/templates/rust/rust-toolchain.toml b/templates/rust/rust-toolchain.toml new file mode 100644 index 0000000..e7ae097 --- /dev/null +++ b/templates/rust/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.64.0" +components = [ "rustfmt", "clippy" ] diff --git a/templates/rust/rustfmt.toml b/templates/rust/rustfmt.toml new file mode 100644 index 0000000..3a26366 --- /dev/null +++ b/templates/rust/rustfmt.toml @@ -0,0 +1 @@ +edition = "2021" |