2021-10-24 15:14:14 +02:00
2021-10-24 15:14:14 +02:00
2020-10-07 22:18:32 +02:00
2021-07-13 23:01:10 +02:00
2020-10-07 22:18:32 +02:00
2020-10-07 22:18:32 +02:00

NOIBW - Nix-Openwrt-ImageBuilder-Wrapper

provide a nix shell, for creating openwrt images by the image builder in declarative way.

buildOpenwrt.nix - Base-Nix-Shell File

This file setup the nix shell with all necessary dependencies and shell environment.

Parameter

{
    pkgs ? import <nixpkgs> {}, # nix packages collection
    target, # build target
    arch, # target architecture
    profile, # build profile
    version, # openwrt version
    packages ? [], # list of user installed packages
    manifestPkgs ? "$(cat manifest_packages)", # manifest packages (fetch command)
    workingFolder ? "$PWD/_builder" # working folder
}:

Commands

loadBuilder -> load device specific image builder and manifest ("default") packages list:

# nix-shell --expr 'with import <nixpkgs> {}; callPackage ./buildOpenwrt.nix {target="<target_name>"; arch="<arch_name"; version="<openwrt_release_version>"; profile="<profile_name>"; packages=[<list_of_user_packages>];}' --pure --run loadBuilder
nix-shell --expr 'with import <nixpkgs> {}; callPackage ./buildOpenwrt.nix {target="brcm2708"; arch="bcm2708"; version="19.07.4"; profile="rpi"; packages=["luci-ssl"];}' --pure --run loadBuilder

makeImage -> create image by image builder

# nix-shell --expr 'with import <nixpkgs> {}; callPackage ./buildOpenwrt.nix {target="<target_name>"; arch="<arch_name"; version="<openwrt_release_version>"; profile="<profile_name>"; packages=[<list_of_user_packages>];}' --pure --run makeCmakeImageleanImage
nix-shell --expr 'with import <nixpkgs> {}; callPackage ./buildOpenwrt.nix {target="brcm2708"; arch="bcm2708"; version="19.07.4"; profile="rpi"; packages=["luci-ssl"];}' --pure --run makeImage

removeBuilder -> remove image builder

# nix-shell --expr 'with import <nixpkgs> {}; callPackage ./buildOpenwrt.nix {target="<target_name>"; arch="<arch_name"; version="<openwrt_release_version>"; profile="<profile_name>"; packages=[<list_of_user_packages>];}' --pure --run removeBuilder
nix-shell --expr 'with import <nixpkgs> {}; callPackage ./buildOpenwrt.nix {target="brcm2708"; arch="bcm2708"; version="19.07.4"; profile="rpi"; packages=["luci-ssl"];}' --pure --run removeBuilder

makeCleanImage -> remove old image builder, load new image builder and create image

# nix-shell --expr 'with import <nixpkgs> {}; callPackage ./buildOpenwrt.nix {target="<target_name>"; arch="<arch_name"; version="<openwrt_release_version>"; profile="<profile_name>"; packages=[<list_of_user_packages>];}' --pure --run makeCleanImage
nix-shell --expr 'with import <nixpkgs> {}; callPackage ./buildOpenwrt.nix {target="brcm2708"; arch="bcm2708"; version="19.07.4"; profile="rpi"; packages=["luci-ssl"];}' --pure --run makeCleanImage

created image can be found:

${workingFolder}/openwrt-imagebuilder-${version}-${target}-$arch}.Linux-x86_64/bin/targets/${target}/${arch}

Device File

Instead of using the --expr option, you can write the build parameter into a "device file", which describe the target device image.

{ pkgs ? import <nixpkgs> {}}:
pkgs.callPackage <path_to_repo>/buildOpenwrt.nix {
        target = "<target_name>";
        arch = "<arch_name>";
        version= "<version_number_string>";
        profile = "<profile_name";
        packages = [ <list_of_user_packages>];
}

pi example

{ pkgs ? import <nixpkgs> {}}:
pkgs.callPackage ../buildOpenwrt.nix {
        target = "brcm2708";
        arch = "bcm2708";
        version= "19.07.4";
        profile = "rpi";
        packages = [
            "luci-ssl"
            "luci-app-adblock"
            "luci-app-openvpn"
        ];
}

build an image with:

# nix-shell <path_to_device_file>.nix --run makeCleanImage
nix-shell devices/pi-img.nix --run makeCleanImage

For more example see devices folder.

Description
No description provided
Readme MIT-0 74 KiB
2022-05-29 18:07:22 +02:00
Languages
Nix 93.1%
Shell 6.9%