Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6d6587dd87 | |||
| 995033f526 | |||
| fb42ccefaa | |||
| 08c00ac2a7 | |||
| 1d5687bbae | |||
| f3f4cdeabc | |||
| 2d062dee87 | |||
|
|
12dc7b849c | ||
|
|
38d9016792 | ||
|
|
3ea4574917 | ||
|
|
677e22d5e2 | ||
|
|
2b96ab089c | ||
|
|
4581c7155d | ||
|
|
d05afa09e8 |
42
.devcontainer/devcontainer.json
Normal file
42
.devcontainer/devcontainer.json
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
// 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",
|
||||||
|
"features": {
|
||||||
|
"ghcr.io/devcontainers/features/nix:1": {
|
||||||
|
"packages": "nixpkgs-fmt",
|
||||||
|
"extraNixConfig": "experimental-features = nix-command flakes"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||||
|
// "forwardPorts": [],
|
||||||
|
|
||||||
|
// Configure tool-specific properties.
|
||||||
|
"runArgs": ["--userns=keep-id"],
|
||||||
|
"containerUser": "vscode",
|
||||||
|
"customizations": {
|
||||||
|
"vscode": {
|
||||||
|
"extensions": [
|
||||||
|
"bbenoist.Nix"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 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 +1,2 @@
|
|||||||
_*
|
_*
|
||||||
|
result
|
||||||
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
|||||||
MIT No Attribution Copyright 2020 stubbfel
|
MIT No Attribution Copyright 2024 stubbfel
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
19
README.md
19
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.
|
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
|
### Commands
|
||||||
|
|
||||||
loadBuilder -> load device specific image builder and manifest ("default") packages list:
|
loadBuilder -> load device specific image builder and manifest ("default") packages list:
|
||||||
|
|
||||||
```sh
|
```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="<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
|
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
|
makeImage -> create image by image builder
|
||||||
|
|
||||||
```sh
|
```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="<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
|
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
|
removeBuilder -> remove image builder
|
||||||
|
|
||||||
```sh
|
```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="<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
|
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
|
makeCleanImage -> remove old image builder, load new image builder and create image
|
||||||
|
|
||||||
```sh
|
```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="<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
|
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:
|
created image can be found:
|
||||||
|
|
||||||
```sh
|
```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
|
## Device File
|
||||||
@@ -68,6 +73,7 @@ pkgs.callPackage <path_to_repo>/buildOpenwrt.nix {
|
|||||||
```
|
```
|
||||||
|
|
||||||
pi example
|
pi example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{ pkgs ? import <nixpkgs> {}}:
|
{ pkgs ? import <nixpkgs> {}}:
|
||||||
pkgs.callPackage ../buildOpenwrt.nix {
|
pkgs.callPackage ../buildOpenwrt.nix {
|
||||||
@@ -86,8 +92,11 @@ pkgs.callPackage ../buildOpenwrt.nix {
|
|||||||
build an image with:
|
build an image with:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# nix-shell <path_to_device_file>.nix --run makeCleanImage
|
# load nixe alias for `nix --experimental-features "nix-command flakes"`
|
||||||
nix-shell devices/pi-img.nix --run makeCleanImage
|
. alias.sh
|
||||||
|
|
||||||
|
# nix run <path_to_device_file>.nix
|
||||||
|
nixe run . devices/pi-img.nix
|
||||||
```
|
```
|
||||||
|
|
||||||
For more example see `devices` folder.
|
For more example see `devices` folder.
|
||||||
|
|||||||
3
alias.sh
Normal file
3
alias.sh
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/env sh
|
||||||
|
|
||||||
|
alias nixe='nix --experimental-features "nix-command flakes"'
|
||||||
@@ -7,7 +7,8 @@
|
|||||||
packages ? [],
|
packages ? [],
|
||||||
manifestPkgs ? "$(cat manifest_packages)",
|
manifestPkgs ? "$(cat manifest_packages)",
|
||||||
workingFolder ? "$PWD/_builder",
|
workingFolder ? "$PWD/_builder",
|
||||||
builderVersion ? version
|
builderVersion ? version,
|
||||||
|
moreBuildInputs ? []
|
||||||
}:
|
}:
|
||||||
pkgs.mkShell {
|
pkgs.mkShell {
|
||||||
name = "openwrt-build-${target}-${arch}-${profile}";
|
name = "openwrt-build-${target}-${arch}-${profile}";
|
||||||
@@ -22,7 +23,7 @@ pkgs.mkShell {
|
|||||||
git
|
git
|
||||||
python3Full
|
python3Full
|
||||||
rsync
|
rsync
|
||||||
man_db
|
man-db
|
||||||
gawk
|
gawk
|
||||||
gettext
|
gettext
|
||||||
unzip
|
unzip
|
||||||
@@ -38,13 +39,13 @@ pkgs.mkShell {
|
|||||||
gnutar
|
gnutar
|
||||||
curl
|
curl
|
||||||
cacert
|
cacert
|
||||||
];
|
] ++ moreBuildInputs;
|
||||||
shellHook =
|
shellHook =
|
||||||
''
|
''
|
||||||
export WORKING_FOLDER=$(realpath ${workingFolder})
|
export WORKING_FOLDER=$(realpath ${workingFolder})
|
||||||
mkdir -p $WORKING_FOLDER
|
mkdir -p $WORKING_FOLDER
|
||||||
function loadBuilder() {
|
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/${builderVersion}/targets/${target}/${arch}/openwrt-imagebuilder-${builderVersion}-${target}-${arch}.Linux-x86_64.tar.zst | tar -I zstd -xv -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-${version}-${target}-${arch}.manifest | cut -f 1 -d ' ' | tr '\n' ' ' > $WORKING_FOLDER/openwrt-imagebuilder-${builderVersion}-${target}-${arch}.Linux-x86_64/manifest_packages
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,17 @@
|
|||||||
pkgs.callPackage ../buildOpenwrt.nix {
|
pkgs.callPackage ../buildOpenwrt.nix {
|
||||||
target = "ar71xx";
|
target = "ar71xx";
|
||||||
arch = "generic";
|
arch = "generic";
|
||||||
version= "19.07.8";
|
version= "19.07.10";
|
||||||
profile = "gl-inet-6416A-v1";
|
profile = "gl-inet-6416A-v1";
|
||||||
packages = [
|
packages = [
|
||||||
"luci-ssl"
|
"luci-ssl"
|
||||||
"luci-proto-wireguard"
|
"luci-proto-wireguard"
|
||||||
"luci-app-wireguard"
|
"luci-app-wireguard"
|
||||||
|
"luci-app-mosquitto"
|
||||||
"kmod-ath9k-htc"
|
"kmod-ath9k-htc"
|
||||||
"ath9k-htc-firmware"
|
"ath9k-htc-firmware"
|
||||||
];
|
];
|
||||||
|
moreBuildInputs = with pkgs; [
|
||||||
|
python2Full
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,17 @@
|
|||||||
pkgs.callPackage ../buildOpenwrt.nix {
|
pkgs.callPackage ../buildOpenwrt.nix {
|
||||||
target = "mvebu";
|
target = "mvebu";
|
||||||
arch = "cortexa9";
|
arch = "cortexa9";
|
||||||
version= "19.07.8";
|
version= "24.10.2";
|
||||||
profile = "linksys_wrt1200ac";
|
profile = "linksys_wrt1200ac";
|
||||||
packages = [
|
packages = [
|
||||||
"adblock"
|
"adblock"
|
||||||
"luci-ssl"
|
"luci-ssl"
|
||||||
"luci-proto-wireguard"
|
"luci-proto-wireguard"
|
||||||
"luci-app-wireguard"
|
|
||||||
"luci-app-adblock"
|
"luci-app-adblock"
|
||||||
"luci-app-openvpn"
|
"luci-app-openvpn"
|
||||||
"openvpn-openssl"
|
"openvpn-openssl"
|
||||||
"tcpdump-mini"
|
"tcpdump-mini"
|
||||||
|
"usteer"
|
||||||
|
"luci-app-usteer"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
{ pkgs ? import <nixpkgs> {}}:
|
{ pkgs ? import <nixpkgs> {}}:
|
||||||
pkgs.callPackage ../buildOpenwrt.nix {
|
pkgs.callPackage ../buildOpenwrt.nix {
|
||||||
target = "brcm2708";
|
target = "bcm27xx";
|
||||||
arch = "bcm2708";
|
arch = "bcm2708";
|
||||||
version= "19.07.8";
|
version= "24.10.2";
|
||||||
profile = "rpi";
|
profile = "rpi";
|
||||||
packages = ["luci-ssl"];
|
packages = ["luci-ssl"];
|
||||||
}
|
}
|
||||||
|
|||||||
26
flake.lock
generated
Normal file
26
flake.lock
generated
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1741862977,
|
||||||
|
"narHash": "sha256-prZ0M8vE/ghRGGZcflvxCu40ObKaB+ikn74/xQoNrGQ=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "cdd2ef009676ac92b715ff26630164bb88fec4e0",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"id": "nixpkgs",
|
||||||
|
"ref": "nixos-24.11",
|
||||||
|
"type": "indirect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
85
flake.nix
Normal file
85
flake.nix
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
{
|
||||||
|
description = "NOIBW - Nix-Openwrt-ImageBuilder-Wrapper";
|
||||||
|
inputs.nixpkgs.url = "nixpkgs/nixos-25.05";
|
||||||
|
|
||||||
|
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}.writers.writeBash "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 update
|
||||||
|
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