nur-packages

My NUR packages
git clone git://git.sikmir.ru/nur-packages
Log | Files | Refs | README | LICENSE

commit 84ee45621d7467f6616d73e1316383238adde59b
parent 7ad7bc4477c3deed8fcc642541eef0f68f5fe3e4
Author: Nikolay Korotkiy <sikmir@disroot.org>
Date:   Sat, 16 Dec 2023 00:08:14 +0400

Add gpsdate

Diffstat:
Mpkgs/default.nix | 1+
Apkgs/gnss/gpsdate/clock_settime.patch | 19+++++++++++++++++++
Apkgs/gnss/gpsdate/default.nix | 27+++++++++++++++++++++++++++
3 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/pkgs/default.nix b/pkgs/default.nix @@ -261,6 +261,7 @@ lib.makeScope newScope ( gnsstk = callPackage ./gnss/gnsstk { }; gnsstk-apps = callPackage ./gnss/gnsstk-apps { }; gps-sdr-sim = callPackage ./gnss/gps-sdr-sim { }; + gpsdate = callPackage ./gnss/gpsdate { }; rtklib = callPackage ./gnss/rtklib { }; visualgps = libsForQt5.callPackage ./gnss/visualgps { }; diff --git a/pkgs/gnss/gpsdate/clock_settime.patch b/pkgs/gnss/gpsdate/clock_settime.patch @@ -0,0 +1,19 @@ +diff --git i/gpsdate.c w/gpsdate.c +index 969bbdc..fe10276 100644 +--- i/gpsdate.c ++++ w/gpsdate.c +@@ -104,10 +104,11 @@ static void process_message(const char *msgid, const char **data) + t->tm_sec = seconds; + + /* Set new system time: */ +- time_t gps_time = mktime(t); +- gps_time += t->tm_gmtoff; ++ struct timespec gps_time; ++ gps_time.tv_sec = mktime(t) + t->tm_gmtoff; ++ gps_time.tv_nsec = 0; + +- if (stime(&gps_time) == 0) { ++ if (clock_settime(CLOCK_REALTIME, &gps_time) == 0) { + printf("Successfully updated local time.\n"); + date_changed = true; + } else { diff --git a/pkgs/gnss/gpsdate/default.nix b/pkgs/gnss/gpsdate/default.nix @@ -0,0 +1,27 @@ +{ lib, stdenv, fetchFromGitHub }: + +stdenv.mkDerivation (finalAttrs: { + pname = "gpsdate"; + version = "2019-12-02"; + + src = fetchFromGitHub { + owner = "adamheinrich"; + repo = "gpsdate"; + rev = "3e48ab58b73485d08e9f4d48054d5e7379e05805"; + hash = "sha256-h/XxQjjelUPYhIuJybZZm/bL07nj242utmYNCwTNw9w="; + }; + + patches = [ ./clock_settime.patch ]; + + installPhase = '' + install -Dm755 gpsdate -t $out/bin + ''; + + meta = with lib; { + description = "Simple tool for fetching date and time from a GPS receiver and saving it as a local time"; + inherit (finalAttrs.src.meta) homepage; + license = licenses.gpl3Plus; + maintainers = [ maintainers.sikmir ]; + platforms = platforms.unix; + }; +})