From 95fe298ae13d85c5093b82d773f01ab2ef6cd0f6 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Fri, 22 Nov 2024 22:40:17 +0000 Subject: [PATCH] git: project setup Signed-off-by: Brendan Golden --- .gitattributes | 37 ++++++++++++++++++ .gitignore | 15 ++++++++ .rustfmt.toml | 9 +++++ Cargo.lock | 7 ++++ Cargo.toml | 6 +++ flake.lock | 93 +++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 61 +++++++++++++++++++++++++++++ rust-toolchain.toml | 2 + src/lib.rs | 14 +++++++ 9 files changed, 244 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 .rustfmt.toml 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/lib.rs diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6c7adef --- /dev/null +++ b/.gitattributes @@ -0,0 +1,37 @@ +# Git config here +* text eol=lf + +############################################# +# Git lfs stuff +# Documents +*.pdf filter=lfs diff=lfs merge=lfs -text +*.doc filter=lfs diff=lfs merge=lfs -text +*.docx filter=lfs diff=lfs merge=lfs -text +# Excel +*.xls filter=lfs diff=lfs merge=lfs -text +*.xlsx filter=lfs diff=lfs merge=lfs -text +*.xlsm filter=lfs diff=lfs merge=lfs -text +# Powerpoints +*.ppt filter=lfs diff=lfs merge=lfs -text +*.pptx filter=lfs diff=lfs merge=lfs -text +*.ppsx filter=lfs diff=lfs merge=lfs -text +# Images +*.png filter=lfs diff=lfs merge=lfs -text +*.jpg filter=lfs diff=lfs merge=lfs -text +# Video +*.mkv filter=lfs diff=lfs merge=lfs -text +*.mp4 filter=lfs diff=lfs merge=lfs -text +*.wmv filter=lfs diff=lfs merge=lfs -text +# Misc +*.zip filter=lfs diff=lfs merge=lfs -text +# ET4011 +*.cbe filter=lfs diff=lfs merge=lfs -text +*.pbs filter=lfs diff=lfs merge=lfs -text +# Open/Libre office +# from https://www.libreoffice.org/discover/what-is-opendocument/ +*.odt filter=lfs diff=lfs merge=lfs -text +*.ods filter=lfs diff=lfs merge=lfs -text +*.odp filter=lfs diff=lfs merge=lfs -text +*.odg filter=lfs diff=lfs merge=lfs -text +# QT +*.ui filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f3cc8d --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +/target +/.idea + +.env +*.env + +result +/result + +*.db +*.db.* + +tmp/ +tmp.* +*.csv diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 0000000..b8ae8dd --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1,9 @@ +max_width = 150 +single_line_if_else_max_width = 100 +chain_width = 100 +fn_params_layout = "Compressed" +#control_brace_style = "ClosingNextLine" +#brace_style = "PreferSameLine" +struct_lit_width = 0 +tab_spaces = 2 +use_small_heuristics = "Max" \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..f88efa0 --- /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 = "wolves-oxidised" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..79b9324 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "wolves-oxidised" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..3b1079c --- /dev/null +++ b/flake.lock @@ -0,0 +1,93 @@ +{ + "nodes": { + "naersk": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1721727458, + "narHash": "sha256-r/xppY958gmZ4oTfLiHN0ZGuQ+RSTijDblVgVLFi1mw=", + "owner": "nix-community", + "repo": "naersk", + "rev": "3fb418eaf352498f6b6c30592e3beb63df42ef11", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "naersk", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1731890469, + "narHash": "sha256-D1FNZ70NmQEwNxpSSdTXCSklBH1z2isPR84J6DQrJGs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5083ec887760adfe12af64830a66807423a859a7", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1732014248, + "narHash": "sha256-y/MEyuJ5oBWrWAic/14LaIr/u5E0wRVzyYsouYY3W6w=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "23e89b7da85c3640bbc2173fe04f4bd114342367", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, + "root": { + "inputs": { + "naersk": "naersk", + "nixpkgs": "nixpkgs_2", + "utils": "utils" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..be454f5 --- /dev/null +++ b/flake.nix @@ -0,0 +1,61 @@ +{ + description = "UL Wolves API Library"; + + inputs = { + nixpkgs.url = "nixpkgs/nixos-unstable"; + naersk.url = "github:nix-community/naersk"; + utils.url = "github:numtide/flake-utils"; + }; + + nixConfig = { + extra-substituters = "https://nix-cache.skynet.ie/skynet-cache"; + extra-trusted-public-keys = "skynet-cache:zMFLzcRZPhUpjXUy8SF8Cf7KGAZwo98SKrzeXvdWABo="; + }; + + outputs = { + self, + nixpkgs, + utils, + naersk, + }: + utils.lib.eachDefaultSystem ( + system: let + pkgs = (import nixpkgs) {inherit system;}; + naersk' = pkgs.callPackage naersk {}; + package_name = "wolves_api"; + buildInputs = with pkgs; [ + openssl + pkg-config + rustfmt + ]; + in rec { + packages = { + # For `nix build` & `nix run`: + default = naersk'.buildPackage { + pname = "${package_name}"; + src = ./.; + buildInputs = buildInputs; + }; + # Run `nix build .#fmt` to run tests + fmt = naersk'.buildPackage { + src = ./.; + mode = "fmt"; + buildInputs = buildInputs; + }; + # Run `nix build .#clippy` to lint code + clippy = naersk'.buildPackage { + src = ./.; + mode = "clippy"; + buildInputs = buildInputs; + }; + }; + + # `nix develop` + devShell = pkgs.mkShell { + nativeBuildInputs = ( + with pkgs; [rustc cargo] + ) ++ buildInputs; + }; + } + ); +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..76fcadb --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "1.82" diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..b93cf3f --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: u64, right: u64) -> u64 { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +}