Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d4ae9fad4 | ||
|
|
c1d482f9a8 | ||
|
|
dbfb4f2b93 |
@@ -1,25 +0,0 @@
|
||||
// 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"
|
||||
}
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,2 +1 @@
|
||||
_*
|
||||
result
|
||||
_*
|
||||
17
.gitlab-ci.yml
Normal file
17
.gitlab-ci.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
pages:
|
||||
image:
|
||||
name: pandoc/alpine
|
||||
entrypoint: ["/bin/sh", "-c"]
|
||||
script:
|
||||
- mkdir -p public
|
||||
- echo '<meta name="google-site-verification" content="ooqaohCgAywtsa97hQcmfXVsc5ZlgQaKSnXvTkSSLGE" />' > header.html
|
||||
- pandoc -f markdown -t html -s README.md -o public/index.html --metadata title="NOIBW - Nix-Openwrt-ImageBuilder-Wrapper" --metadata keywords=nix,shell,openwrt,image,builder -H header.html
|
||||
artifacts:
|
||||
paths:
|
||||
- public
|
||||
rules:
|
||||
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]$/'
|
||||
when: on_success
|
||||
allow_failure: false
|
||||
- when: manual
|
||||
allow_failure: true
|
||||
12
README.md
12
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,37 +24,32 @@ 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 <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
|
||||
|
||||
```sh
|
||||
# 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
|
||||
|
||||
```sh
|
||||
# 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
|
||||
|
||||
```sh
|
||||
# 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:
|
||||
|
||||
```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
|
||||
@@ -73,7 +68,6 @@ pkgs.callPackage <path_to_repo>/buildOpenwrt.nix {
|
||||
```
|
||||
|
||||
pi example
|
||||
|
||||
```nix
|
||||
{ pkgs ? import <nixpkgs> {}}:
|
||||
pkgs.callPackage ../buildOpenwrt.nix {
|
||||
@@ -96,4 +90,4 @@ build an image with:
|
||||
nix-shell devices/pi-img.nix --run makeCleanImage
|
||||
```
|
||||
|
||||
For more example see `devices` folder.
|
||||
For more example see `devices` folder.
|
||||
3
alias.sh
3
alias.sh
@@ -1,3 +0,0 @@
|
||||
#!/bin/env sh
|
||||
|
||||
alias nixe='nix --experimental-features "nix-command flakes"'
|
||||
@@ -6,8 +6,7 @@
|
||||
version,
|
||||
packages ? [],
|
||||
manifestPkgs ? "$(cat manifest_packages)",
|
||||
workingFolder ? "$PWD/_builder",
|
||||
builderVersion ? version
|
||||
workingFolder ? "$PWD/_builder"
|
||||
}:
|
||||
pkgs.mkShell {
|
||||
name = "openwrt-build-${target}-${arch}-${profile}";
|
||||
@@ -22,7 +21,7 @@ pkgs.mkShell {
|
||||
git
|
||||
python3Full
|
||||
rsync
|
||||
man-db
|
||||
man_db
|
||||
gawk
|
||||
gettext
|
||||
unzip
|
||||
@@ -42,18 +41,17 @@ pkgs.mkShell {
|
||||
shellHook =
|
||||
''
|
||||
export WORKING_FOLDER=$(realpath ${workingFolder})
|
||||
mkdir -p $WORKING_FOLDER
|
||||
function loadBuilder() {
|
||||
curl -s https://downloads.openwrt.org/releases/${builderVersion}/targets/${target}/${arch}/openwrt-imagebuilder-${builderVersion}-${target}-${arch}.Linux-x86_64.tar.xz | tar xvJ -C $WORKING_FOLDER
|
||||
curl -s https://downloads.openwrt.org/releases/${version}/targets/${target}/${arch}/openwrt-${version}-${target}-${arch}.manifest | cut -f 1 -d ' ' | tr '\n' ' ' > $WORKING_FOLDER/openwrt-imagebuilder-${builderVersion}-${target}-${arch}.Linux-x86_64/manifest_packages
|
||||
curl -s https://downloads.openwrt.org/releases/${version}/targets/${target}/${arch}/openwrt-imagebuilder-${version}-${target}-${arch}.Linux-x86_64.tar.xz | tar xvJ -C $WORKING_FOLDER
|
||||
curl -s https://downloads.openwrt.org/releases/${version}/targets/${target}/${arch}/openwrt-${version}-${target}-${arch}.manifest | cut -f 1 -d ' ' | tr '\n' ' ' > $WORKING_FOLDER/openwrt-imagebuilder-${version}-${target}-${arch}.Linux-x86_64/manifest_packages
|
||||
}
|
||||
|
||||
function removeBuilder() {
|
||||
rm -rf $WORKING_FOLDER/openwrt-imagebuilder-${builderVersion}-${target}-${arch}.Linux-x86_64
|
||||
rm -rf $WORKING_FOLDER/openwrt-imagebuilder-${version}-${target}-${arch}.Linux-x86_64
|
||||
}
|
||||
|
||||
function makeImage() {
|
||||
cd $WORKING_FOLDER/openwrt-imagebuilder-${builderVersion}-${target}-${arch}.Linux-x86_64
|
||||
cd $WORKING_FOLDER/openwrt-imagebuilder-${version}-${target}-${arch}.Linux-x86_64
|
||||
MANIFEST_PKGS=${manifestPkgs}
|
||||
make image PROFILE=${profile} PACKAGES="$MANIFEST_PKGS ${toString packages}"
|
||||
}
|
||||
|
||||
@@ -2,14 +2,11 @@
|
||||
pkgs.callPackage ../buildOpenwrt.nix {
|
||||
target = "ar71xx";
|
||||
arch = "generic";
|
||||
version= "19.07.8";
|
||||
version= "19.07.4";
|
||||
profile = "gl-inet-6416A-v1";
|
||||
packages = [
|
||||
"luci-ssl"
|
||||
"luci-proto-wireguard"
|
||||
"luci-app-wireguard"
|
||||
"luci-app-mosquitto"
|
||||
"kmod-ath9k-htc"
|
||||
"ath9k-htc-firmware"
|
||||
];
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
pkgs.callPackage ../buildOpenwrt.nix {
|
||||
target = "mvebu";
|
||||
arch = "cortexa9";
|
||||
version= "22.03.4";
|
||||
version= "19.07.4";
|
||||
profile = "linksys_wrt1200ac";
|
||||
packages = [
|
||||
"adblock"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{ pkgs ? import <nixpkgs> {}}:
|
||||
pkgs.callPackage ../buildOpenwrt.nix {
|
||||
target = "bcm27xx";
|
||||
target = "brcm2708";
|
||||
arch = "bcm2708";
|
||||
version= "22.03.4";
|
||||
version= "19.07.4";
|
||||
profile = "rpi";
|
||||
packages = ["luci-ssl"];
|
||||
packages = ["luci-ssl"];
|
||||
}
|
||||
|
||||
26
flake.lock
generated
26
flake.lock
generated
@@ -1,26 +0,0 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
85
flake.nix
85
flake.nix
@@ -1,85 +0,0 @@
|
||||
{
|
||||
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'"
|
||||
'';
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user