refactor(nix): reorganise files
This commit is contained in:
parent
37e12a4266
commit
d710518c61
31
flake.nix
31
flake.nix
|
@ -1,21 +1,20 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
};
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
};
|
||||
|
||||
outputs = {self, nixpkgs}@inputs :
|
||||
let
|
||||
system = "x86_64-linux"; # replace this as needed
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
auto-cpufreq = pkgs.python3Packages.callPackage ./nix/default.nix {};
|
||||
in {
|
||||
packages.${system}.default = auto-cpufreq;
|
||||
outputs = {nixpkgs, ...} @ inputs: let
|
||||
forAllSystems = nixpkgs.lib.genAttrs ["x86_64-linux" "x86_64-darwin" "i686-linux" "aarch64-linux" "aarch64-darwin"];
|
||||
pkgsForEach = nixpkgs.legacyPackages;
|
||||
in {
|
||||
packages = forAllSystems (system: {
|
||||
default = pkgsForEach.${system}.python3Packages.callPackage ./nix/default.nix {};
|
||||
});
|
||||
|
||||
devShells.${system}.default = pkgs.mkShell {
|
||||
inputsFrom = [ auto-cpufreq ];
|
||||
packages = [ pkgs.python310Packages.pip ];
|
||||
};
|
||||
devShells = forAllSystems (system: {
|
||||
default = pkgsForEach.${system}.callPackage ./nix/shell.nix {};
|
||||
});
|
||||
|
||||
nixosModules.default = import ./nix/module.nix inputs;
|
||||
};
|
||||
nixosModules.default = import ./nix/module.nix inputs;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,39 +1,46 @@
|
|||
{ lib, python310Packages, fetchFromGitHub, callPackage, pkgs}:
|
||||
|
||||
python310Packages.buildPythonPackage rec {
|
||||
{
|
||||
lib,
|
||||
python310Packages,
|
||||
pkgs,
|
||||
}:
|
||||
python310Packages.buildPythonPackage {
|
||||
# use pyproject.toml instead of setup.py
|
||||
format = "pyproject";
|
||||
|
||||
pname = "auto-cpufreq";
|
||||
version = "2.0.0dev";
|
||||
version = "2.0.0";
|
||||
src = ../.;
|
||||
|
||||
nativeBuildInputs = with pkgs; [wrapGAppsHook gobject-introspection];
|
||||
|
||||
nativeBuildInputs = with pkgs; [ wrapGAppsHook gobject-introspection ];
|
||||
buildInputs = with pkgs; [gtk3 python310Packages.poetry-core];
|
||||
|
||||
buildInputs = with pkgs; [ gtk3 python310Packages.poetry-core ];
|
||||
|
||||
propagatedBuildInputs = with python310Packages; [ requests pygobject3 click distro psutil setuptools poetry-dynamic-versioning ];
|
||||
propagatedBuildInputs = with python310Packages; [requests pygobject3 click distro psutil setuptools poetry-dynamic-versioning];
|
||||
|
||||
doCheck = false;
|
||||
pythonImportsCheck = [ "auto_cpufreq" ];
|
||||
pythonImportsCheck = ["auto_cpufreq"];
|
||||
|
||||
patches = [
|
||||
|
||||
# patch to prevent script copying and to disable install
|
||||
# patch to prevent script copying and to disable install
|
||||
./patches/prevent-install-and-copy.patch
|
||||
|
||||
];
|
||||
|
||||
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/gui/app.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
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
# copy script manually
|
||||
cp scripts/cpufreqctl.sh $out/bin/cpufreqctl.auto-cpufreq
|
||||
|
||||
# move the css to the rihgt place
|
||||
mkdir -p $out/share/auto-cpufreq/scripts
|
||||
cp scripts/style.css $out/share/auto-cpufreq/scripts/style.css
|
||||
|
||||
# systemd service
|
||||
mkdir -p $out/lib/systemd/system
|
||||
cp scripts/auto-cpufreq.service $out/lib/systemd/system
|
||||
|
@ -55,7 +62,7 @@ python310Packages.buildPythonPackage rec {
|
|||
description = "Automatic CPU speed & power optimizer for Linux";
|
||||
license = licenses.lgpl3Plus;
|
||||
platforms = platforms.linux;
|
||||
maintainers = [ maintainers.Technical27 ];
|
||||
maintainers = [maintainers.Technical27];
|
||||
mainProgram = "auto-cpufreq";
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,43 +1,46 @@
|
|||
inputs: { config, lib, pkgs, options, ... }:
|
||||
|
||||
inputs: {
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
options,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.programs.auto-cpufreq;
|
||||
system = "x86_64-linux";
|
||||
defaultPackage = inputs.self.packages.${system}.default;
|
||||
cfgFilename = "auto-cpufreq.conf";
|
||||
cfgFile = format.generate cfgFilename cfg.settings;
|
||||
|
||||
cfg = config.programs.auto-cpufreq;
|
||||
system = "x86_64-linux";
|
||||
defaultPackage = inputs.self.packages.${system}.default;
|
||||
cfgFilename = "auto-cpufreq.conf";
|
||||
cfgFile = format.generate cfgFilename cfg.settings;
|
||||
|
||||
format = pkgs.formats.ini {};
|
||||
|
||||
format = pkgs.formats.ini {};
|
||||
in {
|
||||
options.programs.auto-cpufreq = {
|
||||
enable = mkEnableOption "Automatic CPU speed & power optimizer for Linux";
|
||||
#gui.enable = mkEnableOption "Enable GUI";
|
||||
|
||||
options.programs.auto-cpufreq = {
|
||||
enable = mkEnableOption "Automatic CPU speed & power optimizer for Linux";
|
||||
settings = mkOption {
|
||||
description = mdDoc ''
|
||||
Configuration for `auto-cpufreq`.
|
||||
|
||||
settings = mkOption {
|
||||
description = lib.mdDoc ''
|
||||
Configuration for `auto-cpufreq`.
|
||||
See its [example configuration file] for supported settings.
|
||||
[example configuration file]: https://github.com/AdnanHodzic/auto-cpufreq/blob/master/auto-cpufreq.conf-example
|
||||
'';
|
||||
|
||||
See its [example configuration file] for supported settings.
|
||||
[example configuration file]: https://github.com/AdnanHodzic/auto-cpufreq/blob/master/auto-cpufreq.conf-example
|
||||
'';
|
||||
|
||||
default = {};
|
||||
type = types.submodule { freeformType = format.type; };
|
||||
};
|
||||
default = {};
|
||||
type = types.submodule {freeformType = format.type;};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
environment.systemPackages = [ defaultPackage ];
|
||||
config = mkIf cfg.enable {
|
||||
environment.systemPackages = [defaultPackage];
|
||||
|
||||
services.auto-cpufreq.enable = true;
|
||||
systemd.services.auto-cpufreq = {
|
||||
overrideStrategy = "asDropin";
|
||||
serviceConfig.ExecStart = lib.mkForce [
|
||||
""
|
||||
"${defaultPackage}/bin/auto-cpufreq --daemon --config ${cfgFile}"
|
||||
];
|
||||
};
|
||||
services.auto-cpufreq.enable = true;
|
||||
systemd.services.auto-cpufreq = {
|
||||
overrideStrategy = "asDropin";
|
||||
serviceConfig.ExecStart = mkForce [
|
||||
""
|
||||
"${getBin} ${defaultPackage} --daemon --config ${cfgFile}"
|
||||
];
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
python310Packages,
|
||||
python3Packages,
|
||||
...
|
||||
}: let
|
||||
mainPkg = python3Packages.callPackage ./default.nix {};
|
||||
in
|
||||
mainPkg.overrideAttrs (oa: {
|
||||
nativeBuildInputs =
|
||||
[
|
||||
python310Packages.pip
|
||||
]
|
||||
++ (oa.nativeBuildInputs or []);
|
||||
})
|
Loading…
Reference in New Issue