diff options
author | pennae <pennae.git@eno.space> | 2023-09-22 20:55:05 +0200 |
---|---|---|
committer | pennae <pennae.git@eno.space> | 2023-09-22 21:06:55 +0200 |
commit | 66c6d2c1dfd4b3ef222bb64d3ccef9be915e0895 (patch) | |
tree | 0dde64acbdf9aa61134cdf066723bd731101f767 /openwrt/packages.nix | |
download | dewclaw-66c6d2c1dfd4b3ef222bb64d3ccef9be915e0895.tar.gz dewclaw-66c6d2c1dfd4b3ef222bb64d3ccef9be915e0895.tar.xz dewclaw-66c6d2c1dfd4b3ef222bb64d3ccef9be915e0895.zip |
initial commit
without warranty of any kind, express or impliend
Diffstat (limited to 'openwrt/packages.nix')
-rw-r--r-- | openwrt/packages.nix | 58 |
1 files changed, 58 insertions, 0 deletions
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) + ''; + }; +} |