From 66c6d2c1dfd4b3ef222bb64d3ccef9be915e0895 Mon Sep 17 00:00:00 2001 From: pennae Date: Fri, 22 Sep 2023 20:55:05 +0200 Subject: initial commit without warranty of any kind, express or impliend --- openwrt/packages.nix | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 openwrt/packages.nix (limited to 'openwrt/packages.nix') diff --git a/openwrt/packages.nix b/openwrt/packages.nix new file mode 100644 index 0000000..bf7b3a7 --- /dev/null +++ b/openwrt/packages.nix @@ -0,0 +1,58 @@ +{ pkgs, lib, config, ... }: + +let + deps = config.build.depsPackage; +in + +{ + options.packages = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = []; + description = '' + Extra packages to install. These are merely names of packages available + to opkg through the package source lists configured on the device, it is + not currently possible to provide packages for installation without + configuring an opkg source first. + ''; + }; + + config = { + deploySteps.packages = { + priority = 9999; + copy = '' + scp ${deps} device:/tmp/deps-${deps.version}.ipk + ''; + apply = '' + if [ ${deps.version} != "$(opkg info ${deps.package_name} | grep Version | cut -d' ' -f2)" ]; then + opkg update + opkg install --autoremove --force-downgrade /tmp/deps-${deps.version}.ipk + fi + ''; + }; + + build.depsPackage = pkgs.runCommand "deps.ipk" rec { + package_name = ".extra-system-deps."; + version = builtins.hashString "sha256" (toString config.packages); + control = '' + Package: ${package_name} + Version: ${version} + Architecture: all + Description: extra system dependencies + ${lib.optionalString + (config.packages != []) + "Depends: ${lib.concatStringsSep ", " config.packages}" + } + ''; + passAsFile = [ "control" ]; + } '' + mkdir -p deps/control deps/data + cp $controlPath deps/control/control + echo 2.0 > deps/debian-binary + + alias tar='command tar --numeric-owner --group=0 --owner=0' + (cd deps/control && tar -czf ../control.tar.gz ./*) + (cd deps/data && tar -czf ../data.tar.gz .) + (cd deps && tar -zcf $out ./debian-binary ./data.tar.gz ./control.tar.gz) + ''; + }; +} -- cgit v1.2.3