summaryrefslogtreecommitdiffstats
path: root/lass/3modules/autowifi.nix
blob: 9aa1a2d28622028078f6eaad717c6a970706c9f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{ config, lib, pkgs, ... }:
with import <stockholm/lib>;
let

  cfg = config.lass.autowifi;

in {
  options.lass.autowifi = {
    enable = mkEnableOption "automatic wifi connector";
    knownWifisFile = mkOption {
      type = types.str;
      default = "/etc/wifis";
    };
    enablePrisonBreak = mkOption {
      type = types.bool;
      default = false;
    };
  };

  config = lib.mkIf cfg.enable {
    systemd.services.autowifi = {
      description = "Automatic wifi connector";
      wantedBy = [ "multi-user.target" ];
      path = [ pkgs.networkmanager ];
      serviceConfig = {
        Type = "simple";
        Restart = "always";
        RestartSec = "10s";
        ExecStart = "${autowifi}/bin/autowifi";
      };
    };

    networking.networkmanager.dispatcherScripts = mkIf cfg.enablePrisonBreak [
      { source = "${pkgs.callPackage <stockholm/makefu/5pkgs/prison-break}/bin/prison-break"; }
    ];
  };
}