Skip to content

Commit 5a29bd7

Browse files
committed
treewide: revamp build system
1 parent 44988be commit 5a29bd7

File tree

8 files changed

+168
-87
lines changed

8 files changed

+168
-87
lines changed

.envrc

-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
use flake
22

3-
watch_file ./nix/deploy.nix
4-
watch_file ./nix/gen-ci.nix
5-
watch_file ./nix/outputs.nix
6-
watch_file ./nix/shell.nix
7-
83
eval "$shellHook"

.github/dependabot.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: "/"
5+
schedule:
6+
interval: monthly
7+
commit-message:
8+
prefix: "chore"
9+
include: "scope"
10+
- package-ecosystem: cargo
11+
directory: "/"
12+
schedule:
13+
interval: weekly
14+
commit-message:
15+
prefix: "chore"
16+
include: "scope"

.github/workflows/build.yml

-28
This file was deleted.

.github/workflows/ci.yaml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: ci
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- flake-update
7+
pull_request:
8+
jobs:
9+
nix-build:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
system:
14+
- x86_64-linux
15+
# - aarch64-linux
16+
steps:
17+
- uses: actions/[email protected]
18+
with:
19+
fetch-depth: 0
20+
- uses: cachix/install-nix-action@v13
21+
with:
22+
install_url: https://nixos-nix-install-tests.cachix.org/serve/ipa0c64h689jb4ys6hxsky2r8xpld0hv/install
23+
install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve'
24+
extra_nix_config: experimental-features = nix-command flakes
25+
- uses: cachix/cachix-action@v10
26+
with:
27+
name: nix-community
28+
- name: nix-build
29+
run: nix build -L .#defaultPackage.${{ matrix.system }}
30+
nix-check:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/[email protected]
34+
with:
35+
fetch-depth: 0
36+
- uses: cachix/install-nix-action@v13
37+
with:
38+
install_url: https://nixos-nix-install-tests.cachix.org/serve/ipa0c64h689jb4ys6hxsky2r8xpld0hv/install
39+
install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve'
40+
extra_nix_config: experimental-features = nix-command flakes
41+
- uses: cachix/cachix-action@v10
42+
with:
43+
name: nix-community
44+
- name: nix-check
45+
run: nix flake check -L
46+
clippy:
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/[email protected]
50+
- uses: actions-rs/toolchain@v1
51+
with:
52+
toolchain: nightly
53+
components: clippy
54+
target: aarch64-unknown-linux-gnu
55+
override: true
56+
- uses: actions-rs/clippy-check@v1
57+
with:
58+
token: ${{ secrets.GITHUB_TOKEN }}
59+
args: --all-features

.github/workflows/clippy.yml

-17
This file was deleted.

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
result
33
result*
44
.direnv/
5+
.pre-commit-config.yaml

flake.lock

+29-23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+63-14
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,96 @@
33
fenix = {
44
url = "github:figsoda/fenix";
55
inputs.nixpkgs.follows = "nixpkgs";
6+
inputs.naersk.follows = "naersk";
67
};
78
flake-utils.url = "github:numtide/flake-utils";
89
naersk = {
910
url = "github:nmattia/naersk";
1011
inputs.nixpkgs.follows = "nixpkgs";
1112
};
1213
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
14+
pre-commit-hooks = {
15+
url = "github:cachix/pre-commit-hooks.nix";
16+
inputs.nixpkgs.follows = "nixpkgs";
17+
inputs.flake-utils.follows = "flake-utils";
18+
};
1319
};
1420

15-
outputs = { self, fenix, flake-utils, naersk, nixpkgs }:
21+
outputs = { self, fenix, flake-utils, naersk, nixpkgs, pre-commit-hooks }:
1622
flake-utils.lib.eachDefaultSystem (system:
1723
let
1824
pkgs = nixpkgs.legacyPackages.${system};
25+
26+
fenixPkgs = fenix.packages.${system};
1927
target = "aarch64-unknown-linux-gnu";
20-
toolchain = with fenix.packages.${system}; combine [
21-
minimal.rustc
22-
minimal.cargo
23-
targets.${target}.latest.rust-std
28+
rustFull = with fenixPkgs; combine [
29+
(stable.withComponents [
30+
"cargo"
31+
"clippy-preview"
32+
"rust-src"
33+
"rust-std"
34+
"rustc"
35+
"rustfmt-preview"
36+
])
37+
targets.${target}.stable.rust-std
2438
];
25-
naerskCross = naersk.lib.${system}.override {
26-
cargo = toolchain;
27-
rustc = toolchain;
28-
};
39+
rustMinimal = with fenixPkgs; combine [
40+
(minimal.withComponents [
41+
"cargo"
42+
"rust-std"
43+
"rustc"
44+
])
45+
targets.${target}.minimal.rust-std
46+
];
47+
48+
naerskBuild = (naersk.lib.${system}.override {
49+
cargo = rustMinimal;
50+
rustc = rustMinimal;
51+
}).buildPackage;
52+
2953
cargoConfig = {
3054
CARGO_BUILD_TARGET = target;
31-
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER = "${pkgs.pkgsCross.aarch64-multiplatform.stdenv.cc}/bin/${target}-gcc";
55+
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER =
56+
if "${system}" == "aarch64-linux" then
57+
"${pkgs.stdenv.cc}/bin/gcc"
58+
else
59+
"${pkgs.pkgsCross.aarch64-multiplatform.stdenv.cc}/bin/${target}-gcc";
3260
};
3361
in
3462
{
35-
defaultPackage = naerskCross.buildPackage ({
63+
packages.hyperpixel-init = naerskBuild ({
3664
src = ./.;
65+
doDoc = true;
3766
} // cargoConfig);
3867

68+
defaultPackage = self.packages.${system}.hyperpixel-init;
69+
3970
devShell = pkgs.mkShell ({
71+
inherit (self.checks.${system}.pre-commit-check) shellHook;
4072
name = "hyperpixel-init";
41-
4273
buildInputs = with pkgs; [
4374
cargo-edit
75+
fenixPkgs.rust-analyzer
76+
nix-linter
4477
nixpkgs-fmt
45-
toolchain
46-
] ++ (with fenix.packages.${system}; [ rust-analyzer ]);
78+
rustFull
79+
];
4780
} // cargoConfig);
81+
82+
checks = {
83+
pre-commit-check = (pre-commit-hooks.lib.${system}.run {
84+
src = ./.;
85+
hooks = {
86+
nixpkgs-fmt.enable = true;
87+
nix-linter.enable = true;
88+
rustfmt = {
89+
enable = true;
90+
entry = pkgs.lib.mkForce ''
91+
bash -c 'PATH="$PATH:${rustFull}/bin" cargo fmt -- --check --color always'
92+
'';
93+
};
94+
};
95+
});
96+
};
4897
});
4998
}

0 commit comments

Comments
 (0)