From 17ecbc3a2a418ec0f6d2df412369a03ecd5945f4 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 25 Apr 2024 14:00:00 +0200 Subject: [PATCH] Add files for displaying a Google Maps picture --- .gitignore | 1 - default.nix | 31 +++++++++++++++++++++++++++++++ eval.nix | 10 ++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 default.nix create mode 100644 eval.nix diff --git a/.gitignore b/.gitignore index a806510..778d660 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -# ---> Nix # Ignore build outputs from performing a nix-build or `nix build` command result result-* diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..c395567 --- /dev/null +++ b/default.nix @@ -0,0 +1,31 @@ +{ pkgs, lib, config, ... }: +{ + options = { + scripts.output = lib.mkOption { + type = lib.types.package; + }; + + requestParams = lib.mkOption { + type = lib.types.listOf lib.types.str; + }; + }; + + config = { + scripts.output = pkgs.writeShellApplication { + name = "map"; + runtimeInputs = with pkgs; [ + curl + imagemagick + ]; + + text = '' + convert <(${./map} ${lib.concatStringsSep " " config.requestParams}) sixel:- + ''; + }; + + requestParams = [ + "size=640x300" + "scale=2" + ]; + }; +} diff --git a/eval.nix b/eval.nix new file mode 100644 index 0000000..c1d0e93 --- /dev/null +++ b/eval.nix @@ -0,0 +1,10 @@ +let + nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-22.11"; + pkgs = import nixpkgs { config = {}; overlays = []; }; +in + pkgs.lib.evalModules { + modules = [ + ({ config, ... }: { config._module.args = { inherit pkgs; }; }) + ./default.nix + ]; + }