nur-packages

My NUR packages
git clone git://git.sikmir.ru/nur-packages
Log | Files | Refs | README | LICENSE

gpxsee.nix (3442B)


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