1
0
Fork 0
mirror of https://codeberg.org/icewind/bitbuffer.git synced 2026-06-03 08:34:07 +02:00

switch flake setup

This commit is contained in:
Robin Appelman 2024-09-24 23:20:29 +02:00
commit 25e7d443b5
4 changed files with 92 additions and 226 deletions

View file

@ -3,7 +3,7 @@ on: [push, pull_request]
name: Continuous integration name: Continuous integration
jobs: jobs:
check: checks:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@ -12,76 +12,17 @@ jobs:
with: with:
name: ci name: ci
instance: https://cache.icewind.me instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}' authToken: "${{ secrets.ATTIC_TOKEN }}"
- run: nix build .#check - run: nix flake check --keep-going
msrv:
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#msrv
clippy:
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#clippy
tests:
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#test
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#fmt
miri-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
- id: set-matrix
run: echo "matrix={\"target\":$(nix eval --json ".#miriTargets.x86_64-linux")}" | tee $GITHUB_OUTPUT
miri-tests: miri-tests:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [tests, miri-matrix] needs: [checks]
strategy: strategy:
fail-fast: false fail-fast: false
matrix: ${{fromJson(needs.miri-matrix.outputs.matrix)}} matrix:
toolchain:
["x86_64-unknown-linux-musl", "mips64-unknown-linux-gnuabi64"]
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27 - uses: cachix/install-nix-action@v27
@ -89,13 +30,18 @@ jobs:
with: with:
name: ci name: ci
instance: https://cache.icewind.me instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}' authToken: "${{ secrets.ATTIC_TOKEN }}"
- run: nix develop .#miri -c cargo miri test --target ${{ matrix.target }} - run: nix run .#miri -- test --target ${{ matrix.target }}
semver: semver:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: check needs: checks
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Check semver - uses: cachix/install-nix-action@v27
uses: obi1kenobi/cargo-semver-checks-action@v2 - uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: "${{ secrets.ATTIC_TOKEN }}"
- run: nix run .#semver-checks

View file

@ -62,8 +62,8 @@ write_stream.write(&ComplexType {
Licensed under either of Licensed under either of
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0) - Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT) - MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)
at your option. at your option.

103
flake.lock generated
View file

@ -1,32 +1,69 @@
{ {
"nodes": { "nodes": {
"naersk": { "crane": {
"locked": {
"lastModified": 1727060013,
"narHash": "sha256-/fC5YlJy4IoAW9GhkJiwyzk0K/gQd9Qi4rRcoweyG9E=",
"owner": "ipetkov",
"repo": "crane",
"rev": "6b40cc876c929bfe1e3a24bf538ce3b5622646ba",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
"flakelight": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
] ]
}, },
"locked": { "locked": {
"lastModified": 1721727458, "lastModified": 1727095190,
"narHash": "sha256-r/xppY958gmZ4oTfLiHN0ZGuQ+RSTijDblVgVLFi1mw=", "narHash": "sha256-eZfUxkPefTP5fknpr2/X+snNysEj830Ft1IaW7VafFE=",
"owner": "nix-community", "owner": "nix-community",
"repo": "naersk", "repo": "flakelight",
"rev": "3fb418eaf352498f6b6c30592e3beb63df42ef11", "rev": "9e0f7e360688187ed3d7d8b033028e0d3473aa2c",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nix-community", "owner": "nix-community",
"repo": "naersk", "repo": "flakelight",
"type": "github"
}
},
"mill-scale": {
"inputs": {
"crane": "crane",
"flakelight": [
"flakelight"
],
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1727556185,
"narHash": "sha256-pEUzAE5WRpPGQYeG/U2mftfHAn2q4aO1pefJNY2EoVw=",
"owner": "icewind1991",
"repo": "mill-scale",
"rev": "823fb3493cb4838c81627821f383af918db33a7f",
"type": "github"
},
"original": {
"owner": "icewind1991",
"repo": "mill-scale",
"type": "github" "type": "github"
} }
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1726838390, "lastModified": 1726969270,
"narHash": "sha256-NmcVhGElxDbmEWzgXsyAjlRhUus/nEqPC5So7BOJLUM=", "narHash": "sha256-8fnFlXBgM/uSvBlLWjZ0Z0sOdRBesyNdH0+esxqizGc=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "944b2aea7f0a2d7c79f72468106bc5510cbf5101", "rev": "23cbb250f3bf4f516a2d0bf03c51a30900848075",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -37,24 +74,25 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"naersk": "naersk", "flakelight": "flakelight",
"nixpkgs": "nixpkgs", "mill-scale": "mill-scale",
"rust-overlay": "rust-overlay", "nixpkgs": "nixpkgs"
"utils": "utils"
} }
}, },
"rust-overlay": { "rust-overlay": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
"mill-scale",
"flakelight",
"nixpkgs" "nixpkgs"
] ]
}, },
"locked": { "locked": {
"lastModified": 1726972233, "lastModified": 1727058553,
"narHash": "sha256-FlL/bNESOtDQoczRhmPfReNAmLqVg+dAX4HectPOOf0=", "narHash": "sha256-tY/UU3Qk5gP/J0uUM4DZ6wo4arNLGAVqLKBotILykfQ=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "36d73192555e569d27579f6c486fea3ab768823c", "rev": "edc5b0f896170f07bd39ad59d6186fcc7859bbb2",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -62,39 +100,6 @@
"repo": "rust-overlay", "repo": "rust-overlay",
"type": "github" "type": "github"
} }
},
"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": 1726560853,
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

103
flake.nix
View file

@ -1,101 +1,16 @@
{ {
inputs = { inputs = {
nixpkgs.url = "nixpkgs/nixos-24.05"; nixpkgs.url = "nixpkgs/nixos-24.05";
utils.url = "github:numtide/flake-utils"; flakelight = {
naersk.url = "github:nix-community/naersk"; url = "github:nix-community/flakelight";
naersk.inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
}; };
mill-scale = {
outputs = { url = "github:icewind1991/mill-scale";
self, inputs.flakelight.follows = "flakelight";
nixpkgs,
utils,
naersk,
rust-overlay,
}:
utils.lib.eachDefaultSystem (system: let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
inherit (pkgs) lib callPackage rust-bin mkShell;
inherit (builtins) listToAttrs fromTOML readFile;
inherit (lib.sources) sourceByRegex;
toolchain = rust-bin.stable.latest.default;
msrv = (fromTOML (readFile ./Cargo.toml)).package.rust-version;
msrvToolchain = rust-bin.stable."${msrv}".default;
miriToolchain = rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override {
extensions = [ "miri" "rust-src" ];
});
naersk' = callPackage naersk {
rustc = toolchain;
cargo = toolchain;
};
msrvNaersk = callPackage naersk {
rustc = msrvToolchain;
cargo = msrvToolchain;
};
src = sourceByRegex ./. ["Cargo.*" "(src|tests|bitbuffer_derive|benches)(/.*)?"];
naerskOpt = {
pname = "bitbuffer";
root = src;
copySources = ["bitbuffer_derive"];
};
in rec {
packages = {
check = naersk'.buildPackage (naerskOpt // {
mode = "check";
});
test = naersk'.buildPackage (naerskOpt // {
mode = "test";
cargoTestOptions = x: x ++ ["--all-features"];
});
clippy = naersk'.buildPackage (naerskOpt // {
mode = "clippy";
});
fmt = naersk'.buildPackage (naerskOpt // {
mode = "fmt";
});
msrv = msrvNaersk.buildPackage (naerskOpt // {
mode = "check";
});
};
miriTargets = [
"x86_64-unknown-linux-musl" # little-endian
"mips64-unknown-linux-gnuabi64" # big-endian
];
devShells = let
tools = with pkgs; [
bacon
cargo-edit
cargo-outdated
(writeShellApplication {
name = "cargo-expand";
runtimeInputs = [cargo-expand toolchain];
text = ''
# shellcheck disable=SC2068
RUSTC_BOOTSTRAP=1 cargo-expand $@
'';
})
cargo-semver-checks
];
in {
default = mkShell {
nativeBuildInputs = [toolchain] ++ tools;
};
msrv = mkShell {
nativeBuildInputs = [msrvToolchain] ++ tools;
};
miri = mkShell {
nativeBuildInputs = [miriToolchain] ++ tools;
}; };
}; };
}); outputs = { mill-scale, ... }: mill-scale ./. {
devShell.packages = pkgs: with pkgs; [ cargo-expand ];
};
} }