Program needs to be run once on Arch Live CD to work on nixos

Hello, I recently switched to nixos from Arch on my dell xps 15 9550. On Arch in AUR there was utility called dell-bios-fan-control that was used to disable control of fans by bios so that they can be controled by utilities like i8kutils so that they are not running all the time at low speeds producing unnecessary noise.

I packaged dell-bios-fan-control for nix using this expression:

{ lib, stdenv, fetchFromGitHub }:

stdenv.mkDerivation {
  pname = "dell-bios-fan-control";
  name = "dell-bios-fan-control";
  version = "unstable-2018-05-21";

  src = fetchFromGitHub {
    owner = "TomFreudenberg";
    repo = "dell-bios-fan-control";
    rev = "a2c81a2918b15b97bdb1c6bf41233e4c2786d416";
    sha256 = "isd8dNgLJCTR405TcH0CaLf2uXd4luJYBSB9ZiRhLLQ=";
  };

  installPhase = ''
    runHook preInstall
    mkdir -p $out/bin
    cp dell-bios-fan-control $out/bin/dell-bios-fan-control
    chmod +rx $out/bin/dell-bios-fan-control
    runHook postInstall
    '';
  meta = {
    homepage = "https://github.com/TomFreudenberg/dell-bios-fan-control";
    description = "Tool to enable or disable the SMBIOS fan control on Dell laptops";
    # This seems to be based on https://github.com/clopez/dellfan, which is gpl2
    license = lib.licenses.gpl2Plus;
    platforms = [ "x86_64-linux" ];
    maintainers = [];
  };
}

But when i try to run it it does not work, sort of. I tried to boot into Arch live cd to check maybe my config on previous arch install were different and maybe it was working because of that, I booted into live cd, installed dell-bios-fan-control-git from AUR on it, run it once and it worked fine on live cd. I thought I would just report it as a bug to nix, but after rebooting from live cd to nixos I tried to use it again on nixos and it worked just fine, but after shutting down my pc it stops working again (it does not stop working after rebooting).

So my questions are:

  • Does anyone have any idea why this might be happening? The only possible difference that comes to my mind from my arch install is that i use disk encryption on nixos, otherwise i think it is mostly the same
  • Are there maybe some alternatives to this program? I found nbfc that may work, but it is not packaged for nix and I cant package it myself

did you take a look at?

https://nixos.wiki/wiki/Nixpkgs/Create_and_debug_packages#Using_nix-shell_for_package_development

There is some good information about what you’re trying to achieve, also take a look in the phases of the build process which could potentially help you debug this issue, specially the buildPhase

you could also provide some kind of ouput to see if there’s some relevant information

1 Like

Sorry if I wasn’t clear about it, package builds and when running prints expected output, but does nothing except printing output when run on nixos.

When i execute sudo dell-bios-fan-control 0 it replies me with BIOS CONTROL DISABLED as it should, however fan control is not disabled and when I try to control fan speeds, for example via i8kctl fan 2 2 to set fans to max speed it does the same thing as if dell-bios-fan-control 0 was never run - tries to change fan speed and fails.
The expected result is that after i run sudo dell-bios-fan-control 0 I should be able to be control fans with utilities like i8kctl, or any other utility that controls fans.

This was working properly on Arch Linux install, and I found hack that allows me to make it work on nixos too, that is - boot into Arch Live CD, build and run the same program on it and reboot into nixos. This makes program work as expected, but only until I shutdown my laptop.

I am trying to find out the why this hack is needed when on Arch it just works, or if there are any other tool that allows disabling bios fan control for my laptop that is packaged for nix or written in c/python so i can try to package it myself

@ivan-pop did u manage to fix it, I intend to do something similar as well. If you managed to find a solution possible to share with me the resources for me to replicate it on my dell laptop, thanks

the arch package installs some systemd units https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=dell-bios-fan-control-git maybe they have to run so the utility works?