Skip to content

Commit d1738fa

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

4 files changed

Lines changed: 10 additions & 64 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 -I nixpkgs=channel:nixos-unstable 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: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,17 @@
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
28+
dbus
2929
];
3030

3131
commonNativeBuildInputs = with pkgs; [
3232
rustToolchain
3333
pkg-config
3434
];
3535

36-
# GUI-specific dependencies
3736
guiBuildInputs = with pkgs; [
3837
gtk4
3938
glib
@@ -43,16 +42,9 @@
4342
gobject-introspection
4443
];
4544

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
4945
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.
5346
rootSrc = ./.;
5447

55-
# Build auto-cpufreq without GUI
5648
auto-cpufreq-base = pkgs.rustPlatform.buildRustPackage {
5749
pname = "auto-cpufreq";
5850
version = "2.0.0-rust";
@@ -66,32 +58,23 @@
6658
nativeBuildInputs = commonNativeBuildInputs;
6759
buildInputs = commonBuildInputs;
6860

69-
# Don't build GUI features
7061
buildNoDefaultFeatures = true;
71-
72-
# Tests require root access
7362
doCheck = false;
7463

7564
postInstall = ''
76-
# Scripts and assets are in repo root, not in cargoSrc.
77-
# Copy them in from rootSrc via the store path.
7865
local root=${rootSrc}
7966
80-
# Install scripts
8167
mkdir -p $out/share/auto-cpufreq/scripts
8268
install -Dm755 $root/scripts/cpufreqctl.sh $out/bin/cpufreqctl.auto-cpufreq
8369
install -Dm644 $root/scripts/style.css $out/share/auto-cpufreq/scripts/style.css
8470
85-
# Install systemd service
8671
mkdir -p $out/lib/systemd/system
8772
substitute $root/scripts/auto-cpufreq.service $out/lib/systemd/system/auto-cpufreq.service \
8873
--replace "/usr/local/bin/auto-cpufreq" "$out/bin/auto-cpufreq"
8974
90-
# Install images
9175
mkdir -p $out/share/pixmaps
9276
install -Dm644 $root/images/icon.png $out/share/pixmaps/auto-cpufreq.png
9377
94-
# Install polkit policy
9578
mkdir -p $out/share/polkit-1/actions
9679
substitute $root/scripts/org.auto-cpufreq.pkexec.policy \
9780
$out/share/polkit-1/actions/org.auto-cpufreq.pkexec.policy \
@@ -108,7 +91,6 @@
10891
};
10992
};
11093

111-
# Build auto-cpufreq with GUI
11294
auto-cpufreq-gui = pkgs.rustPlatform.buildRustPackage {
11395
pname = "auto-cpufreq-gui";
11496
version = "2.0.0-rust";
@@ -120,45 +102,37 @@
120102
};
121103

122104
nativeBuildInputs = commonNativeBuildInputs ++ [
123-
pkgs.wrapGAppsHook
105+
pkgs.wrapGAppsHook3
124106
pkgs.gobject-introspection
125107
];
126108

127109
buildInputs = commonBuildInputs ++ guiBuildInputs;
128110

129-
# Build with GUI features
130111
buildFeatures = [ "gui" ];
131-
132-
# Tests require root access
133112
doCheck = false;
134113

135114
postInstall = ''
136115
local root=${rootSrc}
137116
138-
# Install scripts
139117
mkdir -p $out/share/auto-cpufreq/scripts
140118
install -Dm755 $root/scripts/cpufreqctl.sh $out/bin/cpufreqctl.auto-cpufreq
141119
install -Dm644 $root/scripts/style.css $out/share/auto-cpufreq/scripts/style.css
142120
143-
# Install systemd service
144121
mkdir -p $out/lib/systemd/system
145122
substitute $root/scripts/auto-cpufreq.service $out/lib/systemd/system/auto-cpufreq.service \
146123
--replace "/usr/local/bin/auto-cpufreq" "$out/bin/auto-cpufreq"
147124
148-
# Install images
149125
mkdir -p $out/share/pixmaps
150126
mkdir -p $out/share/auto-cpufreq/images
151127
install -Dm644 $root/images/icon.png $out/share/pixmaps/auto-cpufreq.png
152128
install -Dm644 $root/images/icon.png $out/share/auto-cpufreq/images/icon.png
153129
154-
# Install desktop file
155130
mkdir -p $out/share/applications
156131
substitute $root/scripts/auto-cpufreq-gtk.desktop \
157132
$out/share/applications/auto-cpufreq-gtk.desktop \
158133
--replace "/usr/local/bin/auto-cpufreq-gtk" "$out/bin/auto-cpufreq-gtk" \
159134
--replace "/usr/share/pixmaps/auto-cpufreq.png" "$out/share/pixmaps/auto-cpufreq.png"
160135
161-
# Install polkit policy
162136
mkdir -p $out/share/polkit-1/actions
163137
substitute $root/scripts/org.auto-cpufreq.pkexec.policy \
164138
$out/share/polkit-1/actions/org.auto-cpufreq.pkexec.policy \
@@ -183,7 +157,6 @@
183157
auto-cpufreq-gui = auto-cpufreq-gui;
184158
};
185159

186-
# Development shell
187160
devShells.default = pkgs.mkShell {
188161
buildInputs = commonBuildInputs ++ guiBuildInputs ++ [
189162
rustToolchain
@@ -193,7 +166,7 @@
193166
];
194167

195168
nativeBuildInputs = commonNativeBuildInputs ++ [
196-
pkgs.wrapGAppsHook
169+
pkgs.wrapGAppsHook3
197170
pkgs.gobject-introspection
198171
];
199172

@@ -211,11 +184,6 @@
211184
};
212185
}
213186
) // {
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.
219187
nixosModules.default = import ./nix/module.nix self;
220188
nixosModules.auto-cpufreq = import ./nix/module.nix self;
221189
};

nix/default.nix

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ let
66
# FIX: src and lockFile must point to the auto-cpufreq/ subdirectory,
77
# not the repo root. Previously both were ./. and ./Cargo.lock which
88
# don't exist at root level.
9-
cargoSrc = ./auto-cpufreq;
9+
cargoSrc = ../auto-cpufreq;
1010
rootSrc = ./.;
1111
in
1212

1313
rustPlatform.buildRustPackage rec {
1414
pname = "auto-cpufreq";
15-
version = "2.0.0-rust";
15+
version = "3.0.2";
1616

1717
src = cargoSrc;
1818

1919
cargoLock = {
20-
lockFile = ./auto-cpufreq/Cargo.lock;
20+
lockFile = ../auto-cpufreq/Cargo.lock;
2121
};
2222

2323
nativeBuildInputs = with pkgs; [
@@ -28,6 +28,8 @@ rustPlatform.buildRustPackage rec {
2828

2929
buildInputs = with pkgs; [
3030
openssl
31+
dbus
32+
libxml2
3133
];
3234

3335
# Don't build GUI features by default

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)