From 2d062dee874ae555405483fc17c32594486a597c Mon Sep 17 00:00:00 2001 From: stubbfel Date: Sun, 23 Apr 2023 11:20:38 +0000 Subject: [PATCH] update 22.03.4 --- .devcontainer/devcontainer.json | 25 ++++++++++ .gitignore | 3 +- README.md | 12 +++-- alias.sh | 4 ++ buildOpenwrt.nix | 1 - devices/my-router-img.nix | 2 +- devices/pi-img.nix | 2 +- flake.lock | 26 ++++++++++ flake.nix | 85 +++++++++++++++++++++++++++++++++ 9 files changed, 153 insertions(+), 7 deletions(-) create mode 100644 .devcontainer/devcontainer.json create mode 100644 alias.sh create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..de9ce56 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,25 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/alpine +{ + "name": "Alpine", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/base:alpine-3.17", + "features": { + "ghcr.io/devcontainers/features/nix:1": {} + } + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "uname -a", + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.gitignore b/.gitignore index c434074..53df174 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -_* \ No newline at end of file +_* +result \ No newline at end of file diff --git a/README.md b/README.md index feaa05b..94d3de1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# NOIBW - Nix-Openwrt-ImageBuilder-Wrapper +# NOIBW - Nix-Openwrt-ImageBuilder-Wrapper provide a nix shell, for creating openwrt images by the image builder in declarative way. @@ -24,32 +24,37 @@ This file setup the nix shell with all necessary dependencies and shell environm ### Commands loadBuilder -> load device specific image builder and manifest ("default") packages list: + ```sh # nix-shell --expr 'with import {}; callPackage ./buildOpenwrt.nix {target=""; arch="];}' --pure --run loadBuilder nix-shell --expr 'with import {}; 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 + ```sh # nix-shell --expr 'with import {}; callPackage ./buildOpenwrt.nix {target=""; arch="];}' --pure --run makeCmakeImageleanImage nix-shell --expr 'with import {}; callPackage ./buildOpenwrt.nix {target="brcm2708"; arch="bcm2708"; version="19.07.4"; profile="rpi"; packages=["luci-ssl"];}' --pure --run makeImage ``` removeBuilder -> remove image builder + ```sh # nix-shell --expr 'with import {}; callPackage ./buildOpenwrt.nix {target=""; arch="];}' --pure --run removeBuilder nix-shell --expr 'with import {}; 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 + ```sh # nix-shell --expr 'with import {}; callPackage ./buildOpenwrt.nix {target=""; arch="];}' --pure --run makeCleanImage nix-shell --expr 'with import {}; callPackage ./buildOpenwrt.nix {target="brcm2708"; arch="bcm2708"; version="19.07.4"; profile="rpi"; packages=["luci-ssl"];}' --pure --run makeCleanImage ``` created image can be found: + ```sh -${workingFolder}/openwrt-imagebuilder-${version}-${target}-$arch}.Linux-x86_64/bin/targets/${target}/${arch} +${workingFolder}/openwrt-imagebuilder-${version}-${target}-${arch}.Linux-x86_64/bin/targets/${target}/${arch} ``` ## Device File @@ -68,6 +73,7 @@ pkgs.callPackage /buildOpenwrt.nix { ``` pi example + ```nix { pkgs ? import {}}: pkgs.callPackage ../buildOpenwrt.nix { @@ -90,4 +96,4 @@ build an image with: nix-shell devices/pi-img.nix --run makeCleanImage ``` -For more example see `devices` folder. \ No newline at end of file +For more example see `devices` folder. diff --git a/alias.sh b/alias.sh new file mode 100644 index 0000000..7726fd6 --- /dev/null +++ b/alias.sh @@ -0,0 +1,4 @@ +#!/bin/env sh + +alias nixe='nix --experimental-features "nix-command flakes"' +export NIXPKGS_ALLOW_INSECURE=1 \ No newline at end of file diff --git a/buildOpenwrt.nix b/buildOpenwrt.nix index 5939607..195c93c 100644 --- a/buildOpenwrt.nix +++ b/buildOpenwrt.nix @@ -20,7 +20,6 @@ pkgs.mkShell { gengetopt subversion git - python2Full python3Full rsync man-db diff --git a/devices/my-router-img.nix b/devices/my-router-img.nix index 3d41584..7b6d67a 100644 --- a/devices/my-router-img.nix +++ b/devices/my-router-img.nix @@ -2,7 +2,7 @@ pkgs.callPackage ../buildOpenwrt.nix { target = "mvebu"; arch = "cortexa9"; - version= "22.03.2"; + version= "22.03.4"; profile = "linksys_wrt1200ac"; packages = [ "adblock" diff --git a/devices/pi-img.nix b/devices/pi-img.nix index 85ee134..5c7719a 100644 --- a/devices/pi-img.nix +++ b/devices/pi-img.nix @@ -2,7 +2,7 @@ pkgs.callPackage ../buildOpenwrt.nix { target = "bcm27xx"; arch = "bcm2708"; - version= "22.03.2"; + version= "22.03.4"; profile = "rpi"; packages = ["luci-ssl"]; } diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..7abe5b0 --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1682173319, + "narHash": "sha256-tPhOpJJ+wrWIusvGgIB2+x6ILfDkEgQMX0BTtM5vd/4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ee7ec1c71adc47d2e3c2d5eb0d6b8fbbd42a8d1c", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-22.11-small", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..6bb1106 --- /dev/null +++ b/flake.nix @@ -0,0 +1,85 @@ +{ + description = "NOIBW - Nix-Openwrt-ImageBuilder-Wrapper"; + inputs.nixpkgs.url = "nixpkgs/nixos-22.11-small"; + + outputs = { self, nixpkgs }: + let + name = "NOIBW"; + version = "1.7.0"; + supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); + devTaskScripts = forAllSystems (system: + { + autoTag = nixpkgsFor.${system}.writeScript "auto_tag.sh" '' + git tag --force v${version} + git push origin v${version} + ''; + }); + appScripts = forAllSystems (system: + { + makeCleanImageScript = nixpkgsFor.${system}.writeScript "makeCleanImage.sh" '' + nix-shell "$1" --run makeCleanImage + ''; + }); + in + rec { + packages = forAllSystems (system: + { + default = appScripts.${system}.makeCleanImageScript; + }); + + apps = forAllSystems (system: + let + updateLockScript = nixpkgsFor.${system}.writeShellScriptBin "update_flake_lock.sh" '' + nix --experimental-features 'nix-command flakes' flake lock --update-input nixpkgs + nix --experimental-features 'nix-command flakes' build + ''; + in + { + default = { type = "app"; program = "${packages.${system}.default}"; }; + devTasks = { + updateFlakeLock = { type = "app"; program = "${updateLockScript}/bin/update_flake_lock.sh"; }; + autoTag = { type = "app"; program = "${devTaskScripts.${system}.autoTag}"; }; + }; + }); + + devShells = forAllSystems (system: + { + default = nixpkgsFor.${system}.mkShell { + name = "dev-shell"; + packages = with nixpkgsFor.${system}; [ + perl + quilt + ccache + libxslt + gcc + gengetopt + subversion + git + python3Full + rsync + man-db + gawk + gettext + unzip + file + wget + ncurses5.dev + zlib.static + gnumake + which + bash + coreutils + wget + gnutar + curl + cacert + ]; + shellHook = '' + alias nixe="nix --experimental-features 'nix-command flakes'" + ''; + }; + }); + }; +}