summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple/realwallpaper/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'krebs/5pkgs/simple/realwallpaper/default.nix')
-rw-r--r--krebs/5pkgs/simple/realwallpaper/default.nix82
1 files changed, 77 insertions, 5 deletions
diff --git a/krebs/5pkgs/simple/realwallpaper/default.nix b/krebs/5pkgs/simple/realwallpaper/default.nix
index 04a2a6718..8728c0ae7 100644
--- a/krebs/5pkgs/simple/realwallpaper/default.nix
+++ b/krebs/5pkgs/simple/realwallpaper/default.nix
@@ -1,6 +1,21 @@
{ pkgs, ... }:
pkgs.writers.writeDashBin "generate-wallpaper" ''
- set -euf
+ set -xeuf
+
+ export PATH=${with pkgs; lib.makeBinPath [
+ coreutils
+ curl
+ gnugrep
+ gnused
+ file
+ findutils
+ grib2json
+ imagemagick
+ inkscape
+ jq
+ nomads-cloud
+ xplanet
+ ]}
# usage: getimg FILENAME URL
fetch() {
@@ -118,7 +133,7 @@ pkgs.writers.writeDashBin "generate-wallpaper" ''
# fetch clouds if they are older than 3h
if ! test "$(find clouds-raw.png -mmin -180)"; then
- ${pkgs.nomads-cloud}/bin/nomads-cloud clouds-raw.png
+ nomads-cloud clouds-raw.png
fi
in_size=3600x1800
@@ -161,14 +176,14 @@ pkgs.writers.writeDashBin "generate-wallpaper" ''
fi
if needs_rebuild krebs.png krebs-raw.svg; then
- inkscape -z -e krebs.png -w 16 -h 16 krebs-raw.svg
+ inkscape --export-type="png" --export-width=16 --export-height=16 --export-filename=krebs.png krebs-raw.svg
fi
# -- Planets --
for planet in mercury venus mars jupiter saturn uranus neptune; do
if needs_rebuild "$planet".png "$planet"-raw.svg; then
sed -i 's/#000/#FE8019/g' "$planet"-raw.svg
- inkscape -z -e "$planet".png -w 40 -h 40 "$planet"-raw.svg
+ inkscape --export-type="png" --export-width=40 --export-height=40 --export-filename="$planet.png" "$planet-raw.svg"
fi
done
@@ -256,6 +271,52 @@ pkgs.writers.writeDashBin "generate-wallpaper" ''
shade=15
''}
+ ${pkgs.writers.writePython3 "get_constellations" {
+ libraries = [ pkgs.python3Packages.astropy ];
+ } ./get_constellations.py} ${pkgs.fetchurl {
+ url = "https://raw.githubusercontent.com/ofrohn/d3-celestial/d2e20e104b86429d90ac8227a5b021262b45d75a/data/constellations.lines.json";
+ sha256 = "0g71fdrnxvxd6pcqvihj2q9iaynrl7px45kzw6qm1kymynz6ckr9";
+ }} > constellations.arcs
+
+ xplanet --num_times 1 --geometry $xplanet_out_size \
+ --output xplanet-krebs-stars-output.png --projection merc \
+ -config ${pkgs.writeText "xplanet-krebs-stars.config" ''
+ [default]
+
+ arc_thickness=1
+ arc_file=constellations.arcs
+
+ [earth]
+ "Earth"
+ map=daymap-final.png
+ night_map=nightmap-final.png
+ cloud_map=clouds.png
+ cloud_threshold=1
+ cloud_gamma=10
+ marker_file=marker_file
+ shade=15
+ ''}
+
+ xplanet --num_times 1 --geometry $xplanet_out_size \
+ --latitude 52.520008 --longitude 13.404954 \
+ --output xplanet-krebs-stars-berlin-output.png --projection merc \
+ -config ${pkgs.writeText "xplanet-krebs-stars.config" ''
+ [default]
+
+ arc_thickness=1
+ arc_file=constellations.arcs
+
+ [earth]
+ "Earth"
+ map=daymap-final.png
+ night_map=nightmap-final.png
+ cloud_map=clouds.png
+ cloud_threshold=1
+ cloud_gamma=10
+ marker_file=marker_file
+ shade=15
+ ''}
+
# trim xplanet output
if needs_rebuild realwallpaper.png xplanet-output.png; then
convert xplanet-output.png -crop $out_geometry \
@@ -263,7 +324,6 @@ pkgs.writers.writeDashBin "generate-wallpaper" ''
mv realwallpaper-tmp.png realwallpaper.png
fi
- # trim xplanet output
if needs_rebuild realwallpaper-marker.png xplanet-marker-output.png; then
convert xplanet-marker-output.png -crop $out_geometry \
realwallpaper-marker-tmp.png
@@ -277,6 +337,18 @@ pkgs.writers.writeDashBin "generate-wallpaper" ''
mkdir -p archive
convert realwallpaper-krebs.png archive/"$(date -Is)".jpg
fi
+
+ if needs_rebuild realwallpaper-krebs-stars.png xplanet-krebs-stars-output.png; then
+ convert xplanet-krebs-stars-output.png -crop $out_geometry \
+ realwallpaper-krebs-stars-tmp.png
+ mv realwallpaper-krebs-stars-tmp.png realwallpaper-krebs-stars.png
+ fi
+
+ if needs_rebuild realwallpaper-krebs-stars-berlin.png xplanet-krebs-stars-berlin-output.png; then
+ convert xplanet-krebs-stars-berlin-output.png -crop $out_geometry \
+ realwallpaper-krebs-stars-berlin-tmp.png
+ mv realwallpaper-krebs-stars-berlin-tmp.png realwallpaper-krebs-stars-berlin.png
+ fi
}
main "$@"