nur-packages

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

qmapshack.nix (2968B)


      1 {
      2   config,
      3   lib,
      4   pkgs,
      5   ...
      6 }:
      7 
      8 with lib;
      9 let
     10   cfg = config.programs.qmapshack;
     11   configDir = "${config.xdg.configHome}/QLandkarte";
     12   configFile = "${configDir}/QMapShack.conf";
     13   domain = "org.qlandkarte.QMapShack";
     14 in
     15 {
     16   meta.maintainers = [ maintainers.sikmir ];
     17 
     18   options.programs.qmapshack = {
     19     enable = mkEnableOption "Consumer grade GIS software";
     20 
     21     package = mkOption {
     22       default = pkgs.qmapshack;
     23       defaultText = literalExpression "pkgs.qmapshack";
     24       example = "pkgs.nur.repos.sikmir.qmapshack-bin";
     25       description = "QMapShack package to install.";
     26       type = types.package;
     27     };
     28 
     29     demPackages = mkOption {
     30       default = [ ];
     31       example = [ "pkgs.nur.repos.sikmir.dem" ];
     32       description = "DEM packages to install.";
     33       type = types.listOf types.package;
     34     };
     35 
     36     mapPackages = mkOption {
     37       default = [ ];
     38       example = [
     39         "pkgs.nur.repos.sikmir.qmapshack-onlinemaps"
     40         "pkgs.nur.repos.sikmir.maptourist"
     41       ];
     42       description = "Map packages to install.";
     43       type = types.listOf types.package;
     44     };
     45 
     46     routinoPackages = mkOption {
     47       default = [ ];
     48       example = [ "pkgs.nur.repos.sikmir.routinodb" ];
     49       description = "Routino DB packages to install.";
     50       type = types.listOf types.package;
     51     };
     52   };
     53 
     54   config = mkIf cfg.enable (mkMerge [
     55     { home.packages = [ cfg.package ]; }
     56 
     57     (mkIf pkgs.stdenv.isLinux {
     58       home.activation.createConfigFile = lib.hm.dag.entryBefore [ "writeBoundary" ] ''
     59         $DRY_RUN_CMD mkdir -p ${configDir}
     60         $DRY_RUN_CMD touch ${configFile}
     61       '';
     62     })
     63 
     64     (mkIf (length cfg.demPackages > 0) {
     65       home.activation.setupDemPaths = lib.hm.dag.entryAfter [ "writeBoundary" ] (
     66         if pkgs.stdenv.isDarwin then
     67           "$DRY_RUN_CMD /usr/bin/defaults write ${domain} Canvas.demPaths -array ${toString cfg.demPackages}"
     68         else
     69           "$DRY_RUN_CMD ${pkgs.crudini}/bin/crudini $VERBOSE_ARG --set ${configFile} Canvas demPaths ${concatStringsSep "," cfg.demPackages}"
     70       );
     71     })
     72 
     73     (mkIf (length cfg.mapPackages > 0) {
     74       home.activation.setupMapPaths = lib.hm.dag.entryAfter [ "writeBoundary" ] (
     75         if pkgs.stdenv.isDarwin then
     76           "$DRY_RUN_CMD /usr/bin/defaults write ${domain} Canvas.mapPath -array ${toString cfg.mapPackages}"
     77         else
     78           "$DRY_RUN_CMD ${pkgs.crudini}/bin/crudini $VERBOSE_ARG --set ${configFile} Canvas mapPath ${concatStringsSep "," cfg.mapPackages}"
     79       );
     80     })
     81 
     82     (mkIf (length cfg.routinoPackages > 0) {
     83       home.activation.setupRoutinoPaths = lib.hm.dag.entryAfter [ "writeBoundary" ] (
     84         if pkgs.stdenv.isDarwin then
     85           "$DRY_RUN_CMD /usr/bin/defaults write ${domain} Route.routino.paths -array ${toString cfg.routinoPackages}"
     86         else
     87           "$DRY_RUN_CMD ${pkgs.crudini}/bin/crudini $VERBOSE_ARG --set ${configFile} Route routino\\\\paths ${concatStringsSep "," cfg.routinoPackages}"
     88       );
     89     })
     90   ]);
     91 }