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