mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-18 07:46:09 +01:00
60 lines
1.1 KiB
Nix
60 lines
1.1 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.networking.fan;
|
|
modprobe = "${config.system.sbin.modprobe}/sbin/modprobe";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
networking.fan = {
|
|
|
|
enable = mkEnableOption "FAN Networking";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
###### implementation
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
environment.systemPackages = [ pkgs.fanctl ];
|
|
|
|
systemd.services.fan = {
|
|
description = "FAN Networking";
|
|
wantedBy = [ "multi-user.target" ];
|
|
after = [ "network-online.target" ];
|
|
before = [ "docker.service" ];
|
|
restartIfChanged = false;
|
|
preStart = ''
|
|
if [ ! -f /proc/sys/net/fan/version ]; then
|
|
${modprobe} ipip
|
|
if [ ! -f /proc/sys/net/fan/version ]; then
|
|
echo "The Fan Networking patches have not been applied to this kernel!" 1>&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
mkdir -p /var/lib/fan-networking
|
|
'';
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
RemainAfterExit = true;
|
|
ExecStart = "${pkgs.fanctl}/bin/fanctl up -a";
|
|
ExecStop = "${pkgs.fanctl}/bin/fanctl down -a";
|
|
};
|
|
};
|
|
|
|
};
|
|
|
|
}
|