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