Skip to content

Commit 17fb1b2

Browse files
Nixpkgs testing and building fixed.
1 parent eb6bd82 commit 17fb1b2

3 files changed

Lines changed: 4 additions & 61 deletions

File tree

.github/workflows/build-nix.yaml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ on:
77
- 'flake.lock'
88
- 'auto-cpufreq/Cargo.toml'
99
- 'auto-cpufreq/Cargo.lock'
10-
# FIX: was pointing to wrong filename 'nix.yml', corrected to actual workflow filename
1110
- '.github/workflows/build-nix.yaml'
1211
pull_request:
1312
paths:
@@ -25,7 +24,6 @@ jobs:
2524
package:
2625
- auto-cpufreq
2726
- auto-cpufreq-gui
28-
2927
steps:
3028
- uses: actions/checkout@v4
3129

@@ -35,13 +33,6 @@ jobs:
3533
extra_nix_config: |
3634
experimental-features = nix-command flakes
3735
38-
- name: Setup Cachix
39-
uses: cachix/cachix-action@v14
40-
with:
41-
name: auto-cpufreq
42-
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
43-
continue-on-error: true
44-
4536
- name: Check Nix flake
4637
run: nix flake check
4738

@@ -98,10 +89,6 @@ jobs:
9889
extra_nix_config: |
9990
experimental-features = nix-command flakes
10091
101-
# FIX: Previous approach used `nix eval --file` on a NixOS module expression
102-
# which requires full nixosSystem context and always silently fails outside NixOS.
103-
# Replaced with `nix eval` via the flake's nixosModules output — correct way to
104-
# verify a module is evaluable without a full system build.
10592
- name: Evaluate NixOS module options via flake
10693
run: nix eval .#nixosModules.auto-cpufreq --apply builtins.typeOf
10794
continue-on-error: true
@@ -116,10 +103,9 @@ jobs:
116103
uses: cachix/install-nix-action@v25
117104

118105
- name: Build with nix-build
119-
run: nix-build
106+
run: nix-build nix/default.nix
120107

121108
- name: Test binary
122109
run: |
123110
./result/bin/auto-cpufreq --version || true
124111
./result/bin/auto-cpufreq --help
125-

flake.nix

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
extensions = [ "rust-src" "rust-analyzer" ];
2323
};
2424

25-
# Common inputs for both GUI and non-GUI builds
2625
commonBuildInputs = with pkgs; [
2726
pkg-config
2827
openssl
@@ -33,7 +32,6 @@
3332
pkg-config
3433
];
3534

36-
# GUI-specific dependencies
3735
guiBuildInputs = with pkgs; [
3836
gtk4
3937
glib
@@ -43,16 +41,9 @@
4341
gobject-introspection
4442
];
4543

46-
# FIX: src must point to the auto-cpufreq subdirectory where Cargo.toml
47-
# and Cargo.lock live. Using ./. (repo root) caused:
48-
# error: path '.../Cargo.lock' does not exist
4944
cargoSrc = ./auto-cpufreq;
50-
51-
# Scripts and assets live in the repo root, not inside auto-cpufreq/.
52-
# We need them available during postInstall, so we pass them separately.
5345
rootSrc = ./.;
5446

55-
# Build auto-cpufreq without GUI
5647
auto-cpufreq-base = pkgs.rustPlatform.buildRustPackage {
5748
pname = "auto-cpufreq";
5849
version = "2.0.0-rust";
@@ -66,32 +57,23 @@
6657
nativeBuildInputs = commonNativeBuildInputs;
6758
buildInputs = commonBuildInputs;
6859

69-
# Don't build GUI features
7060
buildNoDefaultFeatures = true;
71-
72-
# Tests require root access
7361
doCheck = false;
7462

7563
postInstall = ''
76-
# Scripts and assets are in repo root, not in cargoSrc.
77-
# Copy them in from rootSrc via the store path.
7864
local root=${rootSrc}
7965
80-
# Install scripts
8166
mkdir -p $out/share/auto-cpufreq/scripts
8267
install -Dm755 $root/scripts/cpufreqctl.sh $out/bin/cpufreqctl.auto-cpufreq
8368
install -Dm644 $root/scripts/style.css $out/share/auto-cpufreq/scripts/style.css
8469
85-
# Install systemd service
8670
mkdir -p $out/lib/systemd/system
8771
substitute $root/scripts/auto-cpufreq.service $out/lib/systemd/system/auto-cpufreq.service \
8872
--replace "/usr/local/bin/auto-cpufreq" "$out/bin/auto-cpufreq"
8973
90-
# Install images
9174
mkdir -p $out/share/pixmaps
9275
install -Dm644 $root/images/icon.png $out/share/pixmaps/auto-cpufreq.png
9376
94-
# Install polkit policy
9577
mkdir -p $out/share/polkit-1/actions
9678
substitute $root/scripts/org.auto-cpufreq.pkexec.policy \
9779
$out/share/polkit-1/actions/org.auto-cpufreq.pkexec.policy \
@@ -108,7 +90,6 @@
10890
};
10991
};
11092

111-
# Build auto-cpufreq with GUI
11293
auto-cpufreq-gui = pkgs.rustPlatform.buildRustPackage {
11394
pname = "auto-cpufreq-gui";
11495
version = "2.0.0-rust";
@@ -120,45 +101,37 @@
120101
};
121102

122103
nativeBuildInputs = commonNativeBuildInputs ++ [
123-
pkgs.wrapGAppsHook
104+
pkgs.wrapGAppsHook3
124105
pkgs.gobject-introspection
125106
];
126107

127108
buildInputs = commonBuildInputs ++ guiBuildInputs;
128109

129-
# Build with GUI features
130110
buildFeatures = [ "gui" ];
131-
132-
# Tests require root access
133111
doCheck = false;
134112

135113
postInstall = ''
136114
local root=${rootSrc}
137115
138-
# Install scripts
139116
mkdir -p $out/share/auto-cpufreq/scripts
140117
install -Dm755 $root/scripts/cpufreqctl.sh $out/bin/cpufreqctl.auto-cpufreq
141118
install -Dm644 $root/scripts/style.css $out/share/auto-cpufreq/scripts/style.css
142119
143-
# Install systemd service
144120
mkdir -p $out/lib/systemd/system
145121
substitute $root/scripts/auto-cpufreq.service $out/lib/systemd/system/auto-cpufreq.service \
146122
--replace "/usr/local/bin/auto-cpufreq" "$out/bin/auto-cpufreq"
147123
148-
# Install images
149124
mkdir -p $out/share/pixmaps
150125
mkdir -p $out/share/auto-cpufreq/images
151126
install -Dm644 $root/images/icon.png $out/share/pixmaps/auto-cpufreq.png
152127
install -Dm644 $root/images/icon.png $out/share/auto-cpufreq/images/icon.png
153128
154-
# Install desktop file
155129
mkdir -p $out/share/applications
156130
substitute $root/scripts/auto-cpufreq-gtk.desktop \
157131
$out/share/applications/auto-cpufreq-gtk.desktop \
158132
--replace "/usr/local/bin/auto-cpufreq-gtk" "$out/bin/auto-cpufreq-gtk" \
159133
--replace "/usr/share/pixmaps/auto-cpufreq.png" "$out/share/pixmaps/auto-cpufreq.png"
160134
161-
# Install polkit policy
162135
mkdir -p $out/share/polkit-1/actions
163136
substitute $root/scripts/org.auto-cpufreq.pkexec.policy \
164137
$out/share/polkit-1/actions/org.auto-cpufreq.pkexec.policy \
@@ -183,7 +156,6 @@
183156
auto-cpufreq-gui = auto-cpufreq-gui;
184157
};
185158

186-
# Development shell
187159
devShells.default = pkgs.mkShell {
188160
buildInputs = commonBuildInputs ++ guiBuildInputs ++ [
189161
rustToolchain
@@ -193,7 +165,7 @@
193165
];
194166

195167
nativeBuildInputs = commonNativeBuildInputs ++ [
196-
pkgs.wrapGAppsHook
168+
pkgs.wrapGAppsHook3
197169
pkgs.gobject-introspection
198170
];
199171

@@ -211,11 +183,6 @@
211183
};
212184
}
213185
) // {
214-
# NixOS module — exported under both keys so both
215-
# `nixosModules.default` and `nixosModules.auto-cpufreq` work.
216-
# FIX: module.nix references inputs.self.packages.${system}.auto-cpufreq
217-
# so self must be passed in. Previously only .default was exported,
218-
# causing `nix eval .#nixosModules.auto-cpufreq` to fail.
219186
nixosModules.default = import ./nix/module.nix self;
220187
nixosModules.auto-cpufreq = import ./nix/module.nix self;
221188
};

nix/shell.nix

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,27 @@
22

33
pkgs.mkShell {
44
buildInputs = with pkgs; [
5-
# Rust toolchain
65
rustc
76
cargo
87
rust-analyzer
98
clippy
109
rustfmt
11-
12-
# Build dependencies
1310
pkg-config
1411
openssl
15-
16-
# GUI dependencies (optional)
1712
gtk4
1813
glib
1914
cairo
2015
gdk-pixbuf
2116
pango
2217
libappindicator-gtk3
2318
gobject-introspection
24-
25-
# System utilities
2619
dmidecode
27-
28-
# Development tools
2920
git
3021
];
3122

3223
nativeBuildInputs = with pkgs; [
3324
pkg-config
34-
wrapGAppsHook
25+
wrapGAppsHook3
3526
];
3627

3728
shellHook = ''
@@ -55,6 +46,5 @@ pkgs.mkShell {
5546
echo ""
5647
'';
5748

58-
# Environment variables for build
5949
RUST_BACKTRACE = "1";
6050
}

0 commit comments

Comments
 (0)