Skip to content

Commit

Permalink
build: add nix flake
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede committed Aug 4, 2024
1 parent baf1b60 commit 0d8c7e5
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 8 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ guide/build/
# These are backup files generated by rustfmt
**/*.rs.bk

# IDEs
.idea

# direnv
/.direnv
58 changes: 58 additions & 0 deletions flake.lock

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

30 changes: 30 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
flake-parts.url = "github:hercules-ci/flake-parts";
};

outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
perSystem = { pkgs, config, inputs', system, lib, ... }: {
formatter = pkgs.nixpkgs-fmt;

devShells.default = pkgs.mkShell {
packages = [
config.formatter
pkgs.fd
pkgs.just
pkgs.nodePackages.prettier
pkgs.taplo
pkgs.watchexec
] ++ lib.optional pkgs.stdenv.isDarwin [
pkgs.pkgsBuildHost.darwin.apple_sdk.frameworks.Security
pkgs.pkgsBuildHost.darwin.apple_sdk.frameworks.CoreFoundation
pkgs.pkgsBuildHost.darwin.apple_sdk.frameworks.SystemConfiguration
pkgs.pkgsBuildHost.libiconv
];
};
};
};
}
28 changes: 20 additions & 8 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
_list:
@just --list

# Check project.
check: && clippy
just --unstable --fmt --check
# nixpkgs-fmt --check .
fd --hidden --type=file -e=md -e=yml --exec-batch prettier --check
fd --hidden -e=toml --exec-batch taplo format --check
fd --hidden -e=toml --exec-batch taplo lint
cargo +nightly fmt -- --check

# Format project.
fmt:
just --unstable --fmt
# nixpkgs-fmt .
fd --hidden --type=file -e=md -e=yml --exec-batch prettier --write
fd --type=file --hidden -e=toml --exec-batch taplo format
cargo +nightly fmt

# Downgrade dev-dependencies necessary to run MSRV checks/tests.
[private]
downgrade-for-msrv:
Expand All @@ -12,27 +29,22 @@ msrv := ```
| sed -E 's/^1\.([0-9]{2})$/1\.\1\.0/'
```
msrv_rustup := "+" + msrv

non_linux_all_features_list := ```
cargo metadata --format-version=1 \
| jq '.packages[] | select(.source == null) | .features | keys' \
| jq -r --slurp \
--arg exclusions "tokio-uring,io-uring" \
'add | unique | . - ($exclusions | split(",")) | join(",")'
```

all_crate_features := if os() == "linux" {
"--all-features"
} else {
"--features='" + non_linux_all_features_list + "'"
}
all_crate_features := if os() == "linux" { "--all-features" } else { "--features='" + non_linux_all_features_list + "'" }

# Run Clippy over workspace.
clippy toolchain="":
cargo {{ toolchain }} clippy --workspace --all-targets {{ all_crate_features }}

# Test workspace code.
[macos, windows]
[macos]
[windows]
test toolchain="":
cargo {{ toolchain }} test --lib --tests --package=actix-macros
cargo {{ toolchain }} nextest run --workspace --exclude=actix-macros --no-default-features
Expand Down

0 comments on commit 0d8c7e5

Please sign in to comment.