From 65994d5b50b94d7b172fff217ad5facd82ce2722 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Tue, 15 Nov 2022 18:13:29 -0800 Subject: meta: initial commit! --- .drone.yml | 32 ++++++++++ .envrc | 1 + .gitignore | 2 + Cargo.lock | 7 +++ Cargo.toml | 8 +++ LICENSE | 20 +++++++ deny.toml | 46 ++++++++++++++ flake.lock | 170 ++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 104 ++++++++++++++++++++++++++++++++ rust-toolchain.toml | 3 + rustfmt.toml | 1 + src/main.rs | 3 + 12 files changed, 397 insertions(+) create mode 100644 .drone.yml create mode 100644 .envrc create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 LICENSE create mode 100644 deny.toml create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 rust-toolchain.toml create mode 100644 rustfmt.toml create mode 100644 src/main.rs diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..b2a6ca4 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,32 @@ +kind: pipeline +type: docker +name: checks + +trigger: + event: + - push + - pull_request + +steps: + - name: Run checks + image: nixpkgs/nix-flakes:nixos-22.05 + commands: + - nix develop --command cargo fmt --check + - nix develop --command cargo deny check + - nix develop --command cargo clippy -- -D warnings +--- +kind: pipeline +type: docker +name: build + +trigger: + event: + - push + - pull_request + +steps: + - name: Run tests and build + image: nixpkgs/nix-flakes:nixos-22.05 + commands: + - nix develop --command cargo test + - nix build . diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..a5dbbcb --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake . diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2e556bb --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +/.pre-commit-config.yaml diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..7c1c56c --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "sendsms" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..6f3365d --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "sendsms" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ac375e1 --- /dev/null +++ b/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/deny.toml b/deny.toml new file mode 100644 index 0000000..fd95cdb --- /dev/null +++ b/deny.toml @@ -0,0 +1,46 @@ +[advisories] +db-path = "~/.cargo/advisory-db" +db-urls = ["https://github.com/rustsec/advisory-db"] +vulnerability = "deny" +unmaintained = "warn" +yanked = "warn" +notice = "warn" +ignore = [] + +[licenses] +unlicensed = "deny" +allow = ["MIT", "Apache-2.0", "ISC", "Unicode-DFS-2016", "OpenSSL"] +deny = [] +copyleft = "allow" +default = "deny" +confidence-threshold = 0.8 +exceptions = [] + +[licenses.private] +ignore = false +registries = [] + +# see https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html#example +[[licenses.clarify]] +name = "ring" +expression = "MIT AND ISC AND OpenSSL" +license-files = [ + { path = "LICENSE", hash = 0xbd0eed23 } +] + +[bans] +multiple-versions = "warn" +wildcards = "allow" +highlight = "all" +allow = [] +deny = [] +skip = [] +skip-tree = [] + +[sources] +unknown-registry = "warn" +unknown-git = "warn" +allow-registry = ["https://github.com/rust-lang/crates.io-index"] +allow-git = [] + +[sources.allow-org] diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..a32d1ed --- /dev/null +++ b/flake.lock @@ -0,0 +1,170 @@ +{ + "nodes": { + "crane": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ], + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1668047118, + "narHash": "sha256-F4xP7dAU6ca+hYa3qF0CtnwfQJT3YH4qEh/IxO+p9t0=", + "owner": "ipetkov", + "repo": "crane", + "rev": "074825a9e8d6446564e2ae6949ac3feb79aa7397", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1650374568, + "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1668563542, + "narHash": "sha256-FrMNezX3v4qLkCg+j1e3Ei/FXOSQP4Chq4OOdttIEns=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ce89321950381ec845e56c6a6d1340abe5cd7a65", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1667992213, + "narHash": "sha256-8Ens8ozllvlaFMCZBxg6S7oUyynYx2v7yleC5M0jJsE=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "ebcbfe09d2bd6d15f68de3a0ebb1e4dcb5cd324b", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "crane": "crane", + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks", + "rust-overlay": "rust-overlay_2" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "crane", + "flake-utils" + ], + "nixpkgs": [ + "crane", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1667487142, + "narHash": "sha256-bVuzLs1ZVggJAbJmEDVO9G6p8BH3HRaolK70KXvnWnU=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "cf668f737ac986c0a89e83b6b2e3c5ddbd8cf33b", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "rust-overlay_2": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1668479979, + "narHash": "sha256-UI+JUCBaMpn+5Y1hSePmndbYX5zu0+bavlfzrhPrGEk=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "2342f70f7257046effc031333c4cfdea66c91d82", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..5b453f2 --- /dev/null +++ b/flake.nix @@ -0,0 +1,104 @@ +{ + description = "A CLI to send SMS with pre-determined messages SMS with pre-determined messa SMS with pre-determine."; + + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:NixOS/nixpkgs"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs = { + flake-utils.follows = "flake-utils"; + nixpkgs.follows = "nixpkgs"; + }; + }; + crane = { + url = "github:ipetkov/crane"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + pre-commit-hooks = { + url = "github:cachix/pre-commit-hooks.nix"; + inputs = { + flake-utils.follows = "flake-utils"; + nixpkgs.follows = "nixpkgs"; + }; + }; + }; + + outputs = + { self + , flake-utils + , nixpkgs + , rust-overlay + , crane + , pre-commit-hooks + }: + + flake-utils.lib.eachDefaultSystem + (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ (import rust-overlay) ]; + }; + rust-toolchain = (pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml).override { + extensions = [ "rust-src" ]; + }; + + craneLib = (crane.mkLib pkgs).overrideScope' (_: _: { + cargo = rust-toolchain; + clippy = rust-toolchain; + rustc = rust-toolchain; + rustfmt = rust-toolchain; + }); + + src = ./.; + + cargoArtifacts = craneLib.buildDepsOnly { + inherit src; + }; + + my-crate = craneLib.buildPackage { + inherit cargoArtifacts src; + }; + in + { + packages.default = my-crate; + apps.default = flake-utils.lib.mkApp { + drv = my-crate; + }; + + checks = { + pre-commit = pre-commit-hooks.lib.${system}.run { + inherit src; + hooks = { + clippy = { + enable = true; + entry = pkgs.lib.mkForce "cargo clippy -- -D warnings"; + }; + nixpkgs-fmt = { + enable = true; + }; + rustfmt = { + enable = true; + entry = pkgs.lib.mkForce "cargo fmt -- --check --color always"; + }; + }; + }; + }; + + devShell = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + rust-toolchain + cargo-deny + rust-analyzer + ]; + + inherit (self.checks.${system}.pre-commit) shellHook; + }; + }) + // { + overlay = final: prev: { + sendsms = self.defaultPackage.${prev.system}.default; + }; + }; +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..e7ae097 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.64.0" +components = [ "rustfmt", "clippy" ] diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..3a26366 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1 @@ +edition = "2021" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} -- cgit v1.2.3