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