commit a5ad583f2d9f6f8b2a332ad474cda1cc3d07c566 Author: Vinzenz Schroeter Date: Sat Feb 8 12:36:09 2025 +0100 initial commit diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..62304ee --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,35 @@ +name: Rust + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + CARGO_TERM_COLOR: always + + # Make sure CI fails on all warnings, including Clippy lints + RUSTFLAGS: "-Dwarnings" + + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Update repos + run: sudo apt-get update -qq + - name: Install rust toolchain + run: sudo apt-get install -qy cargo-1.80 rust-1.80-clippy + - name: Install system dependencies + run: sudo apt-get install -qy liblzma-dev + + - name: Run Clippy + run: cargo clippy --all-targets --all-features + + - name: Build + run: cargo build --release --verbose diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..8e5c5f8 --- /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 = "servicepoint-cli" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..1dca732 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "servicepoint-cli" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..abacd0c --- /dev/null +++ b/flake.lock @@ -0,0 +1,64 @@ +{ + "nodes": { + "naersk": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1736429655, + "narHash": "sha256-BwMekRuVlSB9C0QgwKMICiJ5EVbLGjfe4qyueyNQyGI=", + "owner": "nix-community", + "repo": "naersk", + "rev": "0621e47bd95542b8e1ce2ee2d65d6a1f887a13ce", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "naersk", + "type": "github" + } + }, + "nix-filter": { + "locked": { + "lastModified": 1731533336, + "narHash": "sha256-oRam5PS1vcrr5UPgALW0eo1m/5/pls27Z/pabHNy2Ms=", + "owner": "numtide", + "repo": "nix-filter", + "rev": "f7653272fd234696ae94229839a99b73c9ab7de0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "nix-filter", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1736549401, + "narHash": "sha256-ibkQrMHxF/7TqAYcQE+tOnIsSEzXmMegzyBWza6uHKM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "1dab772dd4a68a7bba5d9460685547ff8e17d899", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-24.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "naersk": "naersk", + "nix-filter": "nix-filter", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..f754bdd --- /dev/null +++ b/flake.nix @@ -0,0 +1,103 @@ +{ + description = "Flake for servicepoint-cli"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11"; + nix-filter.url = "github:numtide/nix-filter"; + naersk = { + url = "github:nix-community/naersk"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = + inputs@{ + self, + nixpkgs, + naersk, + nix-filter, + }: + let + lib = nixpkgs.lib; + supported-systems = [ + "x86_64-linux" + "aarch64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; + forAllSystems = + f: + lib.genAttrs supported-systems ( + system: + f rec { + pkgs = nixpkgs.legacyPackages.${system}; + inherit system; + } + ); + in + rec { + packages = forAllSystems ( + { pkgs, ... }: + let + naersk' = pkgs.callPackage naersk { }; + in + rec { + servicepoint-cli = naersk'.buildPackage rec { + src = nix-filter.lib.filter { + root = ./.; + include = [ + ./Cargo.toml + ./Cargo.lock + ./src + ./README.md + ./LICENSE + ]; + }; + nativeBuildInputs = with pkgs; [ + pkg-config + makeWrapper + ]; + strictDeps = true; + buildInputs = with pkgs; [ + xe + xz + ]; + }; + + default = servicepoint-cli; + } + ); + + legacyPackages = packages; + + devShells = forAllSystems ( + { + pkgs, + system, + }: + { + default = pkgs.mkShell rec { + inputsFrom = [ self.packages.${system}.default ]; + packages = [ + pkgs.gdb + (pkgs.symlinkJoin { + name = "rust-toolchain"; + paths = with pkgs; [ + rustc + cargo + rustPlatform.rustcSrc + rustfmt + clippy + cargo-expand + ]; + }) + ]; + LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath (builtins.concatMap (d: d.buildInputs) inputsFrom)}"; + RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; + }; + } + ); + + formatter = forAllSystems ({ pkgs, ... }: pkgs.nixfmt-rfc-style); + }; +} 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!"); +}