NixTutorial/default.nix

42 lines
778 B
Nix
Raw Normal View History

{ pkgs, lib, config, ... }:
{
options = {
scripts.output = lib.mkOption {
type = lib.types.package;
};
map = {
zoom = lib.mkOption {
type = lib.types.nullOr lib.types.int;
default = 2;
};
};
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"
(lib.mkIf (config.map.zoom != null)
"zoom=${toString config.map.zoom}")
];
};
}