From 48069f95e21825493359211bd14fcd7792a24e96 Mon Sep 17 00:00:00 2001 From: Callum Leslie Date: Tue, 10 Sep 2024 18:21:24 +0100 Subject: [PATCH] initial commit --- .envrc | 2 + .gitignore | 2 + Cargo.lock | 7 +++ Cargo.toml | 6 +++ flake.lock | 115 ++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 76 +++++++++++++++++++++++++++++ rust-toolchain.toml | 2 + src/main.rs | 1 + 8 files changed, 211 insertions(+) create mode 100644 .envrc create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 rust-toolchain.toml create mode 100644 src/main.rs diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..de26198 --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +watch_file rust-toolchain.toml +use flake diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..07c12f2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +result diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..2b0b6bf --- /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 = "nish" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..46011cc --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "nish" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..a63ca0f --- /dev/null +++ b/flake.lock @@ -0,0 +1,115 @@ +{ + "nodes": { + "advisory-db": { + "flake": false, + "locked": { + "lastModified": 1725883717, + "narHash": "sha256-QifFNLfu5bzKPO4iznCj1h+nHhqGZ8NR2Lo7tzh9FRc=", + "owner": "rustsec", + "repo": "advisory-db", + "rev": "7fbf1e630ae52b7b364791a107b5bee5ff929496", + "type": "github" + }, + "original": { + "owner": "rustsec", + "repo": "advisory-db", + "type": "github" + } + }, + "crane": { + "locked": { + "lastModified": 1725409566, + "narHash": "sha256-PrtLmqhM6UtJP7v7IGyzjBFhbG4eOAHT6LPYOFmYfbk=", + "owner": "ipetkov", + "repo": "crane", + "rev": "7e4586bad4e3f8f97a9271def747cf58c4b68f3c", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1725634671, + "narHash": "sha256-v3rIhsJBOMLR8e/RNWxr828tB+WywYIoajrZKFM+0Gg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "574d1eac1c200690e27b8eb4e24887f8df7ac27c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "advisory-db": "advisory-db", + "crane": "crane", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1725935143, + "narHash": "sha256-mVtTVQMlXkydSXVwFClE0ckxHrOQ9nb2DrCjNwW5pUE=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "c3c175c74cd0e8c2c40a0e22bc6e3005c4d28d64", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..3bbcaa0 --- /dev/null +++ b/flake.nix @@ -0,0 +1,76 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + crane.url = "github:ipetkov/crane"; + + advisory-db = { + url = "github:rustsec/advisory-db"; + flake = false; + }; + }; + outputs = { + self, + nixpkgs, + flake-utils, + rust-overlay, + crane, + advisory-db, + }: + flake-utils.lib.eachDefaultSystem + ( + system: let + overlays = [(import rust-overlay)]; + pkgs = import nixpkgs { + inherit system overlays; + }; + + rustToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; + src = craneLib.cleanCargoSource ./.; + + nativeBuildInputs = with pkgs; [rustToolchain pkg-config]; + buildInputs = with pkgs; [udev]; + + commonArgs = { + inherit src buildInputs nativeBuildInputs; + }; + + cargoArtifacts = craneLib.buildDepsOnly commonArgs; + bin = craneLib.buildPackage (commonArgs // {inherit cargoArtifacts;}); + in + with pkgs; { + checks = { + inherit bin; + clippy = craneLib.cargoClippy (commonArgs + // { + inherit cargoArtifacts; + cargoClippyExtraArgs = "--all-targets -- --deny warnings"; + }); + coverage = craneLib.cargoTarpaulin (commonArgs // {inherit cargoArtifacts;}); + fmt = craneLib.cargoFmt {inherit src;}; + audit = craneLib.cargoAudit { + inherit src advisory-db; + }; + }; + + packages = { + default = bin; + }; + + apps = rec { + default = flake-utils.lib.mkApp {drv = bin;}; + }; + + devShells.default = craneLib.devShell { + checks = self.checks.${system}; + packages = []; + }; + } + ); +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..292fe49 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "stable" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..f328e4d --- /dev/null +++ b/src/main.rs @@ -0,0 +1 @@ +fn main() {}