Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored code to use nix #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

chewblacka
Copy link

@chewblacka chewblacka commented Jul 11, 2024

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:

  • Only install.sh requires sudo permissions. After that everything runs without sudo (OpenWRT recommend that the image builder doesn't run under sudo).
  • Should work on all x86 linux distros (not just debian).
  • User doesn't have to mess with script to modify packages - just the packages.txt file
  • Target / arch can be modified by editing target.txt
  • I've added a .gitignore file to ignore all files and track only the files in the current repo. This way you can clone the repo, build stuff in it, and still push back to git.
  • Have edited the README to reflect changes

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

@itiligent
Copy link
Owner

itiligent commented Jul 12, 2024

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.

@itiligent itiligent force-pushed the main branch 3 times, most recently from 06cd56d to dac3d14 Compare July 12, 2024 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants