Author: egorochkin
Date: Thu Sep 16 02:06:44 2010
New Revision: 23816
URL: https://svn.nixos.org/websvn/nix/?rev=23816&sc=1
Log:
Added fold...@home service
Added:
nixos/trunk/modules/services/misc/folding-at-home.nix
Modified:
nixos/trunk/modules/misc/ids.nix
nixos/trunk/modules/module-list.nix
Modified: nixos/trunk/modules/misc/ids.nix
==============================================================================
--- nixos/trunk/modules/misc/ids.nix Wed Sep 15 21:41:18 2010 (r23815)
+++ nixos/trunk/modules/misc/ids.nix Thu Sep 16 02:06:44 2010 (r23816)
@@ -56,6 +56,7 @@
sabnzbd = 33;
tor = 35;
cups = 36;
+ foldingAtHome = 37;
# When adding a uid, make sure it doesn't match an existing gid.
nixbld = 30000; # start of range of uids
Modified: nixos/trunk/modules/module-list.nix
==============================================================================
--- nixos/trunk/modules/module-list.nix Wed Sep 15 21:41:18 2010 (r23815)
+++ nixos/trunk/modules/module-list.nix Thu Sep 16 02:06:44 2010 (r23816)
@@ -62,6 +62,7 @@
./services/misc/autofs.nix
./services/misc/disnix.nix
./services/misc/felix.nix
+ ./services/misc/folding-at-home.nix
./services/misc/gpsd.nix
./services/misc/nix-daemon.nix
./services/misc/nix-gc.nix
Added: nixos/trunk/modules/services/misc/folding-at-home.nix
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ nixos/trunk/modules/services/misc/folding-at-home.nix Thu Sep 16
02:06:44 2010 (r23816)
@@ -0,0 +1,75 @@
+{ config, pkgs, ... }:
+with pkgs.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 fold...@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 {
+ environment.systemPackages = [ pkgs.foldingathome ];
+
+ users.extraUsers = singleton
+ { name = fahUser;
+ uid = config.ids.uids.foldingAtHome;
+ description = "fold...@home user";
+ home = stateDir;
+ };
+
+ jobs.foldingAtHome =
+ { name = "foldingathome";
+
+ startOn = "started network-interfaces";
+ stopOn = "stopping network-interfaces";
+
+ preStart =
+ ''
+ mkdir -m 0755 -p ${stateDir}
+ chown ${fahUser} ${stateDir}
+ cp -f ${pkgs.writeText "client.cfg" cfg.config}
${stateDir}/client.cfg
+ '';
+ exec = "${pkgs.su}/bin/su -s ${pkgs.stdenv.shell} ${fahUser} -c 'cd
${stateDir}; ${pkgs.foldingathome}/bin/fah6'";
+ };
+
+ services.foldingAtHome.config = ''
+ [settings]
+ username=${cfg.nickname}
+ '';
+
+ };
+
+}
\ No newline at end of file
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits