nur-packages

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

commit ba385d26983bc04819b04807e649b9d875a80e7d
parent 6b7b3df0656741d62e2a79d261b6d1871c777a1c
Author: Nikolay Korotkiy <sikmir@gmail.com>
Date:   Tue, 20 Apr 2021 00:30:31 +0300

Add merkaartor module

Diffstat:
Mmodules/default.nix | 1+
Amodules/home-manager/programs/merkaartor.nix | 73+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 74 insertions(+), 0 deletions(-)

diff --git a/modules/default.nix b/modules/default.nix @@ -5,6 +5,7 @@ goldendict = ./home-manager/programs/goldendict.nix; gpxsee = ./home-manager/programs/gpxsee.nix; josm = ./home-manager/programs/josm.nix; + merkaartor = ./home-manager/programs/merkaartor.nix; nnn = ./home-manager/programs/nnn.nix; openorienteering-mapper = ./home-manager/programs/openorienteering-mapper.nix; qmapshack = ./home-manager/programs/qmapshack.nix; diff --git a/modules/home-manager/programs/merkaartor.nix b/modules/home-manager/programs/merkaartor.nix @@ -0,0 +1,73 @@ +{ config, lib, pkgs, ... }: + +with lib; +let + cfg = config.programs.merkaartor; + configDir = "${config.xdg.configHome}/Merkaartor"; + configFile = "${configDir}/Merkaartor.conf"; + domain = "org.merkaartor.Merkaartor"; +in +{ + meta.maintainers = [ maintainers.sikmir ]; + + options.programs.merkaartor = { + enable = mkEnableOption "OpenStreetMap editor"; + + package = mkOption { + default = pkgs.merkaartor; + defaultText = literalExample "pkgs.merkaartor"; + description = "Merkaartor package to install."; + type = types.package; + }; + + user = mkOption { + default = ""; + description = "OSM user."; + type = types.str; + }; + + password = mkOption { + default = ""; + description = "OSM password."; + type = types.str; + }; + }; + + config = mkIf cfg.enable ( + mkMerge [ + { + home.packages = [ cfg.package ]; + } + + ( + mkIf pkgs.stdenv.isLinux { + home.activation.createConfigFile = lib.hm.dag.entryBefore [ "writeBoundary" ] '' + $DRY_RUN_CMD mkdir -p ${configDir} + $DRY_RUN_CMD touch ${configFile} + ''; + } + ) + + ( + mkIf (cfg.user != "" && cfg.password != "") { + home.activation.setupCredentials = lib.hm.dag.entryAfter [ "writeBoundary" ] + ( + if pkgs.stdenv.isDarwin then '' + $DRY_RUN_CMD /usr/bin/defaults write ${domain} OsmServers.1.url https://api.openstreetmap.org/api + $DRY_RUN_CMD /usr/bin/defaults write ${domain} OsmServers.1.selected true + $DRY_RUN_CMD /usr/bin/defaults write ${domain} OsmServers.1.user ${cfg.user} + $DRY_RUN_CMD /usr/bin/defaults write ${domain} OsmServers.1.password ${cfg.password} + $DRY_RUN_CMD /usr/bin/defaults write ${domain} OsmServers.size 1 + '' else '' + $DRY_RUN_CMD ${pkgs.crudini}/bin/crudini $VERBOSE_ARG --set ${configFile} OsmServers 1\\\\url https://api.openstreetmap.org/api + $DRY_RUN_CMD ${pkgs.crudini}/bin/crudini $VERBOSE_ARG --set ${configFile} OsmServers 1\\\\selected true + $DRY_RUN_CMD ${pkgs.crudini}/bin/crudini $VERBOSE_ARG --set ${configFile} OsmServers 1\\\\user ${cfg.user} + $DRY_RUN_CMD ${pkgs.crudini}/bin/crudini $VERBOSE_ARG --set ${configFile} OsmServers 1\\\\password ${cfg.password} + $DRY_RUN_CMD ${pkgs.crudini}/bin/crudini $VERBOSE_ARG --set ${configFile} OsmServers size 1 + '' + ); + } + ) + ] + ); +}