at 17.09-beta 1.6 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 7 cfg = config.services.heyefi; 8in 9 10{ 11 12 ###### interface 13 14 options = { 15 16 services.heyefi = { 17 18 enable = mkEnableOption "heyefi"; 19 20 cardMacaddress = mkOption { 21 default = ""; 22 description = '' 23 An Eye-Fi card MAC address. 24 ''; 25 }; 26 27 uploadKey = mkOption { 28 default = ""; 29 description = '' 30 An Eye-Fi card's upload key. 31 ''; 32 }; 33 34 uploadDir = mkOption { 35 example = "/home/username/pictures"; 36 description = '' 37 The directory to upload the files to. 38 ''; 39 }; 40 41 user = mkOption { 42 default = "root"; 43 description = '' 44 heyefi will be run under this user (user must exist, 45 this can be your user name). 46 ''; 47 }; 48 49 }; 50 51 }; 52 53 54 ###### implementation 55 56 config = mkIf cfg.enable { 57 58 systemd.services.heyefi = 59 { 60 description = "heyefi service"; 61 after = [ "network.target" ]; 62 wantedBy = [ "multi-user.target" ]; 63 serviceConfig = { 64 User = "${cfg.user}"; 65 Restart = "always"; 66 ExecStart = "${pkgs.heyefi}/bin/heyefi"; 67 }; 68 69 }; 70 71 environment.etc."heyefi/heyefi.config".text = 72 '' 73 # /etc/heyefi/heyefi.conf: DO NOT EDIT -- this file has been generated automatically. 74 cards = [["${config.services.heyefi.cardMacaddress}","${config.services.heyefi.uploadKey}"]] 75 upload_dir = "${toString config.services.heyefi.uploadDir}" 76 ''; 77 78 environment.systemPackages = [ pkgs.heyefi ]; 79 80 }; 81 82}