From 1d3fc62af786ec1694cfe879e6f2abb4f50a6056 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 9 Jan 2022 00:52:03 +0100 Subject: sunwait --- flake.nix | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'flake.nix') 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