astro / nix-openwrt-imagebuilder

Build OpenWRT images in Nix derivations
MIT License
129 stars 16 forks source link

How to specify snapshot release, target and variant in a flake please :) ? #23

Closed mannp closed 1 year ago

mannp commented 1 year ago

I am trying to build the following using my existing flake config for another device, but I am unclear how to specify these variables in a flake :-/

  release = "snapshot";
  target = "ipq40xx";
  variant = "generic";
  profile = "glinet_gl-a1300";

Any help would be much appreciated, thanks :)

{ pkgs ? import <nixpkgs> {}
, profiles ? import ./profiles.nix { inherit pkgs; }
#, profiles ? import ./profiles.nix { inherit pkgs; release = "snapshot"; target = "ipq40xx"; variant = "generic"; }
, build ? import ./builder.nix
}:
build (
  profiles.identifyProfile "glinet_gl-a1300"
  //
  {
    release = [ "snapshot" ];
    target = [ "ipq40xx" ];
    variant = [ "generic" ];
    packages = [
      #"zram-swap" "-ppp" "-ppp-mod-pppoe" "-ip6tables" "-odhcp6c" "-kmod-ipv6" "-kmod-ip6tables" "-odhcpd-ipv6only"
      "-ip6tables"
      "-kmod-ip6tables"
      "-kmod-nf-conntrack6"
      "-kmod-ppp"
      "-kmod-pppoe"
      "-kmod-pppox"
      "-kmod-usb-core"
      "-kmod-usb-ohci"
      "-kmod-usb2"
      "-libip6tc"
      "-libmbedtls"

Tried adding;

    release = [ "snapshot" ];
    target = [ "ipq40xx" ];
    variant = [ "generic" ];

But still get;

No match for OpenWRT profile glinet_gl-a1300

astro commented 1 year ago

You had it almost right. Because the profile depends on the release, you must pass release = "snapshot"; when importing profiles.nix.

Note that none of release, target, variant are lists but strings. They are actually returned by profiles.identifyProfile if successful (requiring OpenWRT >=18.06) so you don't need to specify them anywhere.

{ pkgs ? import <nixpkgs> {}
, profiles ? import ./profiles.nix { inherit pkgs; release = "snapshot"; }
, build ? import ./builder.nix
}:
build (
  profiles.identifyProfile "glinet_gl-a1300"
  //
  {
    packages = [
      #"zram-swap" "-ppp" "-ppp-mod-pppoe" "-ip6tables" "-odhcp6c" "-kmod-ipv6" "-kmod-ip6tables" "-odhcpd-ipv6only"
      "-ip6tables"
      "-kmod-ip6tables"
      "-kmod-nf-conntrack6"
      "-kmod-ppp"
      "-kmod-pppoe"
      "-kmod-pppox"
      "-kmod-usb-core"
      "-kmod-usb-ohci"
      "-kmod-usb2"
      "-libip6tc"
      "-libmbedtls"
    ];
  }
)

Of course, I needed to nix run .\#generate-hashes snapshot first. :roll_eyes:

mannp commented 1 year ago

@astro thanks for the prompt and useful reply.

Makes sense 👍🏻 and yes I'd already ran the generate hashes for snapshot :-)

Built successfully, thanks again.