Skip to content
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
5 changes: 3 additions & 2 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# If your shell has direnv support, it will automatically open a "nix-shell".
use nix
# If your shell has direnv support, it will automatically open a Nix shell with
# all relevant dependencies to develop this project.
use flake
19 changes: 8 additions & 11 deletions .github/workflows/developer_productivity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
pull_request:
jobs:
# Job to run change detection
# Job to run change detection for Nix-related files
changes:
runs-on: ubuntu-latest
# Set job outputs to values from filter step.
Expand All @@ -19,13 +19,14 @@ jobs:
filters: |
nix-src:
- 'nix/**'
- 'shell.nix'
- 'flake.nix'
- 'flake.lock'
# This is a convenience test to verify that the toolchain provided by
# shell.nix is valid and can build + run the integration test.
#
# It only runs if the "nix-src" output of the "changes" job is true.
nix_shell_toolchain:
name: "Nix toolchain: `cargo xtask run` works"
name: "Nix shell toolchain: `cargo xtask run` works"
needs: changes
if: ${{ needs.changes.outputs.nix-src == 'true' }}
runs-on: ubuntu-latest
Expand All @@ -34,17 +35,13 @@ jobs:
uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- uses: cachix/install-nix-action@v30
with:
# This channel is only required to invoke "nix-shell".
# Everything inside that nix-shell will use a pinned version of nixpkgs.
nix_path: nixpkgs=channel:nixpkgs-unstable
# Dedicated step to separate all the
# "copying path '/nix/store/...' from 'https://cache.nixos.org'."
# messages from the actual build output. This job takes ~60secs.
# messages from the actual build output.
- name: Prepare Nix Store
run: nix-shell --pure --run "cargo --version"
run: nix develop --command bash -c "cargo --version"
- name: Run VM tests
run: |
COMMAND="cargo xtask run --target x86_64 --headless --ci --tpm=v1"
echo "Executing in nix shell: $COMMAND"
nix-shell --pure --run "$COMMAND"
echo "Executing in Nix shell: $COMMAND"
nix develop --command bash -c "$COMMAND"
62 changes: 62 additions & 0 deletions flake.lock

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

61 changes: 61 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
description = "uefi-rs";

inputs = {
# We follow the latest stable release of nixpkgs
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
rust-overlay.url = "github:oxalica/rust-overlay";
};

outputs =
inputs@{ self, nixpkgs, ... }:
let
# Systems definition for dev shells and exported packages,
# independent of the NixOS configurations and modules defined here. We
# just use "every system" here to not restrict any user. However, it
# likely happens that certain packages don't build for/under certain
# systems.
systems = nixpkgs.lib.systems.flakeExposed;
forAllSystems =
function: nixpkgs.lib.genAttrs systems (system: function nixpkgs.legacyPackages.${system});

# We directly instantiate the functionality, without using an
# nixpkgs overlay.
# https://github.com/oxalica/rust-overlay/blob/f4d5a693c18b389f0d58f55b6f7be6ef85af186f/docs/reference.md?plain=1#L26
rustToolchain =
pkgs:
let
rust-bin = (inputs.rust-overlay.lib.mkRustBin { }) pkgs;
rustToolchainBuilder = import ./nix/rust-toolchain.nix;
in
rustToolchainBuilder { inherit rust-bin; };
in
{
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
packages = with pkgs; [
nixfmt-rfc-style

# Integration test dependencies
swtpm
qemu

# Rust toolchain
(rustToolchain pkgs)

# Other
cargo-llvm-cov
mdbook
yamlfmt
which # used by "cargo xtask fmt"
];

# Set ENV vars.
# OVMF_CODE="${pkgs.OVMF.firmware}";
# OVMF_VARS="${pkgs.OVMF.variables}";
# OVMF_SHELL="${pkgs.edk2-uefi-shell}";
};
});
formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
};
}
5 changes: 0 additions & 5 deletions nix/nixpkgs.nix

This file was deleted.

3 changes: 1 addition & 2 deletions nix/rust-toolchain.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Returns the Rust toolchain for Nix compliant to the rust-toolchain.toml file
# but without rustup.
# Returns a Rust toolchain for Nix that matches the one from the toolchain file.

{
# Comes from rust-overlay
Expand Down
26 changes: 0 additions & 26 deletions nix/sources.json

This file was deleted.

Loading
Loading