nix: add overlay; use best practices (#718)
* feat(nix): add overlay * refactor(nix): use best practices * chore: update flake inputs * refactor(nix): remove unused replace
This commit is contained in:
parent
3f6d7a3e77
commit
7313ec9b8c
|
@ -2,11 +2,11 @@
|
|||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1700823757,
|
||||
"narHash": "sha256-PStAVLO8ycnFBSThYKTFwQ6rw+OH4ZM5KiN0fRE0OuM=",
|
||||
"lastModified": 1717112898,
|
||||
"narHash": "sha256-7R2ZvOnvd9h8fDd65p0JnB7wXfUvreox3xFdYWd1BnY=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "068bacb9b6fbee6a603d1b1f68d7cf032c4feed1",
|
||||
"rev": "6132b0f6e344ce2fe34fc051b72fb46e34f668e0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -15,6 +15,10 @@
|
|||
default = pkgsForEach.${system}.callPackage ./nix/shell.nix {};
|
||||
});
|
||||
|
||||
overlays.default = final: _: {
|
||||
auto-cpufreq = final.callPackage ./nix/default.nix {};
|
||||
};
|
||||
|
||||
nixosModules.default = import ./nix/module.nix inputs;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -57,11 +57,11 @@ python3Packages.buildPythonPackage {
|
|||
];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace auto_cpufreq/core.py --replace '/opt/auto-cpufreq/override.pickle' /var/run/override.pickle
|
||||
substituteInPlace scripts/org.auto-cpufreq.pkexec.policy --replace "/opt/auto-cpufreq/venv/bin/auto-cpufreq" $out/bin/auto-cpufreq
|
||||
substituteInPlace auto_cpufreq/core.py --replace-fail '/opt/auto-cpufreq/override.pickle' /var/run/override.pickle
|
||||
substituteInPlace scripts/org.auto-cpufreq.pkexec.policy --replace-fail "/opt/auto-cpufreq/venv/bin/auto-cpufreq" $out/bin/auto-cpufreq
|
||||
|
||||
substituteInPlace auto_cpufreq/gui/app.py auto_cpufreq/gui/objects.py --replace "/usr/local/share/auto-cpufreq/images/icon.png" $out/share/pixmaps/auto-cpufreq.png
|
||||
substituteInPlace auto_cpufreq/gui/app.py --replace "/usr/local/share/auto-cpufreq/scripts/style.css" $out/share/auto-cpufreq/scripts/style.css
|
||||
substituteInPlace auto_cpufreq/gui/app.py auto_cpufreq/gui/objects.py --replace-fail "/usr/local/share/auto-cpufreq/images/icon.png" $out/share/pixmaps/auto-cpufreq.png
|
||||
substituteInPlace auto_cpufreq/gui/app.py --replace-fail "/usr/local/share/auto-cpufreq/scripts/style.css" $out/share/auto-cpufreq/scripts/style.css
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
|
@ -75,7 +75,6 @@ python3Packages.buildPythonPackage {
|
|||
# systemd service
|
||||
mkdir -p $out/lib/systemd/system
|
||||
cp scripts/auto-cpufreq.service $out/lib/systemd/system
|
||||
substituteInPlace $out/lib/systemd/system/auto-cpufreq.service --replace "/usr/local" $out
|
||||
|
||||
# desktop icon
|
||||
mkdir -p $out/share/applications
|
||||
|
@ -88,12 +87,12 @@ python3Packages.buildPythonPackage {
|
|||
cp scripts/org.auto-cpufreq.pkexec.policy $out/share/polkit-1/actions
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
meta = {
|
||||
homepage = "https://github.com/AdnanHodzic/auto-cpufreq";
|
||||
description = "Automatic CPU speed & power optimizer for Linux";
|
||||
license = licenses.lgpl3Plus;
|
||||
platforms = platforms.linux;
|
||||
maintainers = [maintainers.Technical27];
|
||||
license = lib.licenses.lgpl3Plus;
|
||||
platforms = lib.platforms.linux;
|
||||
maintainers = with lib.maintainers; [Technical27];
|
||||
mainProgram = "auto-cpufreq";
|
||||
};
|
||||
}
|
||||
|
|
|
@ -2,23 +2,26 @@ inputs: {
|
|||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
options,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
let
|
||||
cfg = config.programs.auto-cpufreq;
|
||||
inherit (pkgs.stdenv.hostPlatform) system;
|
||||
defaultPackage = inputs.self.packages.${system}.default;
|
||||
cfgFilename = "auto-cpufreq.conf";
|
||||
cfgFile = format.generate cfgFilename cfg.settings;
|
||||
|
||||
inherit (lib) types;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
|
||||
format = pkgs.formats.ini {};
|
||||
in {
|
||||
options.programs.auto-cpufreq = {
|
||||
enable = mkEnableOption "Automatic CPU speed & power optimizer for Linux";
|
||||
|
||||
settings = mkOption {
|
||||
description = mdDoc ''
|
||||
description = ''
|
||||
Configuration for `auto-cpufreq`.
|
||||
|
||||
See its [example configuration file] for supported settings.
|
||||
|
|
Loading…
Reference in New Issue