fanctrl: init at 1.0.3; add nixos module (#388514)

This commit is contained in:
Wolfgang Walther
2025-07-13 16:36:41 +00:00
committed by GitHub
4 changed files with 175 additions and 0 deletions
@@ -56,6 +56,8 @@
- [Sharkey](https://joinsharkey.org), a Sharkish microblogging platform. Available as [services.sharkey](#opt-services.sharkey.enable).
- [fw-fanctrl](https://github.com/TamtamHero/fw-fanctrl), a simple systemd service to better control Framework Laptop's fan(s). Available as [hardware.fw-fanctrl](#opt-hardware.fw-fanctrl.enable).
- [mautrix-discord](https://github.com/mautrix/discord), a Matrix-Discord puppeting/relay bridge. Available as [services.mautrix-discord](#opt-services.mautrix-discord.enable).
- [SuiteNumérique Meet](https://github.com/suitenumerique/meet) is an open source alternative to Google Meet and Zoom powered by LiveKit: HD video calls, screen sharing, and chat features. Built with Django and React. Available as [services.lasuite-meet](#opt-services.lasuite-meet.enable).
+129
View File
@@ -0,0 +1,129 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.hardware.fw-fanctrl;
configFormat = pkgs.formats.json { };
configOption = configFormat.generate "config.json" cfg.config;
configFile = pkgs.runCommand "configFile" { } ''
${lib.getExe pkgs.jq} -s '.[0] * .[1]' ${pkgs.fw-fanctrl}/share/fw-fanctrl/config.json ${configOption} > $out
'';
in
{
options.hardware.fw-fanctrl = {
enable = lib.mkEnableOption "the fw-fanctrl systemd service and install the needed packages";
disableBatteryTempCheck = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Disable checking battery temperature sensor
'';
};
config = lib.mkOption {
default = { };
description = ''
Additional config entries for the fw-fanctrl service (documentation: https://github.com/TamtamHero/fw-fanctrl/blob/main/doc/configuration.md)
'';
type = lib.types.submodule {
freeformType = configFormat.type;
options = {
defaultStrategy = lib.mkOption {
type = lib.types.str;
default = "lazy";
description = "Default strategy to use";
};
strategyOnDischarging = lib.mkOption {
type = lib.types.str;
default = "";
description = "Default strategy on discharging";
};
strategies = lib.mkOption {
default = null;
description = ''
Additional strategies which can be used by fw-fanctrl
'';
type = lib.types.nullOr (
lib.types.attrsOf (
lib.types.submodule {
options = {
fanSpeedUpdateFrequency = lib.mkOption {
type = lib.types.ints.unsigned;
default = 5;
description = "How often the fan speed should be updated in seconds";
};
movingAverageInterval = lib.mkOption {
type = lib.types.ints.unsigned;
default = 25;
description = "Interval (seconds) of the last temperatures to use to calculate the average temperature";
};
speedCurve = lib.mkOption {
default = [ ];
description = "How should the speed curve look like";
type = lib.types.listOf (
lib.types.submodule {
options = {
temp = lib.mkOption {
type = lib.types.int;
default = 0;
description = "Temperature in °C at which the fan speed should be changed";
};
speed = lib.mkOption {
type = lib.types.ints.between 0 100;
default = 0;
description = "Percent how fast the fan should run at";
};
};
}
);
};
};
}
)
);
};
};
};
};
};
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [
fw-fanctrl
fw-ectool
];
systemd.services.fw-fanctrl = {
description = "Framework Fan Controller";
after = [ "multi-user.target" ];
serviceConfig = {
Type = "simple";
Restart = "always";
ExecStart = "${lib.getExe pkgs.fw-fanctrl} --output-format JSON run --config ${configFile} --silent ${lib.optionalString cfg.disableBatteryTempCheck "--no-battery-sensors"}";
ExecStopPost = "${lib.getExe pkgs.fw-ectool} autofanctrl";
};
wantedBy = [ "multi-user.target" ];
};
# Create suspend config
environment.etc."systemd/system-sleep/fw-fanctrl-suspend.sh".source =
"${pkgs.fw-fanctrl}/share/fw-fanctrl/fw-fanctrl-suspend";
};
meta = {
maintainers = pkgs.fw-fanctrl.meta.maintainers;
};
}
+1
View File
@@ -67,6 +67,7 @@
./hardware/digitalbitbox.nix
./hardware/flipperzero.nix
./hardware/flirc.nix
./hardware/fw-fanctrl.nix
./hardware/glasgow.nix
./hardware/gpgsmartcards.nix
./hardware/graphics.nix
+43
View File
@@ -0,0 +1,43 @@
{
lib,
python3Packages,
fw-ectool,
fetchFromGitHub,
}:
python3Packages.buildPythonPackage rec {
pname = "fw-fanctrl";
version = "1.0.3";
pyproject = true;
src = fetchFromGitHub {
owner = "TamtamHero";
repo = "fw-fanctrl";
tag = "v${version}";
hash = "sha256-TDVULNb/oH66/UX20mC89NSx8YPe8mPwNCB9+phavP4=";
};
build-system = [ python3Packages.setuptools ];
dependencies = [ python3Packages.jsonschema ];
makeWrapperArgs = [ "--prefix PATH : ${lib.makeBinPath [ fw-ectool ]}" ];
postInstall = ''
mkdir -p $out/share/fw-fanctrl
install -m 644 $src/src/fw_fanctrl/_resources/config.json $out/share/fw-fanctrl/config.json
install -m 755 $src/services/system-sleep/fw-fanctrl-suspend $out/share/fw-fanctrl/fw-fanctrl-suspend
patchShebangs --build $out/share/fw-fanctrl/fw-fanctrl-suspend
substituteInPlace $out/share/fw-fanctrl/fw-fanctrl-suspend \
--replace-fail '"%PYTHON_SCRIPT_INSTALLATION_PATH%"' $out/bin/fw-fanctrl
'';
meta = {
mainProgram = "fw-fanctrl";
homepage = "https://github.com/TamtamHero/fw-fanctrl";
description = "Simple systemd service to better control Framework Laptop's fan(s)";
platforms = lib.platforms.linux;
license = lib.licenses.bsd3;
maintainers = [ lib.maintainers.Svenum ];
};
}