Skip to content

Commit f9f06b9

Browse files
committed
refactor: ferrix
1 parent 9509d10 commit f9f06b9

File tree

6 files changed

+56
-255
lines changed

6 files changed

+56
-255
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
if: ${{ inputs.disable-cache != true }}
4747

4848
- name: Install cargo-auditable
49-
uses: taiki-e/install-action@0e09747a63ae497bf945b3dcaf38fef0050d0109 # ratchet:taiki-e/install-action@v2
49+
uses: taiki-e/install-action@1c7b1d35fcc8f6525be0cbdacbf5977079a3f94c # ratchet:taiki-e/install-action@v2
5050
with:
5151
tool: cargo-auditable
5252

@@ -60,7 +60,7 @@ jobs:
6060
run: cp ./target/${{ matrix.target }}/release/am ./am-${{ matrix.target }}
6161

6262
- name: Upload artifacts
63-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # ratchet:actions/upload-artifact@v4
63+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # ratchet:actions/upload-artifact@v5
6464
with:
6565
name: am-${{ matrix.target }}
6666
path: ./am-${{ matrix.target }}

.github/workflows/check.yml

Lines changed: 26 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ permissions:
1414
contents: read
1515

1616
jobs:
17-
clippy:
18-
runs-on: macos-latest
19-
permissions:
20-
contents: read
21-
security-events: write
17+
collect:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
checks: ${{ steps.checks.outputs.checks }}
2221

2322
steps:
2423
- name: Checkout repository
@@ -27,34 +26,24 @@ jobs:
2726
persist-credentials: false
2827

2928
- name: Install Nix
30-
uses: cachix/install-nix-action@a809471b5c7c913aa67bec8f459a11a0decc3fce # ratchet:cachix/install-nix-action@v31
31-
32-
- name: Check
33-
run: nix build --fallback --print-build-logs '.#checks.aarch64-darwin.clippy'
34-
35-
- name: Upload analysis results
36-
uses: github/codeql-action/upload-sarif@192325c86100d080feab897ff886c34abd4c83a3 # ratchet:github/codeql-action/upload-sarif@v3
37-
with:
38-
sarif_file: result
39-
wait-for-processing: true
40-
41-
rustfmt:
42-
runs-on: macos-latest
43-
44-
steps:
45-
- name: Checkout repository
46-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # ratchet:actions/checkout@v5
47-
with:
48-
persist-credentials: false
29+
uses: cachix/install-nix-action@fd24c48048070c1be9acd18c9d369a83f0fe94d7 # ratchet:cachix/install-nix-action@v31
4930

50-
- name: Install Nix
51-
uses: cachix/install-nix-action@a809471b5c7c913aa67bec8f459a11a0decc3fce # ratchet:cachix/install-nix-action@v31
31+
- name: Collect checks
32+
id: checks
33+
run: |
34+
echo "checks=$(nix eval --impure --json --expr 'builtins.attrNames (builtins.getFlake (toString ./.)).checks.${builtins.currentSystem}')" >> "$GITHUB_OUTPUT"
5235
53-
- name: Check
54-
run: nix build --fallback --print-build-logs '.#checks.aarch64-darwin.rustfmt'
36+
check:
37+
needs: collect
38+
strategy:
39+
matrix:
40+
check: ${{ fromJson(needs.collect.outputs.checks) }}
41+
fail-fast: false
5542

56-
nixfmt:
57-
runs-on: macos-latest
43+
runs-on: ubuntu-latest
44+
permissions:
45+
contents: read
46+
security-events: write
5847

5948
steps:
6049
- name: Checkout repository
@@ -63,22 +52,14 @@ jobs:
6352
persist-credentials: false
6453

6554
- name: Install Nix
66-
uses: cachix/install-nix-action@a809471b5c7c913aa67bec8f459a11a0decc3fce # ratchet:cachix/install-nix-action@v31
55+
uses: cachix/install-nix-action@fd24c48048070c1be9acd18c9d369a83f0fe94d7 # ratchet:cachix/install-nix-action@v31
6756

6857
- name: Check
69-
run: nix build --fallback --print-build-logs '.#checks.aarch64-darwin.nixfmt'
70-
71-
reuse:
72-
runs-on: macos-latest
58+
run: nix build --fallback --print-build-logs '.#checks.x86_64-linux.${{ matrix.check }}'
7359

74-
steps:
75-
- name: Checkout repository
76-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # ratchet:actions/checkout@v5
60+
- name: Upload Clippy results
61+
if: ${{ matrix.check == 'clippy' }}
62+
uses: github/codeql-action/upload-sarif@4e94bd11f71e507f7f87df81788dff88d1dacbfb # ratchet:github/codeql-action/upload-sarif@v4
7763
with:
78-
persist-credentials: false
79-
80-
- name: Install Nix
81-
uses: cachix/install-nix-action@a809471b5c7c913aa67bec8f459a11a0decc3fce # ratchet:cachix/install-nix-action@v31
82-
83-
- name: Check
84-
run: nix build --fallback --print-build-logs '.#checks.aarch64-darwin.reuse'
64+
sarif_file: result
65+
wait-for-processing: true

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
toolchain: stable
3838

3939
- name: Authenticate with crates.io
40-
uses: rust-lang/crates-io-auth-action@63a7064947ceca9989005e118db3a5fecdc9259f # ratchet:rust-lang/crates-io-auth-action@v1
40+
uses: rust-lang/crates-io-auth-action@041cce5b4b821e6b0ebc9c9c38b58cac4e34dcc2 # ratchet:rust-lang/crates-io-auth-action@v1
4141
id: auth
4242

4343
- name: Publish
@@ -53,11 +53,11 @@ jobs:
5353
contents: write
5454

5555
steps:
56-
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # ratchet:actions/download-artifact@v5
56+
- uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # ratchet:actions/download-artifact@v6
5757
with:
5858
path: artifacts
5959

6060
- name: Upload to release
61-
uses: softprops/action-gh-release@6cbd405e2c4e67a21c47fa9e383d020e4e28b836 # ratchet:softprops/action-gh-release@v2
61+
uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090 # ratchet:softprops/action-gh-release@v2
6262
with:
6363
files: artifacts/**/*

flake.lock

Lines changed: 19 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 6 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -3,150 +3,18 @@
33
# SPDX-License-Identifier: GPL-3.0-or-later
44

55
{
6-
description = "A beautiful and feature-packed Apple Music CLI";
7-
86
inputs = {
97
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
8+
ferrix.url = "github:ryanccn/ferrix";
109
};
1110

1211
outputs =
13-
{
14-
self,
15-
nixpkgs,
16-
}:
17-
let
18-
inherit (nixpkgs) lib;
19-
systems = [
20-
"x86_64-darwin"
21-
"aarch64-darwin"
22-
];
23-
24-
forAllSystems = lib.genAttrs systems;
25-
nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system});
26-
in
27-
{
28-
checks = forAllSystems (
29-
system:
30-
let
31-
pkgs = nixpkgsFor.${system};
32-
33-
mkFlakeCheck =
34-
{
35-
name,
36-
command,
37-
...
38-
}@args:
39-
pkgs.stdenv.mkDerivation (
40-
{
41-
name = "check-${name}";
42-
inherit (self.packages.${system}.am) src;
43-
44-
buildPhase = ''
45-
${command}
46-
touch "$out"
47-
'';
48-
49-
doCheck = false;
50-
dontInstall = true;
51-
dontFixup = true;
52-
}
53-
// (removeAttrs args [
54-
"name"
55-
"command"
56-
])
57-
);
58-
in
59-
{
60-
nixfmt = mkFlakeCheck {
61-
name = "nixfmt";
62-
command = "find . -name '*.nix' -exec nixfmt --check {} +";
63-
64-
src = self;
65-
nativeBuildInputs = with pkgs; [ nixfmt-rfc-style ];
66-
};
67-
68-
rustfmt = mkFlakeCheck {
69-
name = "rustfmt";
70-
command = "cargo fmt --check";
71-
72-
nativeBuildInputs = with pkgs; [
73-
cargo
74-
rustfmt
75-
];
76-
};
77-
78-
clippy = mkFlakeCheck {
79-
name = "clippy";
80-
command = ''
81-
cargo clippy --all-features --all-targets --tests \
82-
--offline --message-format=json \
83-
| clippy-sarif | tee $out | sarif-fmt
84-
'';
85-
86-
nativeBuildInputs = with pkgs; [
87-
rustPlatform.cargoSetupHook
88-
cargo
89-
rustc
90-
clippy
91-
clippy-sarif
92-
sarif-fmt
93-
];
94-
95-
inherit (self.packages.${system}.am) cargoDeps;
96-
};
97-
98-
reuse = mkFlakeCheck {
99-
name = "reuse";
100-
command = "reuse lint";
101-
102-
src = self;
103-
nativeBuildInputs = with pkgs; [ reuse ];
104-
};
105-
}
106-
);
107-
108-
devShells = forAllSystems (
109-
system:
110-
let
111-
pkgs = nixpkgsFor.${system};
112-
in
113-
{
114-
default = pkgs.mkShell {
115-
packages = with pkgs; [
116-
rustfmt
117-
clippy
118-
rust-analyzer
119-
];
120-
121-
inputsFrom = [ self.packages.${system}.am ];
122-
123-
env = {
124-
RUST_BACKTRACE = 1;
125-
RUST_SRC_PATH = toString pkgs.rustPlatform.rustLibSrc;
126-
};
127-
};
128-
}
129-
);
130-
131-
packages = forAllSystems (
132-
system:
133-
let
134-
pkgs = nixpkgsFor.${system};
135-
packages = self.overlays.default null pkgs;
136-
in
137-
{
138-
inherit (packages) am;
139-
default = packages.am;
140-
}
141-
);
142-
143-
formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style);
144-
145-
overlays.default = _: prev: {
146-
am = prev.callPackage ./package.nix { inherit self; };
147-
};
12+
{ nixpkgs, ferrix, ... }@inputs:
13+
ferrix.lib.mkFlake inputs {
14+
root = ./.;
15+
systems = nixpkgs.lib.platforms.darwin;
14816

149-
homeModules = {
17+
flake.homeModules = {
15018
am-discord =
15119
{
15220
lib,

package.nix

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)