summaryrefslogtreecommitdiffstats
path: root/krebs/3modules/fetchWallpaper.nix
diff options
context:
space:
mode:
authorlassulus <lass@aidsballs.de>2016-02-16 17:15:00 +0100
committerlassulus <lass@aidsballs.de>2016-02-16 17:15:00 +0100
commit0b0b0d65ee05583529df831985580e392713d29a (patch)
tree7eb6799a996924d8e895c54633a47ea3d7a92a4c /krebs/3modules/fetchWallpaper.nix
parent3d30e9cc9014ec6189410944015d3cd7d5ca95a6 (diff)
parentb7a92f63884af00eb0243ec9328be689a6c9b845 (diff)
Merge remote-tracking branch 'cd/master'
Diffstat (limited to 'krebs/3modules/fetchWallpaper.nix')
-rw-r--r--krebs/3modules/fetchWallpaper.nix27
1 files changed, 14 insertions, 13 deletions
diff --git a/krebs/3modules/fetchWallpaper.nix b/krebs/3modules/fetchWallpaper.nix
index f320c7505..53fe0839d 100644
--- a/krebs/3modules/fetchWallpaper.nix
+++ b/krebs/3modules/fetchWallpaper.nix
@@ -1,21 +1,17 @@
{ config, lib, pkgs, ... }:
-with lib;
+with config.krebs.lib;
let
cfg = config.krebs.fetchWallpaper;
out = {
options.krebs.fetchWallpaper = api;
- config = mkIf cfg.enable imp;
+ config = lib.mkIf cfg.enable imp;
};
api = {
enable = mkEnableOption "fetch wallpaper";
- predicate = mkOption {
- type = with types; nullOr path;
- default = null;
- };
url = mkOption {
type = types.str;
};
@@ -33,16 +29,20 @@ let
type = types.str;
default = ":11";
};
+ unitConfig = mkOption {
+ type = types.attrsOf types.str;
+ description = "Extra unit configuration for fetchWallpaper to define conditions and assertions for the unit";
+ example = literalExample ''
+ # do not start when running on umts
+ { ConditionPathExists = "!/var/run/ppp0.pid"; }
+ '';
+ default = {};
+ };
};
fetchWallpaperScript = pkgs.writeScript "fetchWallpaper" ''
#! ${pkgs.bash}/bin/bash
- ${optionalString (cfg.predicate != null) ''
- if ! ${cfg.predicate}; then
- echo "predicate failed - will not fetch from remote"
- exit 0
- fi
- ''}
+
mkdir -p ${shell.escape cfg.stateDir}
curl -s -o ${shell.escape cfg.stateDir}/wallpaper -z ${shell.escape cfg.stateDir}/wallpaper ${shell.escape cfg.url}
feh --no-fehbg --bg-scale ${shell.escape cfg.stateDir}/wallpaper
@@ -76,7 +76,6 @@ let
URL = cfg.url;
DISPLAY = cfg.display;
};
-
restartIfChanged = true;
serviceConfig = {
@@ -84,6 +83,8 @@ let
ExecStart = fetchWallpaperScript;
User = "fetchWallpaper";
};
+
+ unitConfig = cfg.unitConfig;
};
};
in out