aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.org5
-rw-r--r--flake.nix2
-rw-r--r--templates/default.nix6
-rw-r--r--templates/rust/.envrc1
-rw-r--r--templates/rust/.github/dependabot.yml11
-rw-r--r--templates/rust/.github/workflows/build.yml73
-rw-r--r--templates/rust/LICENSE20
-rw-r--r--templates/rust/flake.nix66
-rw-r--r--templates/rust/rust-toolchain.toml3
-rw-r--r--templates/rust/rustfmt.toml1
10 files changed, 188 insertions, 0 deletions
diff --git a/README.org b/README.org
index 9e59a75..41f6342 100644
--- a/README.org
+++ b/README.org
@@ -20,3 +20,8 @@ To update the flakes:
#+begin_src sh
nix flake update
#+end_src
+* templates
+To use one of the template, run:
+#+begin_src sh
+nix flake init -t github:fcuny/world#rust
+#+end_src
diff --git a/flake.nix b/flake.nix
index e7fff1b..0861a89 100644
--- a/flake.nix
+++ b/flake.nix
@@ -65,6 +65,8 @@
});
in
{
+ templates = import ./templates;
+
checks = forAllSystems (system:
let pkgs = nixpkgsFor.${system};
in
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"