nur-packages

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

merkaartor.nix (2425B)


      1 {
      2   config,
      3   lib,
      4   pkgs,
      5   ...
      6 }:
      7 
      8 with lib;
      9 let
     10   cfg = config.programs.merkaartor;
     11   configDir = "${config.xdg.configHome}/Merkaartor";
     12   configFile = "${configDir}/Merkaartor.conf";
     13   domain = "org.merkaartor.Merkaartor";
     14 in
     15 {
     16   meta.maintainers = [ maintainers.sikmir ];
     17 
     18   options.programs.merkaartor = {
     19     enable = mkEnableOption "OpenStreetMap editor";
     20 
     21     package = mkOption {
     22       default = pkgs.merkaartor;
     23       defaultText = literalExpression "pkgs.merkaartor";
     24       description = "Merkaartor package to install.";
     25       type = types.package;
     26     };
     27 
     28     user = mkOption {
     29       default = "";
     30       description = "OSM user.";
     31       type = types.str;
     32     };
     33 
     34     password = mkOption {
     35       default = "";
     36       description = "OSM password.";
     37       type = types.str;
     38     };
     39   };
     40 
     41   config = mkIf cfg.enable (mkMerge [
     42     { home.packages = [ cfg.package ]; }
     43 
     44     (mkIf pkgs.stdenv.isLinux {
     45       home.activation.createConfigFile = lib.hm.dag.entryBefore [ "writeBoundary" ] ''
     46         $DRY_RUN_CMD mkdir -p ${configDir}
     47         $DRY_RUN_CMD touch ${configFile}
     48       '';
     49     })
     50 
     51     (mkIf (cfg.user != "" && cfg.password != "") {
     52       home.activation.setupCredentials = lib.hm.dag.entryAfter [ "writeBoundary" ] (
     53         if pkgs.stdenv.isDarwin then
     54           ''
     55             $DRY_RUN_CMD /usr/bin/defaults write ${domain} OsmServers.1.url https://api.openstreetmap.org/api
     56             $DRY_RUN_CMD /usr/bin/defaults write ${domain} OsmServers.1.selected true
     57             $DRY_RUN_CMD /usr/bin/defaults write ${domain} OsmServers.1.user ${cfg.user}
     58             $DRY_RUN_CMD /usr/bin/defaults write ${domain} OsmServers.1.password ${cfg.password}
     59             $DRY_RUN_CMD /usr/bin/defaults write ${domain} OsmServers.size 1
     60           ''
     61         else
     62           ''
     63             $DRY_RUN_CMD ${pkgs.crudini}/bin/crudini $VERBOSE_ARG --set ${configFile} OsmServers 1\\\\url https://api.openstreetmap.org/api
     64             $DRY_RUN_CMD ${pkgs.crudini}/bin/crudini $VERBOSE_ARG --set ${configFile} OsmServers 1\\\\selected true
     65             $DRY_RUN_CMD ${pkgs.crudini}/bin/crudini $VERBOSE_ARG --set ${configFile} OsmServers 1\\\\user ${cfg.user}
     66             $DRY_RUN_CMD ${pkgs.crudini}/bin/crudini $VERBOSE_ARG --set ${configFile} OsmServers 1\\\\password ${cfg.password}
     67             $DRY_RUN_CMD ${pkgs.crudini}/bin/crudini $VERBOSE_ARG --set ${configFile} OsmServers size 1
     68           ''
     69       );
     70     })
     71   ]);
     72 }