git.iko.soy/typeable/nixpkgs
on master help sign in
mbpfan: new package

Daemon that uses input from coretemp module and sets the fan speed using the applesmc module

commit53ab1f7d3ca355a16569bb77bb950b89e8fcf01b authorCharles Strahan <charles.c.strahan@gmail.com> dateThu 30 Apr 2015, 21:14 (12 years ago) parenta8f17b3
3 files changed+61
pkgs/os-specific/linux/mbpfan/default.nix+30 pkgs/os-specific/linux/mbpfan/fixes.patch+29 pkgs/top-level/all-packages.nix+2
pkgs/os-specific/linux/mbpfan/default.nixnew file+30
@@ -0,0 +1,30 @@
1+{ stdenv, lib, fetchFromGitHub, gnugrep, kmod }:
2+
3+stdenv.mkDerivation rec {
4+ name = "mbpfan-${version}";
5+ version = "1.9.0";
6+ src = fetchFromGitHub {
7+ owner = "dgraziotin";
8+ repo = "mbpfan";
9+ rev = "v${version}";
10+ sha256 = "15nm1d0a0c0lzxqngrpn2qpsydsmglnn6d20djl7brpsq26j24h9";
11+ };
12+ patches = [ ./fixes.patch ];
13+ postPatch = ''
14+ substituteInPlace src/main.c \
15+ --replace '@GREP@' '${gnugrep}/bin/grep' \
16+ --replace '@LSMOD@' '${kmod}/bin/lsmod'
17+ '';
18+ installPhase = ''
19+ mkdir -p $out/bin $out/etc
20+ cp bin/mbpfan $out/bin
21+ cp mbpfan.conf $out/etc
22+ '';
23+ meta = with lib; {
24+ description = "Daemon that uses input from coretemp module and sets the fan speed using the applesmc module";
25+ homepage = "https://github.com/dgraziotin/mbpfan";
26+ license = licenses.gpl3;
27+ platforms = platforms.linux;
28+ maintainers = with maintainers; [ cstrahan ];
29+ };
30+}
pkgs/os-specific/linux/mbpfan/fixes.patchnew file+29
@@ -0,0 +1,29 @@
1+diff --git a/src/main.c b/src/main.c
2+index e8af708..6cfee17 100644
3+--- a/src/main.c
4++++ b/src/main.c
5+@@ -71,7 +71,7 @@ void check_requirements()
6+ * Check for coretemp and applesmc modules
7+ * Credits: -http://stackoverflow.com/questions/12978794
8+ */
9+- FILE *fd = popen("lsmod | grep coretemp", "r");
10++ FILE *fd = popen("@LSMOD@ | @GREP@ coretemp", "r");
11+ char buf[16];
12+
13+ if (!(fread (buf, 1, sizeof (buf), fd) > 0)) {
14+@@ -87,7 +87,7 @@ void check_requirements()
15+
16+ pclose(fd);
17+
18+- fd = popen("lsmod | grep applesmc", "r");
19++ fd = popen("@LSMOD@ | @GREP@ applesmc", "r");
20+
21+ if (!(fread (buf, 1, sizeof (buf), fd) > 0)) {
22+ DIR* dir = opendir(APPLESMC_PATH);
23+@@ -145,4 +145,4 @@ int main(int argc, char *argv[])
24+ void (*fan_control)() = mbpfan;
25+ go_daemon(fan_control);
26+ exit(EXIT_SUCCESS);
27+-}
28+\ No newline at end of file
29++}
pkgs/top-level/all-packages.nix+2
@@ -9512,6 +9512,8 @@ let
95129512
95139513 lvm2 = callPackage ../os-specific/linux/lvm2 { };
95149514
9515+ mbpfan = callPackage ../os-specific/linux/mbpfan { };
9516+
95159517 mdadm = callPackage ../os-specific/linux/mdadm { };
95169518
95179519 mingetty = callPackage ../os-specific/linux/mingetty { };