2009-11-10 16:22:57 +01:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (pkgs.lib) mkOption mkIf;
|
2009-11-18 14:28:16 +01:00
|
|
|
|
2009-11-10 16:22:57 +01:00
|
|
|
cfg = config.services.openafsClient;
|
2009-11-18 14:28:16 +01:00
|
|
|
|
|
|
|
cellServDB = pkgs.fetchurl {
|
|
|
|
url = http://dl.central.org/dl/cellservdb/CellServDB.2009-06-29;
|
|
|
|
sha256 = "be566f850e88130333ab8bc3462872ad90c9482e025c60a92f728b5bac1b4fa9";
|
|
|
|
};
|
|
|
|
|
2009-11-10 16:22:57 +01:00
|
|
|
afsConfig = pkgs.runCommand "afsconfig" {} ''
|
|
|
|
ensureDir $out
|
|
|
|
echo ${cfg.cellName} > $out/ThisCell
|
|
|
|
cp ${cellServDB} $out/CellServDB
|
|
|
|
echo "/afs:${cfg.cacheDirectory}:${cfg.cacheSize}" > $out/cacheinfo
|
|
|
|
'';
|
2010-02-01 17:29:15 +01:00
|
|
|
|
|
|
|
openafsPkgs = config.boot.kernelPackages.openafsClient;
|
2009-11-10 16:22:57 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.openafsClient = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "Whether to enable the OpenAFS client.";
|
|
|
|
};
|
|
|
|
|
|
|
|
cellName = mkOption {
|
|
|
|
default = "grand.central.org";
|
|
|
|
description = "Cell name.";
|
|
|
|
};
|
|
|
|
|
|
|
|
cacheSize = mkOption {
|
|
|
|
default = "100000";
|
|
|
|
description = "Cache size.";
|
|
|
|
};
|
|
|
|
|
|
|
|
cacheDirectory = mkOption {
|
|
|
|
default = "/var/cache/openafs";
|
|
|
|
description = "Cache directory.";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2010-02-01 17:29:15 +01:00
|
|
|
environment.systemPackages = [ openafsPkgs ];
|
2009-11-10 16:22:57 +01:00
|
|
|
|
|
|
|
environment.etc = [
|
|
|
|
{ source = afsConfig;
|
|
|
|
target = "openafs";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
jobs.openafsClient =
|
|
|
|
{ name = "afsd";
|
|
|
|
|
|
|
|
description = "AFS client";
|
|
|
|
|
2009-11-26 15:12:19 +01:00
|
|
|
startOn = "started network-interfaces";
|
|
|
|
stopOn = "stopping network-interfaces";
|
2009-11-10 16:22:57 +01:00
|
|
|
|
|
|
|
preStart = ''
|
|
|
|
mkdir -m 0755 /afs || true
|
|
|
|
mkdir -m 0755 -p ${cfg.cacheDirectory} || true
|
2010-02-01 17:29:15 +01:00
|
|
|
${pkgs.module_init_tools}/sbin/insmod ${openafsPkgs}/lib/openafs/libafs-*.ko || true
|
|
|
|
${openafsPkgs}/sbin/afsd -confdir ${afsConfig} -cachedir ${cfg.cacheDirectory} -dynroot -fakestat
|
2009-11-10 16:22:57 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
postStop = ''
|
|
|
|
umount /afs
|
2010-02-01 17:29:15 +01:00
|
|
|
${openafsPkgs}/sbin/afsd -shutdown
|
2009-11-10 16:22:57 +01:00
|
|
|
rmmod libafs
|
|
|
|
'';
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|