|
22 | 22 | extensions = [ "rust-src" "rust-analyzer" ]; |
23 | 23 | }; |
24 | 24 |
|
25 | | - # Common inputs for both GUI and non-GUI builds |
26 | 25 | commonBuildInputs = with pkgs; [ |
27 | 26 | pkg-config |
28 | 27 | openssl |
| 28 | + dbus |
29 | 29 | ]; |
30 | 30 |
|
31 | 31 | commonNativeBuildInputs = with pkgs; [ |
32 | 32 | rustToolchain |
33 | 33 | pkg-config |
34 | 34 | ]; |
35 | 35 |
|
36 | | - # GUI-specific dependencies |
37 | 36 | guiBuildInputs = with pkgs; [ |
38 | 37 | gtk4 |
39 | 38 | glib |
|
43 | 42 | gobject-introspection |
44 | 43 | ]; |
45 | 44 |
|
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 |
49 | 45 | 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. |
53 | 46 | rootSrc = ./.; |
54 | 47 |
|
55 | | - # Build auto-cpufreq without GUI |
56 | 48 | auto-cpufreq-base = pkgs.rustPlatform.buildRustPackage { |
57 | 49 | pname = "auto-cpufreq"; |
58 | 50 | version = "2.0.0-rust"; |
|
66 | 58 | nativeBuildInputs = commonNativeBuildInputs; |
67 | 59 | buildInputs = commonBuildInputs; |
68 | 60 |
|
69 | | - # Don't build GUI features |
70 | 61 | buildNoDefaultFeatures = true; |
71 | | - |
72 | | - # Tests require root access |
73 | 62 | doCheck = false; |
74 | 63 |
|
75 | 64 | postInstall = '' |
76 | | - # Scripts and assets are in repo root, not in cargoSrc. |
77 | | - # Copy them in from rootSrc via the store path. |
78 | 65 | local root=${rootSrc} |
79 | 66 |
|
80 | | - # Install scripts |
81 | 67 | mkdir -p $out/share/auto-cpufreq/scripts |
82 | 68 | install -Dm755 $root/scripts/cpufreqctl.sh $out/bin/cpufreqctl.auto-cpufreq |
83 | 69 | install -Dm644 $root/scripts/style.css $out/share/auto-cpufreq/scripts/style.css |
84 | 70 |
|
85 | | - # Install systemd service |
86 | 71 | mkdir -p $out/lib/systemd/system |
87 | 72 | substitute $root/scripts/auto-cpufreq.service $out/lib/systemd/system/auto-cpufreq.service \ |
88 | 73 | --replace "/usr/local/bin/auto-cpufreq" "$out/bin/auto-cpufreq" |
89 | 74 |
|
90 | | - # Install images |
91 | 75 | mkdir -p $out/share/pixmaps |
92 | 76 | install -Dm644 $root/images/icon.png $out/share/pixmaps/auto-cpufreq.png |
93 | 77 |
|
94 | | - # Install polkit policy |
95 | 78 | mkdir -p $out/share/polkit-1/actions |
96 | 79 | substitute $root/scripts/org.auto-cpufreq.pkexec.policy \ |
97 | 80 | $out/share/polkit-1/actions/org.auto-cpufreq.pkexec.policy \ |
|
108 | 91 | }; |
109 | 92 | }; |
110 | 93 |
|
111 | | - # Build auto-cpufreq with GUI |
112 | 94 | auto-cpufreq-gui = pkgs.rustPlatform.buildRustPackage { |
113 | 95 | pname = "auto-cpufreq-gui"; |
114 | 96 | version = "2.0.0-rust"; |
|
120 | 102 | }; |
121 | 103 |
|
122 | 104 | nativeBuildInputs = commonNativeBuildInputs ++ [ |
123 | | - pkgs.wrapGAppsHook |
| 105 | + pkgs.wrapGAppsHook3 |
124 | 106 | pkgs.gobject-introspection |
125 | 107 | ]; |
126 | 108 |
|
127 | 109 | buildInputs = commonBuildInputs ++ guiBuildInputs; |
128 | 110 |
|
129 | | - # Build with GUI features |
130 | 111 | buildFeatures = [ "gui" ]; |
131 | | - |
132 | | - # Tests require root access |
133 | 112 | doCheck = false; |
134 | 113 |
|
135 | 114 | postInstall = '' |
136 | 115 | local root=${rootSrc} |
137 | 116 |
|
138 | | - # Install scripts |
139 | 117 | mkdir -p $out/share/auto-cpufreq/scripts |
140 | 118 | install -Dm755 $root/scripts/cpufreqctl.sh $out/bin/cpufreqctl.auto-cpufreq |
141 | 119 | install -Dm644 $root/scripts/style.css $out/share/auto-cpufreq/scripts/style.css |
142 | 120 |
|
143 | | - # Install systemd service |
144 | 121 | mkdir -p $out/lib/systemd/system |
145 | 122 | substitute $root/scripts/auto-cpufreq.service $out/lib/systemd/system/auto-cpufreq.service \ |
146 | 123 | --replace "/usr/local/bin/auto-cpufreq" "$out/bin/auto-cpufreq" |
147 | 124 |
|
148 | | - # Install images |
149 | 125 | mkdir -p $out/share/pixmaps |
150 | 126 | mkdir -p $out/share/auto-cpufreq/images |
151 | 127 | install -Dm644 $root/images/icon.png $out/share/pixmaps/auto-cpufreq.png |
152 | 128 | install -Dm644 $root/images/icon.png $out/share/auto-cpufreq/images/icon.png |
153 | 129 |
|
154 | | - # Install desktop file |
155 | 130 | mkdir -p $out/share/applications |
156 | 131 | substitute $root/scripts/auto-cpufreq-gtk.desktop \ |
157 | 132 | $out/share/applications/auto-cpufreq-gtk.desktop \ |
158 | 133 | --replace "/usr/local/bin/auto-cpufreq-gtk" "$out/bin/auto-cpufreq-gtk" \ |
159 | 134 | --replace "/usr/share/pixmaps/auto-cpufreq.png" "$out/share/pixmaps/auto-cpufreq.png" |
160 | 135 |
|
161 | | - # Install polkit policy |
162 | 136 | mkdir -p $out/share/polkit-1/actions |
163 | 137 | substitute $root/scripts/org.auto-cpufreq.pkexec.policy \ |
164 | 138 | $out/share/polkit-1/actions/org.auto-cpufreq.pkexec.policy \ |
|
183 | 157 | auto-cpufreq-gui = auto-cpufreq-gui; |
184 | 158 | }; |
185 | 159 |
|
186 | | - # Development shell |
187 | 160 | devShells.default = pkgs.mkShell { |
188 | 161 | buildInputs = commonBuildInputs ++ guiBuildInputs ++ [ |
189 | 162 | rustToolchain |
|
193 | 166 | ]; |
194 | 167 |
|
195 | 168 | nativeBuildInputs = commonNativeBuildInputs ++ [ |
196 | | - pkgs.wrapGAppsHook |
| 169 | + pkgs.wrapGAppsHook3 |
197 | 170 | pkgs.gobject-introspection |
198 | 171 | ]; |
199 | 172 |
|
|
211 | 184 | }; |
212 | 185 | } |
213 | 186 | ) // { |
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. |
219 | 187 | nixosModules.default = import ./nix/module.nix self; |
220 | 188 | nixosModules.auto-cpufreq = import ./nix/module.nix self; |
221 | 189 | }; |
|
0 commit comments