diff options
author | lassulus <lass@aidsballs.de> | 2015-10-03 18:21:01 +0200 |
---|---|---|
committer | lassulus <lass@aidsballs.de> | 2015-10-04 13:42:29 +0200 |
commit | 0a7d4c3469a0411790e6edb5bfe7d0bef3bf2dd6 (patch) | |
tree | 9c678d89e556499084b13fdc93c663cba7da099c | |
parent | 041ef784486b554374fd5ad9e172889ad7e631d2 (diff) |
lass 3: add wallpaper.nix
lass 2 configs: add wallpaper.nix
lass 2: add wallpaper-server.nix
lass: refactor realwallpaper
-rw-r--r-- | lass/1systems/cloudkrebs.nix | 2 | ||||
-rw-r--r-- | lass/1systems/echelon.nix | 1 | ||||
-rw-r--r-- | lass/1systems/mors.nix | 2 | ||||
-rw-r--r-- | lass/2configs/realwallpaper-server.nix | 32 | ||||
-rw-r--r-- | lass/2configs/realwallpaper.nix | 9 | ||||
-rw-r--r-- | lass/3modules/default.nix | 1 | ||||
-rw-r--r-- | lass/3modules/realwallpaper.nix | 102 | ||||
-rw-r--r-- | lass/5pkgs/default.nix | 1 | ||||
-rw-r--r-- | lass/5pkgs/realwallpaper.nix | 28 |
9 files changed, 176 insertions, 2 deletions
diff --git a/lass/1systems/cloudkrebs.nix b/lass/1systems/cloudkrebs.nix index 19675be32..2a6a70ffd 100644 --- a/lass/1systems/cloudkrebs.nix +++ b/lass/1systems/cloudkrebs.nix @@ -14,7 +14,7 @@ in { ../2configs/retiolum.nix ../2configs/fastpoke-pages.nix ../2configs/new-repos.nix - ../2configs/privoxy-retiolum.nix + ../2configs/realwallpaper.nix { networking.interfaces.enp2s1.ip4 = [ { diff --git a/lass/1systems/echelon.nix b/lass/1systems/echelon.nix index d1a3f34f7..782674cb0 100644 --- a/lass/1systems/echelon.nix +++ b/lass/1systems/echelon.nix @@ -11,6 +11,7 @@ in { ../../tv/2configs/CAC-CentOS-7-64bit.nix ../2configs/base.nix ../2configs/retiolum.nix + ../2configs/realwallpaper.nix { networking.interfaces.enp2s1.ip4 = [ { diff --git a/lass/1systems/mors.nix b/lass/1systems/mors.nix index 1ac1c2162..414afcbba 100644 --- a/lass/1systems/mors.nix +++ b/lass/1systems/mors.nix @@ -23,7 +23,7 @@ ../2configs/wordpress.nix ../2configs/bitlbee.nix ../2configs/firefoxPatched.nix - ../2configs/wallpaper.nix + ../2configs/realwallpaper.nix ]; krebs.build = { diff --git a/lass/2configs/realwallpaper-server.nix b/lass/2configs/realwallpaper-server.nix new file mode 100644 index 000000000..7340fc7ca --- /dev/null +++ b/lass/2configs/realwallpaper-server.nix @@ -0,0 +1,32 @@ +{ config, lib, ... }: + +let + hostname = config.krebs.build.host.name; + inherit (lib) + nameValuePair + ; + +in { + imports = [ + ./realwallpaper.nix + ]; + + krebs.nginx.servers.wallpaper = { + server-names = [ + hostname + ]; + locations = [ + (nameValuePair "/wallpaper.png" '' + root /tmp/; + '') + ]; + }; + + krebs.iptables = { + tables = { + filter.INPUT.rules = [ + { predicate = "-i retiolum -p tcp --dport 80"; target = "ACCEPT"; } + ]; + }; + }; +} diff --git a/lass/2configs/realwallpaper.nix b/lass/2configs/realwallpaper.nix new file mode 100644 index 000000000..f1c8861e1 --- /dev/null +++ b/lass/2configs/realwallpaper.nix @@ -0,0 +1,9 @@ +{ config, ... }: + +{ + imports = [ + ../3modules/realwallpaper.nix + ]; + + lass.realwallpaper.enable = true; +} diff --git a/lass/3modules/default.nix b/lass/3modules/default.nix index 9de987bf3..9b6211278 100644 --- a/lass/3modules/default.nix +++ b/lass/3modules/default.nix @@ -3,5 +3,6 @@ _: { imports = [ ./xresources.nix + ./realwallpaper.nix ]; } diff --git a/lass/3modules/realwallpaper.nix b/lass/3modules/realwallpaper.nix new file mode 100644 index 000000000..85dd35233 --- /dev/null +++ b/lass/3modules/realwallpaper.nix @@ -0,0 +1,102 @@ +arg@{ config, lib, pkgs, ... }: + +let + inherit (lib) + mkEnableOption + mkOption + types + mkIf + ; + + lpkgs = import ../5pkgs { inherit pkgs; }; + + cfg = config.lass.realwallpaper; + + out = { + options.lass.realwallpaper = api; + config = mkIf cfg.enable imp; + }; + + api = { + enable = mkEnableOption "realwallpaper"; + + workingDir = mkOption { + type = types.str; + default = "/var/realwallpaper/"; + }; + + nightmap = mkOption { + type = types.str; + default = "http://eoimages.gsfc.nasa.gov/images/imagerecords/55000/55167/earth_lights_lrg.jpg"; + }; + + daymap = mkOption { + type = types.str; + default = "http://www.nnvl.noaa.gov/images/globaldata/SnowIceCover_Daily.png"; + }; + + cloudmap = mkOption { + type = types.str; + default = "http://xplanetclouds.com/free/local/clouds_2048.jpg"; + }; + + outFile = mkOption { + type = types.str; + default = "/tmp/wallpaper.png"; + }; + + timerConfig = mkOption { + type = types.unspecified; + default = { + OnCalendar = "*:0/15"; + }; + }; + + }; + + imp = { + systemd.timers.realwallpaper = { + description = "real wallpaper generator timer"; + + timerConfig = cfg.timerConfig; + }; + + systemd.services.realwallpaper = { + description = "real wallpaper generator"; + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + + path = with pkgs; [ + xplanet + imagemagick + curl + file + ]; + + environment = { + working_dir = cfg.workingDir; + nightmap_url = cfg.nightmap; + daymap_url = cfg.daymap; + cloudmap_url = cfg.cloudmap; + out_file = cfg.outFile; + }; + + restartIfChanged = true; + + serviceConfig = { + Type = "simple"; + ExecStart = "${lpkgs.realwallpaper}/realwallpaper.sh"; + User = "realwallpaper"; + }; + }; + + users.extraUsers.realwallpaper = { + uid = 2009435407; #genid realwallpaper + home = cfg.workingDir; + createHome = true; + }; + }; + +in +out + diff --git a/lass/5pkgs/default.nix b/lass/5pkgs/default.nix index 7427cb620..6954c6a2c 100644 --- a/lass/5pkgs/default.nix +++ b/lass/5pkgs/default.nix @@ -13,4 +13,5 @@ rec { ublock = callPackage ./firefoxPlugins/ublock.nix {}; vimperator = callPackage ./firefoxPlugins/vimperator.nix {}; }; + realwallpaper = callPackage ./realwallpaper.nix {}; } diff --git a/lass/5pkgs/realwallpaper.nix b/lass/5pkgs/realwallpaper.nix new file mode 100644 index 000000000..4fea977ec --- /dev/null +++ b/lass/5pkgs/realwallpaper.nix @@ -0,0 +1,28 @@ +{ stdenv, fetchgit, xplanet, imagemagick, curl, file }: + +stdenv.mkDerivation { + name = "realwallpaper"; + + src = fetchgit { + url = https://github.com/Lassulus/realwallpaper; + rev = "c2778c3c235fc32edc8115d533a0d0853ab101c5"; + sha256 = "0yhbjz19zk8sj5dsvccm6skkqq2vardn1yi70qmd5li7qvp17mvs"; + }; + + phases = [ + "unpackPhase" + "installPhase" + ]; + + buildInputs = [ + xplanet + imagemagick + curl + file + ]; + + installPhase = '' + mkdir -p $out + cp realwallpaper.sh $out/realwallpaper.sh + ''; +} |