From 870517f871da89944abb18a4dea23448fd817997 Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Sun, 6 Apr 2025 21:28:39 +0200 Subject: [PATCH 1/6] xtask: fix nix formatting nixfmt wants to be called with arguments of files to check and does not walk the tree by itself. --- xtask/src/main.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 91e288eb9..c98dec829 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -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(_) => { From 7d4074bbe975ec1d54e0a8b982dc314ad1f216bd Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Sun, 6 Apr 2025 21:33:52 +0200 Subject: [PATCH 2/6] nix: update flake inputs We now get a fresh Rust 1.86 toolchain from Nix. --- flake.lock | 14 +++++++------- flake.nix | 6 ++++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/flake.lock b/flake.lock index e97a8b0f2..7ef268fd1 100644 --- a/flake.lock +++ b/flake.lock @@ -2,16 +2,16 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1740743217, - "narHash": "sha256-brsCRzLqimpyhORma84c3W2xPbIidZlIc3JGIuQVSNI=", + "lastModified": 1743814133, + "narHash": "sha256-drDyYyUmjeYGiHmwB9eOPTQRjmrq3Yz26knwmMPLZFk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "b27ba4eb322d9d2bf2dc9ada9fd59442f50c8d7c", + "rev": "250b695f41e0e2f5afbf15c6b12480de1fe0001b", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-24.11", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } @@ -43,11 +43,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1740882709, - "narHash": "sha256-VC+8GxWK4p08jjIbmsNfeFQajW2lsiOR/XQiOOvqgvs=", + "lastModified": 1743906877, + "narHash": "sha256-Thah1oU8Vy0gs9bh5QhNcQh1iuQiowMnZPbrkURonZA=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "f4d5a693c18b389f0d58f55b6f7be6ef85af186f", + "rev": "9d00c6b69408dd40d067603012938d9fbe95cfcd", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 69f1a6f80..1a29f2265 100644 --- a/flake.nix +++ b/flake.nix @@ -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"; }; From d7a7d753dfaecd78c8db3f6ea859a34a99c6cbf9 Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Sun, 6 Apr 2025 21:40:58 +0200 Subject: [PATCH 3/6] ci: run cargo xtask in Nix shell This simplifies to get all the relevant tools. --- .github/workflows/developer_productivity.yml | 2 +- .github/workflows/rust.yml | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/developer_productivity.yml b/.github/workflows/developer_productivity.yml index 0f60b8a79..f0a8d1497 100644 --- a/.github/workflows/developer_productivity.yml +++ b/.github/workflows/developer_productivity.yml @@ -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. diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 32eea8415..f908e7b8b 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -87,17 +87,19 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v31 - 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 + # 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 + # Executing this in a Nix shell ensures that all our checks run as all + # required tooling exists. - name: Check formatting - run: cargo xtask fmt --check + run: | + CMD="cargo xtask fmt --check" + nix develop --command bash -c "$CMD" - name: Run clippy run: | rustup component add clippy From 909fad5cd0d2097d5c280bf7c6adc3e3ce5b4e6b Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Sun, 6 Apr 2025 21:43:04 +0200 Subject: [PATCH 4/6] ci: move lints job from rust.yml to qa.yml We are linting the repo, not just Rust. --- .github/workflows/qa.yml | 29 +++++++++++++++++++++++++++++ .github/workflows/rust.yml | 29 ----------------------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml index 5842e5a9f..205a1ad12 100644 --- a/.github/workflows/qa.yml +++ b/.github/workflows/qa.yml @@ -8,3 +8,32 @@ jobs: - uses: actions/checkout@v4 # Executes "typos ." - uses: crate-ci/typos@v1.30.2 + 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 + # 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 diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f908e7b8b..ecd86a8f7 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -81,35 +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: 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 - # 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 # 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 From 205edcd7082858467e391806f3f5dbb19f9a357c Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Sun, 6 Apr 2025 21:44:48 +0200 Subject: [PATCH 5/6] yml: fix unformatted files --- .github/FUNDING.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 7bcdd5248..45fcae6b5 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -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 From 98e6852edb8a17daae0471853b6b934b724be3f2 Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Sun, 6 Apr 2025 21:48:57 +0200 Subject: [PATCH 6/6] ci: prevent spam in `Check formatting` We separate the build log from the formatting log. --- .github/workflows/qa.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml index 205a1ad12..dc53347cb 100644 --- a/.github/workflows/qa.yml +++ b/.github/workflows/qa.yml @@ -21,6 +21,9 @@ jobs: # 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