Skip to content

Output image does not install uhttpd or luci #53

@TheRealGramdalf

Description

@TheRealGramdalf

I've got the imagebuilder set up with the following file:

{
  inputs,
  pkgs,
  x-wifi-password ? "none",
  x-hashed-root-password ? "none",
  ...
}: let
  ssh-pub-key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIL5ibKzd+V2eR1vmvBAfSWcZmPB8zUYFMAN3FS6xY9ma";

  argon = {
    ipk = builtins.fetchurl {
      url = "https://github.com/jerrykuku/luci-theme-argon/releases/download/v2.3.2/luci-theme-argon_2.3.2-r20250207_all.ipk";
      sha256 = "sha256:0csaa17wln1sy4x6v7dj2w6ly7v8s7xznxwhgb411mll1yxycdl8";
    };
    config-ipk = builtins.fetchurl {
      url = "https://github.com/jerrykuku/luci-app-argon-config/releases/download/v0.9/luci-app-argon-config_0.9_all.ipk";
      sha256 = "sha256:1mgz9a3b51m0mwr36y4105wfmqk97gnw0ilrx85df0fd6ddhb35x";
    };
    deps = [
      "luci-compat"
      "luci-lib-ipkg"
      "luci-lua-runtime"
      "curl"
    ];
    backgrounds = builtins.concatStringsSep " " [
      ./backgrounds/dragon-prince-3.jpg
      ./backgrounds/dragon-prince-4.jpg
    ];
  };

  profiles = inputs.openwrt-imagebuilder.lib.profiles {inherit pkgs;};

  config =
    profiles.identifyProfile "linksys_wrt1900ac-v1"
    // {
      release = "24.10.0";
      extraImageName = "killridge-ap";
      packages =
        [
          "iperf3"
          "luci-app-advanced-reboot"
          "luci-app-wifischedule"
        ]
        ++ argon.deps;
      files = pkgs.runCommand "image-files" {} ''

        ## Sub-optimally add extra ipk files to install (this takes up unneeded space)
        mkdir -p $out/root/extraPackages
        cp ${argon.ipk} $out/root/extraPackages/
        cp ${argon.config-ipk} $out/root/extraPackages/

        # Add argon backgrounds
        mkdir -p $out/www/luci-static/argon/background
        cp ${argon.backgrounds} $out/www/luci-static/argon/background/

        # Set UCI settings
        mkdir -p $out/etc/uci-defaults
        cat > $out/etc/uci-defaults/99-custom <<EOF
          exec >/root/uci-defaults.log 2>&1
          uci batch << EOI

            # Remove wan dhcp config
            del dhcp.wan
            # Set dhcp settings for LAN
            del dhcp.lan.ra_slaac
            set dhcp.lan.ignore='1'
            del dhcp.@dnsmasq[0].authoritative
            del dhcp.@dnsmasq[0].nonwildcard
            del dhcp.@dnsmasq[0].boguspriv
            del dhcp.@dnsmasq[0].filterwin2k
            del dhcp.@dnsmasq[0].filter_aaaa
            del dhcp.@dnsmasq[0].filter_a
            del dhcp.@dnsmasq[0].nonegcache
            set dhcp.@dnsmasq[0].local='/local/'
            set dhcp.@dnsmasq[0].domain='local'

            # Remove the WAN firewall zone
            del firewall.@zone[1]

            # Delete the WAN/WAN6 interfaces
            del network.wan
            del network.wan6

            # Set the static address so it won't conflict
            set network.lan.ipaddr='192.168.1.2'
            # Set the gateway and DNS server to the edge router
            set network.lan.gateway='192.168.1.1'
            add_list network.lan.dns='192.168.1.1'
            # Set the mDNS search domain
            add_list network.lan.dns_search='local'

            # Add the WAN port to the lan bridge
            del network.@device[0].ports
            add_list network.@device[0].ports='lan1'
            add_list network.@device[0].ports='lan2'
            add_list network.@device[0].ports='lan3'
            add_list network.@device[0].ports='lan4'
            add_list network.@device[0].ports='wan'
            set network.globals.packet_steering='1'


            # Set hostname, timezone
            del system.ntp.enabled
            del system.ntp.enable_server
            set system.@system[0].hostname='killridge'
            set system.@system[0].description='Wireless AP running OpenWRT'
            set system.@system[0].zonename='America/Vancouver'
            set system.@system[0].timezone='PST8PDT,M3.2.0,M11.1.0'
            set system.@system[0].log_proto='udp'
            set system.@system[0].conloglevel='8'
            set system.@system[0].cronloglevel='7'

            # WiFi
            # sae-mixed is WPA2/WPA3 mixed mode
            set wireless.radio0.htmode='HT20'
            set wireless.radio0.country='CA'
            set wireless.radio0.cell_density='0'
            set wireless.radio0.channel='auto'
            set wireless.default_radio0.ssid='OpenWRT'
            set wireless.default_radio0.encryption='sae-mixed'
            set wireless.default_radio0.key='${x-wifi-password}'
            set wireless.default_radio0.ocv='0'

            set wireless.radio1.country='CA'
            set wireless.radio1.cell_density='0'
            set wireless.radio1.channel='auto'
            set wireless.default_radio1.ssid='Openwrt'
            set wireless.default_radio1.encryption='sae-mixed'
            set wireless.default_radio1.key='${x-wifi-password}'
            set wireless.default_radio1.ocv='0'

            # Enable WiFi
            del wireless.default_radio1.disabled='0'
            del wireless.default_radio0.disabled='0'
            del wireless.radio1.disabled='0'
            del wireless.radio0.disabled='0'
            
            # Disable password authentication (disabled for testing)
            #set dropbear.main.PasswordAuth='off'
            #set dropbear.main.RootPasswordAuth='off'


            # Redirect HTTP requests to HTTPS (LUCI)
            set uhttpd.main.redirect_https='1'

            # Set argon to dark mode
            set argon.@global[0].mode='dark'


            commit
          EOI

          # Add an ssh key
          echo "${ssh-pub-key}" >> /etc/dropbear/authorized_keys

          # Make a backup of /etc/shadow to /etc/shadow- as per the busybox passwd convention
          ##cp /etc/shadow /etc/shadow-
          # Change root password. Note the escaped \$ character in the regex.
          # The $pass variable must be defined as literal, as it contains special characters. Either escape said characters or use single quotes.
          ##sed -i -e "s;^root:[\$A-z0-9]*:;root:${x-hashed-root-password}:;" /etc/shadow

        EOF
      '';
    };
in
  inputs.openwrt-imagebuilder.lib.build config

But after building and flashing it, neither uhttpd or luci is installed, leaving a system without a WebUI.
Is this an issue with nix-openwrt-imagebuilder specifically, or is it a limitation/bug in the upstream imagebuilder itself? I swear I've seen a note somewhere on the OpenWRT wiki saying it doesn't include luci/uhttpd by default, but all I can find is the following: https://openwrt.org/docs/guide-developer/toolchain/use-buildsystem#using_official_build_config

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions