Skip to content

xtask: fix nixfmt + update Nix flake + fix CI #1607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# If you are a frequent contributor to uefi-rs and would like to be featured in
# the sponsors section, please contact the maintainers.

github: phip1611
2 changes: 1 addition & 1 deletion .github/workflows/developer_productivity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- uses: cachix/install-nix-action@v30
- uses: cachix/install-nix-action@v31
# Dedicated step to separate all the
# "copying path '/nix/store/...' from 'https://cache.nixos.org'."
# messages from the actual build output.
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,35 @@ jobs:
- uses: actions/checkout@v4
# Executes "typos ."
- uses: crate-ci/[email protected]
lints:
name: Lints
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- uses: cachix/install-nix-action@v31
- uses: Swatinem/rust-cache@v2
# Dedicated step to separate all the
# "copying path '/nix/store/...' from 'https://cache.nixos.org'."
# messages from the actual build output.
- name: Prepare Nix Store
run: nix develop --command echo
# A dedicated step removes spam from the actual job.
- name: Build cargo xtask
run: cargo xtask help >/dev/null
# Executing this in a Nix shell ensures that all our checks run as all
# required tooling exists.
- name: Check formatting
run: |
CMD="cargo xtask fmt --check"
nix develop --command bash -c "$CMD"
- name: Run clippy
run: |
rustup component add clippy
cargo xtask clippy --warnings-as-errors
- name: Run cargo doc (without unstable)
run: cargo xtask doc --warnings-as-errors --document-private-items
- name: Verify generated code is up-to-date
run: cargo xtask gen-code --check
- name: Run additional checks on the uefi-raw package
run: cargo xtask check-raw
27 changes: 0 additions & 27 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,33 +81,6 @@ jobs:
- uses: Swatinem/rust-cache@v2
- name: Run cargo test (without unstable)
run: cargo xtask test
lints:
name: Lints
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- name: Install yamlfmt
env:
YFV: "0.13.0"
HASH: "043e96d754a8afa4f4c5c13ffb2f3e50c6be5a70bf53292d3025abc0b42fe4ae"
run: |
curl -L --fail --output /tmp/yamlfmt.tar.xz https://github.com/google/yamlfmt/releases/download/v${YFV}/yamlfmt_${YFV}_Linux_x86_64.tar.gz
echo "${HASH} /tmp/yamlfmt.tar.xz" | sha256sum --check
tar xf /tmp/yamlfmt.tar.xz -C /usr/local/bin yamlfmt
- name: Check formatting
run: cargo xtask fmt --check
- name: Run clippy
run: |
rustup component add clippy
cargo xtask clippy --warnings-as-errors
- name: Run cargo doc (without unstable)
run: cargo xtask doc --warnings-as-errors --document-private-items
- name: Verify generated code is up-to-date
run: cargo xtask gen-code --check
- name: Run additional checks on the uefi-raw package
run: cargo xtask check-raw
# Run the build with our current stable MSRV (specified in
# ./msrv_toolchain.toml). This serves to check that we don't
# accidentally start relying on a new feature without intending
Expand Down
14 changes: 7 additions & 7 deletions flake.lock

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

6 changes: 4 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
description = "uefi-rs";

inputs = {
# We follow the latest stable release of nixpkgs
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
# Use freshest nixpkgs. We don't use master as packages in nixpkgs-unstable
# have already been build by the nixpkgs CI and are available from the
# nixos.org cache.
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
};

Expand Down
18 changes: 13 additions & 5 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,23 @@ fn run_fmt_project(fmt_opt: &FmtOpt) -> Result<()> {
eprintln!("Formatting: yml - SKIPPED");
}

// fmt nix
if has_cmd("nixfmt") {
// fmt nix (by passing files as arguments)
// `find . -name "*.nix" -type f -exec nix fmt {} \+`
if has_cmd("find") && has_cmd("nixfmt") {
eprintln!("Formatting: nix");
let mut command = Command::new("nixfmt");
let mut command = Command::new("find");
command.arg(".");
command.arg("-name");
command.arg("*.nix");
command.arg("-type");
command.arg("f");
command.arg("-exec");
command.arg("nixfmt");
if fmt_opt.check {
command.arg("--check");
}
command.arg("nix");
command.arg("shell.nix");
command.arg("{}");
command.arg("+");

match run_cmd(command) {
Ok(_) => {
Expand Down
Loading