fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Tristan Daniël Maatswaylock: document the need for host PAM configuration5171f5ef

master
1.9 KiB73 linesraw
1{ pkgs, config, lib, ... }:
2
3with lib;
4
5let cfg = config.programs.swaylock;
6in {
7  meta.maintainers = [ hm.maintainers.rcerc ];
8
9  options.programs.swaylock = {
10    enable = mkOption {
11      type = lib.types.bool;
12      default = versionOlder config.home.stateVersion "23.05"
13        && (cfg.settings != { });
14      defaultText = literalExpression ''
15        true  if state version < 23.05 and settings ≠ { },
16        false otherwise
17      '';
18      example = true;
19      description = ''
20        Whether to enable swaylock.
21
22        Note that PAM must be configured to enable swaylock to perform
23        authentication. The package installed through home-manager
24        will *not* be able to unlock the session without this
25        configuration.
26
27        On NixOS, this is by default enabled with the sway module, but
28        for other compositors it can currently be enabled using:
29
30        ```nix
31        security.pam.services.swaylock = {};
32        ```
33      '';
34    };
35
36    package = mkPackageOption pkgs "swaylock" { };
37
38    settings = mkOption {
39      type = with types; attrsOf (oneOf [ bool float int str ]);
40      default = { };
41      description = ''
42        Default arguments to {command}`swaylock`. An empty set
43        disables configuration generation.
44      '';
45      example = {
46        color = "808080";
47        font-size = 24;
48        indicator-idle-visible = false;
49        indicator-radius = 100;
50        line-color = "ffffff";
51        show-failed-attempts = true;
52      };
53    };
54  };
55
56  config = mkIf cfg.enable {
57    assertions = [
58      (lib.hm.assertions.assertPlatform "programs.swaylock" pkgs
59        lib.platforms.linux)
60    ];
61
62    home.packages = [ cfg.package ];
63
64    xdg.configFile."swaylock/config" = mkIf (cfg.settings != { }) {
65      text = concatStrings (mapAttrsToList (n: v:
66        if v == false then
67          ""
68        else
69          (if v == true then n else n + "=" + builtins.toString v) + "\n")
70        cfg.settings);
71    };
72  };
73}