29027fd1e1
Using pkgs.lib on the spine of module evaluation is problematic because the pkgs argument depends on the result of module evaluation. To prevent an infinite recursion, pkgs and some of the modules are evaluated twice, which is inefficient. Using ‘with lib’ prevents this problem.
72 lines
1.2 KiB
Nix
72 lines
1.2 KiB
Nix
# Global configuration for wvdial.
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
configFile = ''
|
|
[Dialer Defaults]
|
|
PPPD PATH = ${pkgs.ppp}/sbin/pppd
|
|
${config.environment.wvdial.dialerDefaults}
|
|
'';
|
|
|
|
cfg = config.environment.wvdial;
|
|
|
|
in
|
|
{
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
environment.wvdial = {
|
|
|
|
dialerDefaults = mkOption {
|
|
default = "";
|
|
type = types.string;
|
|
example = ''Init1 = AT+CGDCONT=1,"IP","internet.t-mobile"'';
|
|
description = ''
|
|
Contents of the "Dialer Defaults" section of
|
|
<filename>/etc/wvdial.conf</filename>.
|
|
'';
|
|
};
|
|
|
|
pppDefaults = mkOption {
|
|
default = ''
|
|
noipdefault
|
|
usepeerdns
|
|
defaultroute
|
|
persist
|
|
noauth
|
|
'';
|
|
type = types.string;
|
|
description = "Default ppp settings for wvdial.";
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
###### implementation
|
|
|
|
config = mkIf (cfg.dialerDefaults != "") {
|
|
|
|
environment = {
|
|
|
|
etc =
|
|
[
|
|
{ source = pkgs.writeText "wvdial.conf" configFile;
|
|
target = "wvdial.conf";
|
|
}
|
|
{ source = pkgs.writeText "wvdial" cfg.pppDefaults;
|
|
target = "ppp/peers/wvdial";
|
|
}
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|