itiligent / Easy-OpenWRT-Builder

A simple framework for building customized OpenWRT images with additional options for virtual machine conversion & embedded parition resizing
21 stars 8 forks source link

Refactored code to use nix #2

Open chewblacka opened 3 months ago

chewblacka commented 3 months ago

Hi just creating a pull request. Have refactored the code to install dependencies using nix package manager. These are the new files:

install.sh - installs the dependencies ( and the nix package manager if not already on the system). uninstall.sh - uninstalls nix packages.txt - contains list of packages any built image will contain target.txt - contains the target to build (x86 by default)

installer_files - directory containing installation files, including:

x86-imagebuilder.sh - a slightly modified version of your script flake.nix - this is the nix expression which is used to install the required dependencies (line 9), and copy the x86-imagebuilder.sh to the nix-store (i.e. /nix/store/...) where the install.sh symlinks it to buildimage.

Features:

Hope it's ok. Let me know if any issues! Many thanks

itiligent commented 3 months ago

Thanks very much for this, its quite educational for me.

I wont merge this however as I do have concerns this is too much of a divergence from the main purpose of this repo. I will try to explain...

The main points of this repo are:

  1. Educational: To lay out in the least complex the structured workflow of the OWRT image builder tool and a scripted representation of what the OWRT image build docs say. As such, eyes should be looking at the script to understand it and learn, however NIX aims to take eyes outside of it as well as potentially obfusacting this image builder workflow.
  2. To apply some defensive limits around the resize of partitions for noobs - NIX does not address this.

If introducing NIX, we effectively alter the all of the above and switch the focus away from explaining the OWRT image builder workflow in plain text to only a NIX based outcome. The extra NIX complexity may perhaps gain the avoidance of the use of sudo for the make image command - which I've now addressed with just a few line changes in bash.

This is an elegant solution for sure, but a likely more complex solution than is needed in this context. I thank you for this again and I will keep your PR here for others to find and also learn from.