add maps app (doesn't do much yet)
This commit is contained in:
parent
6fd41b7e1c
commit
c3b796ef79
@ -49,6 +49,7 @@ in {
|
||||
});
|
||||
modemmanager-small = mm;
|
||||
satellite = prev.satellite.override { modemmanager = mm; };
|
||||
maps = final.callPackage ./pkgs/maps {};
|
||||
})
|
||||
];
|
||||
|
||||
@ -200,6 +201,7 @@ SUBSYSTEM=="wwan", ENV{DEVNAME}=="/dev/wwan0qmi0", ENV{DEVTYPE}=="wwan_port", \
|
||||
satellite
|
||||
wlr-randr
|
||||
modemmanager-small
|
||||
maps
|
||||
];
|
||||
|
||||
users.users.dan = {
|
||||
|
16
pkgs/maps/Makefile
Normal file
16
pkgs/maps/Makefile
Normal file
@ -0,0 +1,16 @@
|
||||
FENNEL?=fennel
|
||||
PREFIX?=/usr/local
|
||||
NAME?=maps
|
||||
|
||||
MODULES=main.fnl
|
||||
|
||||
%.lua : %.fnl
|
||||
$(FENNEL) --compile $< > $@
|
||||
|
||||
$(NAME): $(patsubst %.fnl,%.lua,$(MODULES)) Makefile
|
||||
(echo -e "#!/usr/bin/env lua\n" ; cat main.lua ) > $@
|
||||
chmod +x $@
|
||||
|
||||
install:
|
||||
mkdir -p $(PREFIX)/bin $(PREFIX)/
|
||||
cp $(NAME) $(PREFIX)/bin
|
85
pkgs/maps/default.nix
Normal file
85
pkgs/maps/default.nix
Normal file
@ -0,0 +1,85 @@
|
||||
{ stdenv
|
||||
, pkg-config
|
||||
, buildPackages
|
||||
, callPackage
|
||||
, clutter
|
||||
, fetchFromGitHub
|
||||
, fetchurl
|
||||
, gobject-introspection
|
||||
, gtk3
|
||||
, lib
|
||||
, lua53Packages
|
||||
, lua5_3
|
||||
, makeDesktopItem
|
||||
, makeWrapper
|
||||
, wrapGAppsHook3
|
||||
, writeText
|
||||
, osm-gps-map
|
||||
, glib-networking
|
||||
, copyDesktopItems
|
||||
}:
|
||||
let
|
||||
luaPackages = lua53Packages;
|
||||
fennel = luaPackages.fennel;
|
||||
lgi = luaPackages.buildLuaPackage {
|
||||
pname = "lgi";
|
||||
version = "0.9.2-2";
|
||||
buildInputs = [ gobject-introspection ];
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "lgi-devs";
|
||||
repo = "lgi";
|
||||
rev = "e06ad94c8a1c84e3cdb80cee293450a280dfcbc7";
|
||||
hash = "sha256-VYr/DV1FAyzPe6p6Quc1nmsHup23IAMfz532rL167Q4=";
|
||||
};
|
||||
};
|
||||
lua = lua5_3.withPackages (ps: with ps; [
|
||||
lgi
|
||||
luafilesystem
|
||||
luaposix
|
||||
readline
|
||||
]);
|
||||
pname = "maps";
|
||||
in stdenv.mkDerivation {
|
||||
inherit pname;
|
||||
version = "0.1";
|
||||
src =./.;
|
||||
|
||||
buildInputs = [
|
||||
lua
|
||||
gtk3.dev
|
||||
gobject-introspection # .dev
|
||||
osm-gps-map
|
||||
glib-networking
|
||||
# gdk-pixbuf
|
||||
# glib
|
||||
# libchamplain
|
||||
];
|
||||
nativeBuildInputs = [
|
||||
buildPackages.lua
|
||||
gobject-introspection
|
||||
makeWrapper
|
||||
fennel
|
||||
wrapGAppsHook3
|
||||
copyDesktopItems
|
||||
];
|
||||
GIO_EXTRA_MODULES = [ "${glib-networking.out}/lib/gio/modules" ];
|
||||
|
||||
makeFlags = [ "PREFIX=${placeholder "out"}" "NAME=${pname}" ];
|
||||
|
||||
postInstall = ''
|
||||
mkdir -p $out/share/icons/
|
||||
cp icon.svg $out/share/icons/${pname}.svg
|
||||
'';
|
||||
|
||||
desktopItems = [
|
||||
(makeDesktopItem {
|
||||
name = pname;
|
||||
desktopName = "Maps";
|
||||
exec = pname;
|
||||
type = "Application";
|
||||
icon = "nix-snowflake"; # "${placeholder "out"}/share/icons/${pname}.svg";
|
||||
})
|
||||
];
|
||||
}
|
71
pkgs/maps/main.fnl
Normal file
71
pkgs/maps/main.fnl
Normal file
@ -0,0 +1,71 @@
|
||||
; (local { : view } (require :fennel))
|
||||
|
||||
(local {
|
||||
: Gtk
|
||||
: OsmGpsMap
|
||||
: Gdk
|
||||
}
|
||||
(require :lgi))
|
||||
|
||||
(local CSS "
|
||||
label.readout {
|
||||
font: 48px \"Noto Sans\";
|
||||
margin: 10px;
|
||||
padding: 5px;
|
||||
background-color: rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
")
|
||||
|
||||
(fn styles []
|
||||
(let [style_provider (Gtk.CssProvider)]
|
||||
(Gtk.StyleContext.add_provider_for_screen
|
||||
(Gdk.Screen.get_default)
|
||||
style_provider
|
||||
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
|
||||
)
|
||||
(style_provider:load_from_data CSS)))
|
||||
|
||||
(local window (Gtk.Window {
|
||||
:title "Map"
|
||||
:name "toplevel"
|
||||
:default_width 720
|
||||
:default_height 800
|
||||
|
||||
:on_destroy Gtk.main_quit
|
||||
}))
|
||||
|
||||
(fn osm-widget []
|
||||
(doto (OsmGpsMap.Map {})
|
||||
(tset :map-source OsmGpsMap.MapSource_t.OPENSTREETMAP)
|
||||
(: :set_center_and_zoom 52.595 -0.1 14)
|
||||
(: :layer_add (OsmGpsMap.MapOsd {
|
||||
:show_copyright true
|
||||
; :show_coordinates true
|
||||
:show_scale true
|
||||
}))
|
||||
))
|
||||
|
||||
(fn readout [text]
|
||||
(doto (Gtk.Label {:label text})
|
||||
(-> (: :get_style_context) (: :add_class :readout))))
|
||||
|
||||
(fn readouts []
|
||||
(doto (Gtk.Box
|
||||
{
|
||||
:orientation Gtk.Orientation.VERTICAL
|
||||
:halign Gtk.Align.END
|
||||
})
|
||||
(-> (: :get_style_context) (: :add_class :readouts))
|
||||
(: :add (readout "21:05:00"))
|
||||
(: :add (readout "00:00"))
|
||||
(: :add (readout "25 km/h"))))
|
||||
|
||||
(window:add
|
||||
(doto (Gtk.Overlay {})
|
||||
(: :add (osm-widget))
|
||||
(: :add_overlay (readouts))
|
||||
))
|
||||
|
||||
(window:show_all)
|
||||
(styles)
|
||||
(Gtk:main)
|
9
pkgs/maps/shell.nix
Normal file
9
pkgs/maps/shell.nix
Normal file
@ -0,0 +1,9 @@
|
||||
with import <nixpkgs> {};
|
||||
let package = pkgs.callPackage ./. {};
|
||||
in
|
||||
package.overrideAttrs(o: {
|
||||
shellHook = ''
|
||||
export LUA_CPATH=$(lua -e "print(package.cpath)")
|
||||
export LUA_PATH=$(lua -e "print(package.path)")
|
||||
'';
|
||||
})
|
Loading…
Reference in New Issue
Block a user