Skip to content

Commit

Permalink
Add nix build
Browse files Browse the repository at this point in the history
  • Loading branch information
nea89o committed Oct 27, 2024
1 parent e144986 commit ee007f9
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 80 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

name: "Build"
on:
pull_request:
push:
jobs:
nix-build:
name: "Nix"
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
- run: nix build
- run: nix run . -- -V


2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/target
.env
reports
result

15 changes: 10 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@

use std::process::Command;
fn main() {
let output = Command::new("git")
.args(["rev-parse", "HEAD"])
.output()
.unwrap();
let git_hash = String::from_utf8(output.stdout).unwrap();
let git_hash = if let Ok(git_hash) = std::env::var("GIT_HASH") {
git_hash
} else {
let output = Command::new("git")
.args(["rev-parse", "HEAD"])
.output()
.unwrap();
let git_hash = String::from_utf8(output.stdout).unwrap();
git_hash
};
println!("cargo:rustc-env=GIT_HASH={}", git_hash);
}
58 changes: 12 additions & 46 deletions flake.lock

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

56 changes: 28 additions & 28 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,35 @@
flake-utils.url = "github:numtide/flake-utils";
};

outputs = {
self,
nixpkgs,
rust-overlay,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system: let
overlays = [(import rust-overlay)];
pkgs = import nixpkgs {
inherit system overlays;
outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
rustToolchain =
pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
rustPlatform = pkgs.makeRustPlatform {
cargo = rustToolchain;
rustc = rustToolchain;
};
in
with pkgs; {
devShells.default = mkShell {
buildInputs = [
openssl
pkg-config
(rust-bin.fromRustupToolchainFile ./rust-toolchain.toml)
rust-analyzer
sccache
cargo-make
];
deps = [ pkgs.openssl ];
in with pkgs; {
defaultPackage = rustPlatform.buildRustPackage {
name = "ursa-minor";
src = ./.;
cargoLock = { lockFileContents = builtins.readFile ./Cargo.lock; };
buildInputs = deps;
nativeBuildInputs = [ pkgs.pkg-config ];
env = { GIT_HASH = self.rev or self.dirtyRev or "nix-dirty"; };
};
devShells.default = mkShell {
buildInputs =
[ pkg-config rustToolchain rust-analyzer sccache cargo-make ]
++ deps;

shellHook = ''
shellHook = ''
export RUSTC_WRAPPER="${sccache}/bin/sccache"
'';
};
}
);
'';
};
});
}
6 changes: 5 additions & 1 deletion src/hypixel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ pub async fn respond_to(
let mut part_iter = parts.iter();
for query_argument in &rule.query_arguments {
let Some(next_part) = part_iter.next() else {
return make_error(400, format!("Missing query argument {}", query_argument).as_str()).map(Some);
return make_error(
400,
format!("Missing query argument {}", query_argument).as_str(),
)
.map(Some);
};
query_parts.push((query_argument.clone(), (*next_part).to_owned()));
}
Expand Down

0 comments on commit ee007f9

Please sign in to comment.