Skip to content

Commit

Permalink
Add nix and github ci builds
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyGiorgio committed May 13, 2024
1 parent f134486 commit 163d988
Show file tree
Hide file tree
Showing 7 changed files with 231 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: "Format"
on:
pull_request:
jobs:
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: DeterminateSystems/flake-checker-action@main
- name: Run clippy
run: nix develop --command bash -c "just clippy"
13 changes: 13 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: "Test"
on:
pull_request:
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: DeterminateSystems/flake-checker-action@main
- name: Run `nix develop test`
run: nix develop --command bash -c "just test"
115 changes: 115 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
description = "Harbor Flake.nix";

inputs = {
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs.url = "nixpkgs/nixos-unstable";
};

outputs = { self, nixpkgs, flake-utils, rust-overlay }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ rust-overlay.overlays.default ];
pkgs = import nixpkgs { inherit system overlays; };
rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
inputs = [
rust
pkgs.rust-analyzer
pkgs.openssl
pkgs.zlib
pkgs.gcc
pkgs.pkg-config
pkgs.just
pkgs.binaryen
pkgs.clang
pkgs.expat
pkgs.llvmPackages.libcxxClang
pkgs.fontconfig
pkgs.freetype
pkgs.freetype.dev
pkgs.libGL
pkgs.pkg-config
pkgs.xorg.libX11
pkgs.xorg.libXcursor
pkgs.xorg.libXi
pkgs.xorg.libXrandr
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.AppKit
pkgs.darwin.apple_sdk.frameworks.CoreText
pkgs.darwin.apple_sdk.frameworks.WebKit
];
in
{
defaultPackage = pkgs.rustPlatform.buildRustPackage {
src = ./.;

cargoLock = {
lockFile = ./Cargo.lock;
};

nativeBuildInputs = inputs;
};


devShell = pkgs.mkShell {
packages = inputs;
shellHook = ''
export LIBCLANG_PATH=${pkgs.libclang.lib}/lib/
export LD_LIBRARY_PATH=${pkgs.openssl}/lib:$LD_LIBRARY_PATH
'';
};
}
);
}
11 changes: 11 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
test:
cargo test

run:
RUST_LOG=debug cargo run

release:
cargo run --release

clippy:
cargo clippy --all-features --tests -- -D warnings
4 changes: 4 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[toolchain]
channel = "nightly-2024-05-13"
components = ["rustfmt", "clippy"]
profile = "default"
8 changes: 8 additions & 0 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,11 @@ pub fn run_core() -> Subscription<Message> {
},
)
}

#[cfg(test)]
mod tests {
#[tokio::test]
async fn example_test() {
assert!(true);
}
}

0 comments on commit 163d988

Please sign in to comment.