gpxsee.nix (3110B)
1 { 2 config, 3 lib, 4 pkgs, 5 ... 6 }: 7 8 with lib; 9 let 10 cfg = config.programs.gpxsee; 11 configDir = "${config.xdg.configHome}/gpxsee"; 12 configFile = "${configDir}/gpxsee.conf"; 13 domain = "com.gpxsee.GPXSee"; 14 15 appDataLocation = 16 if pkgs.stdenv.isDarwin then 17 "Library/Application Support/GPXSee" 18 else 19 "${config.xdg.dataHome}/gpxsee"; 20 demDir = "${appDataLocation}/DEM"; 21 mapDir = "${appDataLocation}/maps"; 22 poiDir = "${appDataLocation}/POI"; 23 styleDir = "${appDataLocation}/style"; 24 in 25 { 26 meta.maintainers = [ maintainers.sikmir ]; 27 28 options.programs.gpxsee = { 29 enable = mkEnableOption "GPS log file viewer and analyzer"; 30 31 package = mkOption { 32 default = pkgs.gpxsee; 33 defaultText = literalExpression "pkgs.gpxsee"; 34 example = "pkgs.nur.repos.sikmir.gpxsee-bin"; 35 description = "GPXSee package to install."; 36 type = types.package; 37 }; 38 39 demPackage = mkOption { 40 default = null; 41 example = "pkgs.nur.repos.sikmir.dem"; 42 description = "DEM package to install."; 43 type = types.nullOr types.package; 44 }; 45 46 mapPackages = mkOption { 47 default = [ ]; 48 example = [ 49 "pkgs.nur.repos.sikmir.gpxsee-maps" 50 "pkgs.nur.repos.sikmir.maptourist" 51 ]; 52 description = "Map packages to install."; 53 type = types.listOf types.package; 54 }; 55 56 poiPackages = mkOption { 57 default = [ ]; 58 example = [ 59 "pkgs.nur.repos.sikmir.poi.geocachingSu" 60 "pkgs.nur.repos.sikmir.poi.westra" 61 ]; 62 description = "POI packages to install."; 63 type = types.listOf types.package; 64 }; 65 66 stylePackage = mkOption { 67 default = null; 68 example = "pkgs.nur.repos.sikmir.qtpbfimageplugin-styles"; 69 description = "QtPBFImagePlugin style package to install."; 70 type = types.nullOr types.package; 71 }; 72 }; 73 74 config = mkIf cfg.enable (mkMerge [ 75 { 76 home.packages = [ cfg.package ]; 77 78 home.activation.hideToolbar = lib.hm.dag.entryAfter [ "writeBoundary" ] ( 79 if pkgs.stdenv.isDarwin then 80 "$DRY_RUN_CMD /usr/bin/defaults write ${domain} Settings.toolbar -bool false" 81 else 82 "$DRY_RUN_CMD ${pkgs.crudini}/bin/crudini $VERBOSE_ARG --set ${configFile} Settings toolbar 0" 83 ); 84 } 85 86 (mkIf pkgs.stdenv.isLinux { 87 home.activation.createConfigFile = lib.hm.dag.entryBefore [ "writeBoundary" ] '' 88 $DRY_RUN_CMD mkdir -p ${configDir} 89 $DRY_RUN_CMD touch ${configFile} 90 ''; 91 }) 92 93 (mkIf (cfg.demPackage != null) { home.file."${demDir}".source = "${cfg.demPackage}"; }) 94 95 (mkIf (length cfg.mapPackages > 0) { 96 home.file = listToAttrs ( 97 map (m: { 98 name = "${mapDir}/${m.name}"; 99 value.source = "${m}"; 100 }) cfg.mapPackages 101 ); 102 }) 103 104 (mkIf (length cfg.poiPackages > 0) { 105 home.file = listToAttrs ( 106 map (p: { 107 name = "${poiDir}/${p.name}"; 108 value.source = "${p}"; 109 }) cfg.poiPackages 110 ); 111 }) 112 113 (mkIf (cfg.stylePackage != null) { home.file."${styleDir}".source = "${cfg.stylePackage}"; }) 114 ]); 115 }