fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7cfg = config . services . flameshot ; 8 9iniFormat = pkgs . formats . ini { }; 10 11iniFile = iniFormat . generate "flameshot.ini" cfg . settings ; 12 13in { 14meta . maintainers = [ maintainers . hamhut1066 ]; 15 16options . services . flameshot = { 17enable = mkEnableOption "Flameshot" ; 18 19package = mkOption { 20type = types . package ; 21default = pkgs . flameshot ; 22defaultText = literalExpression "pkgs.flameshot" ; 23description = "Package providing {command}`flameshot`." ; 24}; 25 26settings = mkOption { 27type = iniFormat . type ; 28default = { }; 29example = { 30General = { 31disabledTrayIcon = true ; 32showStartupLaunchMessage = false ; 33}; 34}; 35description = '' 36Configuration to use for Flameshot. See 37<https://github.com/flameshot-org/flameshot/blob/master/flameshot.example.ini> 38for available options. 39'' ; 40}; 41}; 42 43config = mkIf cfg . enable { 44assertions = [ 45( lib . hm . assertions . assertPlatform "services.flameshot" pkgs 46lib . platforms . linux ) 47]; 48 49home . packages = [ cfg . package ]; 50 51xdg . configFile = mkIf ( cfg . settings != { }) { 52"flameshot/flameshot.ini" . source = iniFile ; 53}; 54 55systemd . user . services . flameshot = { 56Unit = { 57Description = "Flameshot screenshot tool" ; 58Requires = [ "tray.target" ]; 59After = [ "graphical-session-pre.target" "tray.target" ]; 60PartOf = [ "graphical-session.target" ]; 61X-Restart-Triggers = mkIf ( cfg . settings != { }) [ " ${ iniFile } " ]; 62}; 63 64Install = { WantedBy = [ "graphical-session.target" ]; }; 65 66Service = { 67Environment = "PATH= ${ config . home . profileDirectory } /bin" ; 68ExecStart = " ${ cfg . package } /bin/flameshot" ; 69Restart = "on-abort" ; 70 71# Sandboxing. 72LockPersonality = true ; 73MemoryDenyWriteExecute = true ; 74NoNewPrivileges = true ; 75PrivateUsers = true ; 76RestrictNamespaces = true ; 77SystemCallArchitectures = "native" ; 78SystemCallFilter = "@system-service" ; 79}; 80}; 81}; 82}