about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--nixos/modules/module-list.nix6
-rw-r--r--nixos/modules/services/computing/foldingathome/client.nix81
-rw-r--r--nixos/modules/services/misc/folding-at-home.nix67
-rw-r--r--pkgs/applications/science/misc/foldingathome/client.nix59
-rw-r--r--pkgs/applications/science/misc/foldingathome/control.nix58
-rw-r--r--pkgs/applications/science/misc/foldingathome/viewer.nix55
-rw-r--r--pkgs/misc/foldingathome/default.nix36
-rw-r--r--pkgs/top-level/aliases.nix1
-rw-r--r--pkgs/top-level/all-packages.nix4
9 files changed, 260 insertions, 107 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index dba2593bbef55..771d7e128ea14 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -247,9 +247,10 @@
   ./services/cluster/kubernetes/proxy.nix
   ./services/cluster/kubernetes/scheduler.nix
   ./services/computing/boinc/client.nix
-  ./services/computing/torque/server.nix
-  ./services/computing/torque/mom.nix
+  ./services/computing/foldingathome/client.nix
   ./services/computing/slurm/slurm.nix
+  ./services/computing/torque/mom.nix
+  ./services/computing/torque/server.nix
   ./services/continuous-integration/buildbot/master.nix
   ./services/continuous-integration/buildbot/worker.nix
   ./services/continuous-integration/buildkite-agents.nix
@@ -432,7 +433,6 @@
   ./services/misc/ethminer.nix
   ./services/misc/exhibitor.nix
   ./services/misc/felix.nix
-  ./services/misc/folding-at-home.nix
   ./services/misc/freeswitch.nix
   ./services/misc/fstrim.nix
   ./services/misc/gammu-smsd.nix
diff --git a/nixos/modules/services/computing/foldingathome/client.nix b/nixos/modules/services/computing/foldingathome/client.nix
new file mode 100644
index 0000000000000..9f99af48c48a6
--- /dev/null
+++ b/nixos/modules/services/computing/foldingathome/client.nix
@@ -0,0 +1,81 @@
+{ config, lib, pkgs, ... }:
+with lib;
+let
+  cfg = config.services.foldingathome;
+
+  args =
+    ["--team" "${toString cfg.team}"]
+    ++ lib.optionals (cfg.user != null) ["--user" cfg.user]
+    ++ cfg.extraArgs
+    ;
+in
+{
+  imports = [
+    (mkRenamedOptionModule [ "services" "foldingAtHome" ] [ "services" "foldingathome" ])
+    (mkRenamedOptionModule [ "services" "foldingathome" "nickname" ] [ "services" "foldingathome" "user" ])
+    (mkRemovedOptionModule [ "services" "foldingathome" "config" ] ''
+      Use <literal>services.foldingathome.extraArgs instead<literal>
+    '')
+  ];
+  options.services.foldingathome = {
+    enable = mkEnableOption "Enable the Folding@home client";
+
+    package = mkOption {
+      type = types.package;
+      default = pkgs.fahclient;
+      defaultText = "pkgs.fahclient";
+      description = ''
+        Which Folding@home client to use.
+      '';
+    };
+
+    user = mkOption {
+      type = types.nullOr types.str;
+      default = null;
+      description = ''
+        The user associated with the reported computation results. This will
+        be used in the ranking statistics.
+      '';
+    };
+
+    team = mkOption {
+      type = types.int;
+      default = 236565;
+      description = ''
+        The team ID associated with the reported computation results. This
+        will be used in the ranking statistics.
+
+        By default, use the NixOS folding@home team ID is being used.
+      '';
+    };
+
+    extraArgs = mkOption {
+      type = types.listOf types.str;
+      default = [];
+      description = ''
+        Extra startup options for the FAHClient. Run
+        <literal>FAHClient --help</literal> to find all the available options.
+      '';
+    };
+  };
+
+  config = mkIf cfg.enable {
+    systemd.services.foldingathome = {
+      description = "Folding@home client";
+      after = [ "network.target" ];
+      wantedBy = [ "multi-user.target" ];
+      script = ''
+        exec ${cfg.package}/bin/FAHClient ${lib.escapeShellArgs args}
+      '';
+      serviceConfig = {
+        DynamicUser = true;
+        StateDirectory = "foldingathome";
+        WorkingDirectory = "%S/foldingathome";
+      };
+    };
+  };
+
+  meta = {
+    maintainers = with lib.maintainers; [ zimbatm ];
+  };
+}
diff --git a/nixos/modules/services/misc/folding-at-home.nix b/nixos/modules/services/misc/folding-at-home.nix
deleted file mode 100644
index fd2ea3948f64d..0000000000000
--- a/nixos/modules/services/misc/folding-at-home.nix
+++ /dev/null
@@ -1,67 +0,0 @@
-{ config, lib, pkgs, ... }:
-with lib;
-let
-  stateDir = "/var/lib/foldingathome";
-  cfg = config.services.foldingAtHome;
-  fahUser = "foldingathome";
-in {
-
-  ###### interface
-
-  options = {
-
-    services.foldingAtHome = {
-
-      enable = mkOption {
-        default = false;
-        description = ''
-          Whether to enable the Folding@Home to use idle CPU time.
-        '';
-      };
-
-      nickname = mkOption {
-        default = "Anonymous";
-        description = ''
-          A unique handle for statistics.
-        '';
-      };
-
-      config = mkOption {
-        default = "";
-        description = ''
-          Extra configuration. Contents will be added verbatim to the
-          configuration file.
-        '';
-      };
-
-    };
-
-  };
-
-  ###### implementation
-
-  config = mkIf cfg.enable {
-
-    users.users.${fahUser} =
-      { uid = config.ids.uids.foldingathome;
-        description = "Folding@Home user";
-        home = stateDir;
-      };
-
-    systemd.services.foldingathome = {
-      after = [ "network.target" ];
-      wantedBy = [ "multi-user.target" ];
-      preStart = ''
-        mkdir -m 0755 -p ${stateDir}
-        chown ${fahUser} ${stateDir}
-        cp -f ${pkgs.writeText "client.cfg" cfg.config} ${stateDir}/client.cfg
-      '';
-      script = "${pkgs.su}/bin/su -s ${pkgs.runtimeShell} ${fahUser} -c 'cd ${stateDir}; ${pkgs.foldingathome}/bin/fah6'";
-    };
-
-    services.foldingAtHome.config = ''
-        [settings]
-        username=${cfg.nickname}
-    '';
-  };
-}
diff --git a/pkgs/applications/science/misc/foldingathome/client.nix b/pkgs/applications/science/misc/foldingathome/client.nix
new file mode 100644
index 0000000000000..9a29fde0a4380
--- /dev/null
+++ b/pkgs/applications/science/misc/foldingathome/client.nix
@@ -0,0 +1,59 @@
+{ stdenv
+, autoPatchelfHook
+, buildFHSUserEnv
+, dpkg
+, fetchurl
+, gcc-unwrapped
+, ocl-icd
+, zlib
+, extraPkgs ? []
+}:
+let
+  majMin = stdenv.lib.versions.majorMinor version;
+  version = "7.5.1";
+
+  fahclient = stdenv.mkDerivation rec {
+    inherit version;
+    pname = "fahclient";
+
+    src = fetchurl {
+      url = "https://download.foldingathome.org/releases/public/release/fahclient/debian-stable-64bit/v${majMin}/fahclient_${version}_amd64.deb";
+      hash = "sha256-7+RwYdMoZnJZwYFbmLxsN9ozk2P7jpOGZz9qlvTTfSY=";
+    };
+
+    nativeBuildInputs = [
+      autoPatchelfHook
+      dpkg
+    ];
+
+    buildInputs = [
+      gcc-unwrapped.lib
+      zlib
+    ];
+
+    unpackPhase = "dpkg-deb -x ${src} ./";
+    installPhase = "cp -ar usr $out";
+  };
+in
+buildFHSUserEnv {
+  name = fahclient.name;
+
+  targetPkgs = pkgs': [
+    fahclient
+    ocl-icd
+  ] ++ extraPkgs;
+
+  runScript = "/bin/FAHClient";
+
+  extraInstallCommands = ''
+    mv $out/bin/$name $out/bin/FAHClient
+  '';
+
+  meta = {
+    description = "Folding@home client";
+    homepage = "https://foldingathome.org/";
+    license = stdenv.lib.licenses.unfree;
+    maintainers = [ stdenv.lib.maintainers.zimbatm ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/pkgs/applications/science/misc/foldingathome/control.nix b/pkgs/applications/science/misc/foldingathome/control.nix
new file mode 100644
index 0000000000000..be400ffe5f954
--- /dev/null
+++ b/pkgs/applications/science/misc/foldingathome/control.nix
@@ -0,0 +1,58 @@
+{ stdenv
+, autoPatchelfHook
+, dpkg
+, fetchurl
+, makeWrapper
+, python2
+}:
+let
+  majMin = stdenv.lib.versions.majorMinor version;
+  version = "7.5.1";
+
+  python = python2.withPackages
+    (
+      ps: [
+        ps.pycairo
+        ps.pygobject2
+        ps.pygtk
+      ]
+    );
+in
+stdenv.mkDerivation rec {
+  inherit version;
+  pname = "fahcontrol";
+
+  src = fetchurl {
+    url = "https://download.foldingathome.org/releases/public/release/fahcontrol/debian-stable-64bit/v${majMin}/fahcontrol_${version}-1_all.deb";
+    hash = "sha256-ydN4I6vmZpI9kD+/TXxgWc+AQqIIlUvABEycWmY1tNg=";
+  };
+
+  nativeBuildInputs = [
+    dpkg
+    makeWrapper
+  ];
+
+  buildInputs = [ python ];
+
+  doBuild = false;
+
+  unpackPhase = ''
+    dpkg-deb -x ${src} ./
+  '';
+
+  installPhase = "cp -ar usr $out";
+
+  postFixup = ''
+    sed -e 's|/usr/bin|$out/bin|g' -i $out/share/applications/FAHControl.desktop
+    wrapProgram "$out/bin/FAHControl" \
+      --set PYTHONPATH "$out/lib/python2.7/dist-packages"
+  '';
+
+  meta = {
+    description = "Folding@home control";
+    homepage = "https://foldingathome.org/";
+    license = stdenv.lib.licenses.unfree;
+    maintainers = [ stdenv.lib.maintainers.zimbatm ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/pkgs/applications/science/misc/foldingathome/viewer.nix b/pkgs/applications/science/misc/foldingathome/viewer.nix
new file mode 100644
index 0000000000000..03fa54cd73380
--- /dev/null
+++ b/pkgs/applications/science/misc/foldingathome/viewer.nix
@@ -0,0 +1,55 @@
+{ stdenv
+, autoPatchelfHook
+, dpkg
+, fetchurl
+, freeglut
+, gcc-unwrapped
+, libGL
+, libGLU
+, makeWrapper
+, zlib
+}:
+let
+  majMin = stdenv.lib.versions.majorMinor version;
+  version = "7.5.1";
+in
+stdenv.mkDerivation rec {
+  inherit version;
+  pname = "fahviewer";
+
+  src = fetchurl {
+    url = "https://download.foldingathome.org/releases/public/release/fahviewer/debian-stable-64bit/v${majMin}/fahviewer_${version}_amd64.deb";
+    hash = "sha256-yH0zGjX8aNBEJ5lq7wWydcpp2rO+9Ah++q9eJ+ldeyk=";
+  };
+
+  nativeBuildInputs = [
+    autoPatchelfHook
+    dpkg
+    makeWrapper
+  ];
+
+  buildInputs = [
+    freeglut
+    gcc-unwrapped.lib
+    libGL
+    libGLU
+    zlib
+  ];
+
+  unpackPhase = ''
+    dpkg-deb -x ${src} ./
+    sed -e 's|/usr/bin|$out/bin|g' -i usr/share/applications/FAHViewer.desktop
+  '';
+
+  installPhase = ''
+    cp -ar usr $out
+  '';
+
+  meta = {
+    description = "Folding@home viewer";
+    homepage = "https://foldingathome.org/";
+    license = stdenv.lib.licenses.unfree;
+    maintainers = [ stdenv.lib.maintainers.zimbatm ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/pkgs/misc/foldingathome/default.nix b/pkgs/misc/foldingathome/default.nix
deleted file mode 100644
index 1aae47e603b58..0000000000000
--- a/pkgs/misc/foldingathome/default.nix
+++ /dev/null
@@ -1,36 +0,0 @@
-{stdenv, fetchurl}:
-
-stdenv.mkDerivation {
-  name = "folding-at-home-6.02";
-
-  src = fetchurl {
-    url = http://www.stanford.edu/group/pandegroup/folding/release/FAH6.02-Linux.tgz;
-    sha256 = "01nwi0lb4vv0xg4k04i2fbf5v5qgabl70jm5cgvw1ibgqjz03910";
-  };
-
-  unpackPhase = "tar xvzf $src";
-
-  # Otherwise it doesn't work at all, even ldd thinks it's not a dynamic executable
-  dontStrip = true;
-
-  # This program, to run with '-smp', wants to execute the program mpiexec
-  # as "./mpiexec", although it also expects to write the data files into "."
-  # I suggest, if someone wants to run it, in the data directory set a link
-  # to the store for 'mpiexec', so './mpiexec' will work. That link better
-  # be considered a gcroot.
-  installPhase = ''
-    BINFILES="fah6 mpiexec";
-    for a in $BINFILES; do
-      patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) $a
-    done
-    mkdir -p $out/bin
-    cp $BINFILES $out/bin
-  '';
-
-  meta = {
-    homepage = http://folding.stanford.edu/;
-    description = "Folding@home distributed computing client";
-    license = stdenv.lib.licenses.unfree;
-    platforms = [ "i686-linux" ];
-  };
-}
diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix
index 3a504f20d9445..d815983e12621 100644
--- a/pkgs/top-level/aliases.nix
+++ b/pkgs/top-level/aliases.nix
@@ -132,6 +132,7 @@ mapAliases ({
 
   firestr = throw "firestr has been removed."; # added 2019-12-08
   flameGraph = flamegraph; # added 2018-04-25
+  foldingathome = fahclient; # added 2020-09-03
   font-awesome-ttf = font-awesome; # 2018-02-25
   # 2019-10-31
   fontconfig-ultimate = throw ''
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index febee38ef0870..b80334ae61283 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -25033,7 +25033,9 @@ in
 
   flockit = callPackage ../tools/backup/flockit { };
 
-  foldingathome = callPackage ../misc/foldingathome { };
+  fahclient = callPackage ../applications/science/misc/foldingathome/client.nix {};
+  fahcontrol = callPackage ../applications/science/misc/foldingathome/control.nix {};
+  fahviewer = callPackage ../applications/science/misc/foldingathome/viewer.nix {};
 
   foo2zjs = callPackage ../misc/drivers/foo2zjs {};