commit 137b923f553617d774306d2bb24f090277f01543
parent 7bc6ce40d477fe636785a4f5bd4ecbbc9f0ee7b6
Author: Nikolay Korotkiy <sikmir@gmail.com>
Date: Thu, 6 Aug 2020 01:20:33 +0300
qmapshack module: add more options
Diffstat:
1 file changed, 83 insertions(+), 8 deletions(-)
diff --git a/modules/home-manager/programs/qmapshack.nix b/modules/home-manager/programs/qmapshack.nix
@@ -3,6 +3,9 @@
with lib;
let
cfg = config.programs.qmapshack;
+ configDir = "${config.xdg.configHome}/QLandkarte";
+ configFile = "${configDir}/QMapShack.conf";
+ domain = "org.qlandkarte.QMapShack";
in
{
meta.maintainers = [ maintainers.sikmir ];
@@ -13,17 +16,89 @@ in
package = mkOption {
default = pkgs.qmapshack;
defaultText = literalExample "pkgs.qmapshack";
+ example = "pkgs.nur.repos.sikmir.qmapshack-bin";
description = "QMapShack package to install.";
type = types.package;
};
- };
- config = mkIf cfg.enable {
- home.packages = [
- cfg.package
- qmapshack-onlinemaps
- qmapshack-routinodb
- qmapshack-dem
- ];
+ demPackages = mkOption {
+ default = [ ];
+ example = [ "pkgs.nur.repos.sikmir.dem" ];
+ description = "DEM packages to install.";
+ type = types.listOf types.package;
+ };
+
+ mapPackages = mkOption {
+ default = [ ];
+ example = [
+ "pkgs.nur.repos.sikmir.qmapshack-onlinemaps"
+ "pkgs.nur.repos.sikmir.maptourist"
+ ];
+ description = "Map packages to install.";
+ type = types.listOf types.package;
+ };
+
+ routinoPackages = mkOption {
+ default = [ ];
+ example = [ "pkgs.nur.repos.sikmir.routinodb" ];
+ description = "Routino DB packages to install.";
+ type = types.listOf types.package;
+ };
};
+
+ config = mkIf cfg.enable (
+ mkMerge [
+ {
+ home.packages = [ cfg.package ];
+ }
+
+ (
+ mkIf pkgs.stdenv.isLinux {
+ home.activation.createConfigFile = config.lib.dag.entryBefore [ "writeBoundary" ] ''
+ $DRY_RUN_CMD mkdir -p ${configDir}
+ $DRY_RUN_CMD touch ${configFile}
+ '';
+ }
+ )
+
+ (
+ mkIf (length cfg.demPackages > 0) {
+ home.activation.setupDemPaths =
+ config.lib.dag.entryAfter [ "writeBoundary" ]
+ (
+ if pkgs.stdenv.isDarwin then
+ "$DRY_RUN_CMD /usr/bin/defaults write ${domain} Canvas.demPaths -array ${toString cfg.demPackages}"
+ else
+ "$DRY_RUN_CMD ${pkgs.crudini}/bin/crudini $VERBOSE_ARG --set ${configFile} Canvas demPaths ${concatStringsSep "," cfg.demPackages}"
+ );
+ }
+ )
+
+ (
+ mkIf (length cfg.mapPackages > 0) {
+ home.activation.setupMapPaths =
+ config.lib.dag.entryAfter [ "writeBoundary" ]
+ (
+ if pkgs.stdenv.isDarwin then
+ "$DRY_RUN_CMD /usr/bin/defaults write ${domain} Canvas.mapPath -array ${toString cfg.mapPackages}"
+ else
+ "$DRY_RUN_CMD ${pkgs.crudini}/bin/crudini $VERBOSE_ARG --set ${configFile} Canvas mapPath ${concatStringsSep "," cfg.mapPackages}"
+ );
+ }
+ )
+
+ (
+ mkIf (length cfg.routinoPackages > 0) {
+ home.activation.setupRoutinoPaths =
+ config.lib.dag.entryAfter [ "writeBoundary" ]
+ (
+ if pkgs.stdenv.isDarwin then
+ "$DRY_RUN_CMD /usr/bin/defaults write ${domain} Route.routino.paths -array ${toString cfg.routinoPackages}"
+ else
+ "$DRY_RUN_CMD ${pkgs.crudini}/bin/crudini $VERBOSE_ARG --set ${configFile} Route routino\\\\paths ${concatStringsSep "," cfg.routinoPackages}"
+ );
+ }
+ )
+ ]
+ );
}