Skip to content

Commit

Permalink
switch flake setup
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed Sep 24, 2024
1 parent 611c14e commit 21a6a16
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 201 deletions.
69 changes: 15 additions & 54 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ on:
jobs:
check-proto:
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v26
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
authToken: "${{ secrets.ATTIC_TOKEN }}"
- run: nix run .#proto-builder protobuf/steam/protos protobuf/steam/src/generated
- run: nix run .#proto-builder protobuf/tf2/protos protobuf/tf2/src/generated
- run: nix run .#proto-builder protobuf/csgo/protos protobuf/csgo/src/generated
Expand All @@ -23,67 +22,29 @@ jobs:
git diff
git diff-index --quiet HEAD --
check:
matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v26
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#check

clippy:
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v26
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#clippy

msrv:
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v26
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#msrv

test:
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v26
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#test-crypto
- run: nix build .#test
- uses: cachix/install-nix-action@v27
- id: set-matrix
run: echo "matrix={\"check\":$(nix eval --json '.#checks.x86_64-linux' --apply 'builtins.attrNames')}" | tee $GITHUB_OUTPUT

all-features:
checks:
runs-on: ubuntu-latest
needs: check
needs: [ matrix ]
strategy:
fail-fast: false
matrix: ${{fromJson(needs.miri-matrix.outputs.matrix)}}
name: ${{ matrix.check }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v26
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#all-features
authToken: "${{ secrets.ATTIC_TOKEN }}"
- run: nom build .#checks.x86_64-linux.${{ matrix.check }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ async fn main() -> Result<(), Box<dyn Error>> {

This is in large parts inspired by and based of [@DoctorMcKay's](https://github.com/DoctorMcKay) work
on [SteamUser](https://github.com/DoctorMcKay/node-steam-user/),
massive credits go to all who worked on that.
massive credits go to all who worked on that.
103 changes: 54 additions & 49 deletions flake.lock

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

112 changes: 17 additions & 95 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,101 +1,23 @@
{
inputs = {
nixpkgs.url = "nixpkgs/nixos-24.05";
utils.url = "github:numtide/flake-utils";
naersk.url = "github:nix-community/naersk";
naersk.inputs.nixpkgs.follows = "nixpkgs";
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
flakelight = {
url = "github:nix-community/flakelight";
inputs.nixpkgs.follows = "nixpkgs";
};
mill-scale = {
url = "github:icewind1991/mill-scale";
inputs.flakelight.follows = "flakelight";
};
};

outputs = {
self,
nixpkgs,
utils,
naersk,
rust-overlay,
}:
utils.lib.eachDefaultSystem (system: let
overlays = [(import rust-overlay)];
pkgs = (import nixpkgs) {
inherit system overlays;
outputs = { mill-scale, ... }: mill-scale ./. {
extraFiles = [ "system.pem" ];
packages = {
proto-builder = { craneLib, ... }: craneLib.buildPackage {
src = craneLib.cleanCargoSource ./protobuf/build;
doCheck = false;
strictDeps = true;
};
inherit (builtins) listToAttrs fromTOML readFile;
lib = pkgs.lib;
naersk' = pkgs.callPackage naersk {};
srcFilters = ["Cargo.*" "(src|derive|benches|tests|examples|crypto|protobuf)(/.*)?"];
src = lib.sources.sourceByRegex ./. srcFilters;
buildDeps = with pkgs; [
pkg-config
openssl
];

msrv = (fromTOML (readFile ./Cargo.toml)).package.rust-version;
msrvToolchain = pkgs.rust-bin.stable."${msrv}".default;
naerskMsrv = let
toolchain = msrvToolchain;
in
pkgs.callPackage naersk {
cargo = toolchain;
rustc = toolchain;
};

nearskOpt = {
inherit src;
pname = "steam-vent";
nativeBuildInputs = buildDeps;
};
in rec {
packages = {
check = naersk'.buildPackage (nearskOpt
// {
mode = "check";
});
all-features = naersk'.buildPackage (nearskOpt
// {
mode = "check";
cargoBuildOptions = x: x++ ["--all-features"];
});
clippy = naersk'.buildPackage (nearskOpt
// {
mode = "clippy";
cargoBuildOptions = x: x++ ["--all-features"];
});
test = naersk'.buildPackage (nearskOpt
// {
release = false;
mode = "test";
});
test-crypto = naersk'.buildPackage (nearskOpt
// {
release = false;
mode = "test";
cargoTestOptions = x: x ++ ["-p" "steam-vent-crypto"];
});
msrv = naerskMsrv.buildPackage (nearskOpt
// {
mode = "check";
cargoBuildOptions = x: x++ ["--all-features"];
});
proto-builder = naersk'.buildPackage {
src = lib.sources.sourceByRegex ./protobuf/build srcFilters;
};
};

devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs;
[
rust-bin.stable.latest.default
bacon
cargo-edit
cargo-outdated
clippy
cargo-audit
cargo-msrv
cargo-fuzz
cargo-semver-checks
]
++ buildDeps;
};
});
};
};
}
2 changes: 1 addition & 1 deletion protobuf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Sourced from https://github.com/SteamDatabase/Protobufs
- cargo r -- ../steam/{protos,src/generated}
- cargo r -- ../tf2/{protos,src/generated}
- cargo r -- ../csgo/{protos,src/generated}
- cargo r -- ../dota2/{protos,src/generated}
- cargo r -- ../dota2/{protos,src/generated}
2 changes: 1 addition & 1 deletion src/serverlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl ServerList {
let cell = options.cell;

let response: ServerListResponse = client
.get(&format!(
.get(format!(
"https://api.steampowered.com/ISteamDirectory/GetCMList/v1/?cellid={cell}"
))
.send()
Expand Down

0 comments on commit 21a6a16

Please sign in to comment.