From 1d3fc62af786ec1694cfe879e6f2abb4f50a6056 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 9 Jan 2022 00:52:03 +0100 Subject: sunwait --- files/.config | 7 +++++++ flake.lock | 20 +++++++++++++++++++- flake.nix | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) diff --git a/files/.config b/files/.config index 80044c5..32d2146 100644 --- a/files/.config +++ b/files/.config @@ -716,6 +716,7 @@ CONFIG_FEED_packages=y CONFIG_FEED_luci=y CONFIG_FEED_routing=y CONFIG_FEED_telephony=y +CONFIG_FEED_sunwait=y # # Base system @@ -6933,6 +6934,12 @@ CONFIG_PACKAGE_e2fsprogs=y # CONFIG_PACKAGE_wall is not set # end of Terminal +# +# Utilities +# +CONFIG_PACKAGE_sunwait=y +# end of Utilities + # # Virtualization # diff --git a/flake.lock b/flake.lock index 79e8421..f4aeef7 100644 --- a/flake.lock +++ b/flake.lock @@ -121,7 +121,25 @@ "openwrt-luci": "openwrt-luci", "openwrt-packages": "openwrt-packages", "openwrt-routing": "openwrt-routing", - "openwrt-telephony": "openwrt-telephony" + "openwrt-telephony": "openwrt-telephony", + "sunwait": "sunwait" + } + }, + "sunwait": { + "flake": false, + "locked": { + "lastModified": 1603744793, + "narHash": "sha256-XQ16/JuHFQuHfToMZ3O5+5kvmFGJTKHiB4Hqb1nLSDM=", + "owner": "risacher", + "repo": "sunwait", + "rev": "102cb417ecbb7a3757ba9ee4b94d6db3225124c4", + "type": "github" + }, + "original": { + "owner": "risacher", + "ref": "master", + "repo": "sunwait", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index 33f1e76..ab4a0ef 100644 --- a/flake.nix +++ b/flake.nix @@ -38,6 +38,14 @@ url = "git+https://git.openwrt.org/feed/telephony.git"; flake = false; }; + + sunwait = { + type = "github"; + owner = "risacher"; + repo = "sunwait"; + ref = "master"; + flake = false; + }; }; outputs = { self, openwrt, nixpkgs, flake-utils, ... }@inputs: flake-utils.lib.eachDefaultSystem (system: @@ -100,11 +108,55 @@ phases = [ "unpackPhase" "patchPhase" "buildPhase" "installPhase" ]; patchPhase = let + sunwaitRepo = pkgs.runCommand "openwrt-sunwait" {} '' + mkdir -p $out/utils/sunwait + cp ${pkgs.writeText "Makefile" '' + include $(TOPDIR)/rules.mk + + PKG_NAME:=sunwait + PKG_VERSION:=${inputs.sunwait.rev} + PKG_RELEASE:=1 + + include $(INCLUDE_DIR)/package.mk + + define Package/sunwait + SECTION:=util + CATEGORY:=Utilities + TITLE:=Sunwait + URL:=https://github.com/risacher/sunwait + DEPENDS:=+libstdcpp +libc + endef + + define Package/sunwait/description + Wait until the specified solar event + endef + + define Build/Prepare + cp -r ${inputs.sunwait} . + cd $(basename ${inputs.sunwait}) + endef + + define Build/Compile + $(TARGET_CC) $(TARGET_CPPFLAGS) -o $(PKG_BUILD_DIR)/sunwait.o -c $(PKG_BUILD_DIR)/sunwait.cpp + $(TARGET_CC) $(TARGET_CPPFLAGS) -o $(PKG_BUILD_DIR)/sunriset.o -c $(PKG_BUILD_DIR)/sunriset.cpp + $(TARGET_CC) $(TARGET_CPPFLAGS) -o $(PKG_BUILD_DIR)/print.o -c $(PKG_BUILD_DIR)/print.cpp + $(TARGET_CC) $(TARGET_LDFLAGS) -o $(PKG_BUILD_DIR)/$1 $(PKG_BUILD_DIR)/sunwait.o $(PKG_BUILD_DIR)/sunriset.o $(PKG_BUILD_DIR)/print.o -lm -lstdc++ + endef + + define Package/sunwait/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/sunwait $(1)/usr/bin/ + endef + + $(eval $(call BuildPackage,sunwait)) + ''} $out/utils/sunwait/Makefile + ''; feedsConf = pkgs.writeText "feeds.conf" '' src-cpy packages ${inputs.openwrt-packages} src-cpy luci ${inputs.openwrt-luci} src-cpy routing ${inputs.openwrt-routing} src-cpy telephony ${inputs.openwrt-telephony} + src-cpy sunwait ${sunwaitRepo} ''; in '' rm feeds.conf.default -- cgit v1.2.3