nur-packages

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

josm.nix (1958B)


      1 {
      2   config,
      3   lib,
      4   pkgs,
      5   ...
      6 }:
      7 
      8 with lib;
      9 let
     10   cfg = config.programs.josm;
     11   configDir =
     12     if pkgs.stdenv.isDarwin then
     13       "${config.home.homeDirectory}/Library/Preferences/JOSM"
     14     else
     15       "${config.xdg.configHome}/JOSM";
     16   configFile = "${configDir}/preferences.xml";
     17 in
     18 {
     19   meta.maintainers = [ maintainers.sikmir ];
     20 
     21   options.programs.josm = {
     22     enable = mkEnableOption "An extensible editor for OpenStreetMap";
     23 
     24     package = mkOption {
     25       default = pkgs.josm;
     26       defaultText = literalExpression "pkgs.josm";
     27       description = "JOSM package to install.";
     28       type = types.package;
     29     };
     30 
     31     accessTokenKey = mkOption {
     32       default = "";
     33       description = "OAuth Access Token Key.";
     34       type = types.str;
     35     };
     36 
     37     accessTokenSecret = mkOption {
     38       default = "";
     39       description = "OAuth Access Token Secret.";
     40       type = types.str;
     41     };
     42   };
     43 
     44   config = mkIf cfg.enable (mkMerge [
     45     {
     46       home.packages = [ cfg.package ];
     47 
     48       home.activation.createJOSMConfigFile = lib.hm.dag.entryBefore [ "writeBoundary" ] ''
     49         . ${./josm/init-prefs.sh}
     50         . ${./josm/upsert-tag.sh}
     51         export PATH=${pkgs.xmlstarlet}/bin:$PATH
     52         initPrefs ${cfg.package.version} ${configFile}
     53         upsertTag josm.version ${cfg.package.version} ${configFile}
     54       '';
     55     }
     56 
     57     (mkIf (cfg.accessTokenKey != "") {
     58       home.activation.setupAccessTokenKey = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
     59         . ${./josm/upsert-tag.sh}
     60         export PATH=${pkgs.xmlstarlet}/bin:$PATH
     61         upsertTag oauth.access-token.key ${cfg.accessTokenKey} ${configFile}
     62       '';
     63     })
     64 
     65     (mkIf (cfg.accessTokenSecret != "") {
     66       home.activation.setupAccessTokenSecret = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
     67         . ${./josm/upsert-tag.sh}
     68         export PATH=${pkgs.xmlstarlet}/bin:$PATH
     69         upsertTag oauth.access-token.secret ${cfg.accessTokenSecret} ${configFile}
     70       '';
     71     })
     72   ]);
     73 }