Unverified Commit d2085f48 authored by h7x4's avatar h7x4 Committed by GitHub
Browse files

dell-bios-fan-control: init package and module (#439978)

parents 11973bc8 1547ceaf
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@
  If your SQLite database is corrupted, the migration might fail and require [manual intervention](https://github.com/louislam/uptime-kuma/issues/5281).
  See the [migration guide](https://github.com/louislam/uptime-kuma/wiki/Migration-From-v1-To-v2) for more information.

- Added `dell-bios-fan-control` package and service.

- We now use the upstream wrapper script for Gradle, supporting both the `JAVA_HOME` and `GRADLE_OPTS` environment variables.

## Nixpkgs Library {#sec-nixpkgs-release-26.05-lib}
+5 −0
Original line number Diff line number Diff line
@@ -22190,6 +22190,11 @@
    githubId = 13792812;
    name = "James Leitch";
  };
  rickyelopez = {
    github = "rickyelopez";
    githubId = 31072564;
    name = "Ricky";
  };
  rickynils = {
    email = "rickynils@gmail.com";
    github = "rickynils";
+1 −0
Original line number Diff line number Diff line
@@ -651,6 +651,7 @@
  ./services/hardware/buffyboard.nix
  ./services/hardware/ddccontrol.nix
  ./services/hardware/deepcool-digital-linux.nix
  ./services/hardware/dell-bios-fan-control.nix
  ./services/hardware/display.nix
  ./services/hardware/fancontrol.nix
  ./services/hardware/freefall.nix
+49 −0
Original line number Diff line number Diff line
{
  config,
  pkgs,
  lib,
  ...
}:
let
  cfg = config.services.hardware.dell-bios-fan-control;
in
{
  meta.maintainers = with lib.maintainers; [ rickyelopez ];

  options.services.hardware.dell-bios-fan-control = {
    enable = lib.mkEnableOption "One-shot service to disable dell bios fan control on startup";
    package = lib.mkPackageOption pkgs "dell-bios-fan-control" { };
  };

  config = lib.mkIf cfg.enable {
    boot.kernelModules = [ "i8k" ];
    environment.systemPackages = [ cfg.package ];
    # see ref in aur: https://aur.archlinux.org/cgit/aur.git/tree/dell-bios-fan-control.service?h=dell-bios-fan-control-git
    systemd.services.dell-bios-fan-control = {
      description = "Disables BIOS control of fans at boot.";
      wants = [ "dell-bios-fan-control-resume.service" ];
      wantedBy = [ "multi-user.target" ];
      before = [ "i8kmon.service" ];
      serviceConfig = {
        Type = "oneshot";
        RemainAfterExit = true;
        ExecStart = "${lib.getExe cfg.package} 0";
        ExecStop = "${lib.getExe cfg.package} 1";
      };
    };

    # see ref in aur: https://aur.archlinux.org/cgit/aur.git/tree/dell-bios-fan-control-resume.service?h=dell-bios-fan-control-git
    systemd.services.dell-bios-fan-control-resume = {
      description = "Restart dell-bios-fan-control on resume.";
      wants = [ "dell-bios-fan-control.service" ];
      wantedBy = [ "suspend.target" ];
      after = [ "suspend.target" ];
      serviceConfig = {
        Type = "oneshot";
        # re: sleep, see: https://github.com/NixOS/nixpkgs/pull/439978#discussion_r2404279441
        ExecStartPre = "${pkgs.coreutils}/bin/sleep 30";
        ExecStart = "${config.systemd.package}/bin/systemctl restart dell-bios-fan-control.service";
      };
    };
  };
}
+40 −0
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  fetchFromGitHub,
  installShellFiles,
}:
stdenv.mkDerivation {
  pname = "dell-bios-fan-control";
  version = "0-unstable-2022-01-19";

  src = fetchFromGitHub {
    owner = "TomFreudenberg";
    repo = "dell-bios-fan-control";
    rev = "27006106595bccd6c309da4d1499f93d38903f9a";
    hash = "sha256-3ihzvwL86c9VJDfGpbWpkOwZ7qU0E5U2UuOeCwPMR1s=";
  };

  nativeBuildInputs = [ installShellFiles ];

  hardeningDisable = [
    "fortify"
  ];

  installPhase = ''
    runHook preInstall

    installBin dell-bios-fan-control

    runHook postInstall
  '';

  meta = {
    description = "Simple tool to enable or disable the SMBIOS (auto) fan control on various Dell laptops";
    homepage = "https://github.com/TomFreudenberg/dell-bios-fan-control";
    license = lib.licenses.gpl2Plus;
    mainProgram = "dell-bios-fan-control";
    maintainers = with lib.maintainers; [ rickyelopez ];
    platforms = [ "x86_64-linux" ];
  };
}