๐ A collection of C++, Python & Rust development-oriented config scripts to quickly init new machines ๐ป for my personal use. Dotfiles are in a separate repository here: https://github.com/jan-revay/dotfiles and here: https://github.com/jan-revay/windows_dotfiles
cd ~
git clone https://github.com/jan-revay/initPC.git
cd initPC/
git checkout <branch>
(optional step, branchdevel
is the default)- Run the initPC script launcher:
./run_init.sh
- on Linux distros or TermuxSet-ExecutionPolicy unrestricted && cd Windows_10 && .\run_all.ps1
- on Windows
โ๏ธ Note: Logs will appear in the folder initPC/Logs/
. Use cat <logfile>
to display the log file with the original VT100 colors.
Run the refresh
command from Bash, after you have updated the initPC
or dotfiles
repo (e.g. adding a package, changing a config file, or adding an alias...), to apply the config change to your machine (after the first run). The script never removes any packages other than the ones in apt-get autoremove
, therefore removing packages from the init script does not have any effect after the first run.
devel
- development and experiments, might be inconsistent or broken regularly. Consistent, and fully functional changes from the branchdevel
might be merged into the branchtesting
. Thedevel
branch is expected to be broken from time to time (e.g. when working on larger changes "per partes" or experimenting) and it might not always be possible to init a machine using it. New changes are usually pushed to thedevel
branch directly, however, very large changes can have an individual feature branch.testing
- shouldn't be broken or inconsistent most of the time, changes fromdevel
that are queued to be accepted to thestable
branch (or rejected). If a change is rejected fromtesting
it will be dropped via a commit intodevel
that will be fast-forward merged to thetesting
branch again.stable
- tested, stable, useful, production-ready, and not expected to change more than a few times a year.LTS
- debloated, (also tested, stable, useful, production-ready) and not expected to change much in the yearly horizon. Only necessary stuff. Possibly useful for detecting whether bugs in thestable
branch are caused by the init script or to be used as a substitute for thestable
branch while thestable
branch has a critical bug. Debloating is done via additional commits on top of theLTS
branch, therefore syncingstable
andLTS
is done via rebasing to preserve the debloating commits on top. As theLTS
branch has additional commits on top, it is tested separately.feature-<name of the feature>
- all feature branches should be branched off and merged todevel
. Features and bugfixes oftesting
,stable
, orLTS
should always go through thedevel
branch first (following the change workflow below).archived/<branch-name>-<YYYY-MM-DD>
- branches archived before apush --force
.
LTS
, stable
, and testing
branches are expected to be always in a consistent state so that they can always be used to init a new machine e.g. VM or a bootable partition.
โ๏ธ Note: By stable I mean free of unpredictable behavior and crashes, not as described here: https://medium.com/@gordon.messmer/what-does-stable-mean-4447ac53bac8 (TODO toread)
functional & tested, stable, useful not changing, debloated,
impl. consistent** & production-ready retested & stable
O---------> devel ---------------> testing -----------------> stable -----------------> LTS
| โง ff-only merge ff-only merge rebase
| impl. |
| |
+-----> feature-branch
large
change
** "consistent" means, among other things, that all CI tests (implemented via GitHub actions) pass successfully.
At the moment it would just add complexity, and unnecessary dependence (e.g. it could break Termux on Android), be less flexible, and would not be as beneficial for a project of this size. Also, I don't have any experience in writing Ansible scripts... However, I might rewrite some parts of the codebase to Ansible scripts later.
Dotfiles are currently managed via a bare Git repo (home directory) and Stow (system-level configuration files). In the future, I might use Chezmoi or a more sophisticated tool for managing dotfiles & templating them, if the need arises. See: https://www.chezmoi.io/why-use-chezmoi/
By idempotency, we mean: TODO
Let:
R_C1 - executing refresh resp. initPC via ./run_init.sh on a commit C1
S - clean state (state after installing a new OS before running ./run_init.sh)
๐ข - set of all possible states of an OS image
โ : R_Ci x ๐ข -> ๐ข - application of the `refresh` command to the state
We want:
R_C1 โ (R_C1 โ S) = R_C1 โ S
Yes, the refresh command should be idempotent. This is also partly verified in CI via GitHub actions (TODO make sure).
4. Does running the refresh
command after a change in this repo on a clean machine (new OS install) produce an equivalent state to running refresh
on an existing machine? Why not to use Nix instead?
In general no. Only the Nix package manager can do that well. It would be hard to replicate that elsewhere. However, the whole configuration of a new machine takes just around 20 minutes with these scripts. Therefore if the state of an existing machine and the state described in this repo diverge too much, it should be possible to reinstall the OS and reconfigure the machine from a clean state fairly quickly (TODO after the backup solution is also finished). Hence despite the fact that Nix is more capable in this regard, it is still possible to achieve a similar practical effect using this init script. As Nix is a bit less common than Debian and Ubuntu, I have chosen to use Debian package manager as a default instead of Nix. However, I plan to implement the initPC script for Nix as well and I am also considering using Nix more in the future.
TODO - when does this hold and when it does not?
Let us have 2 commits:
C1
C2
C1 -> C2
And let:
R_Ci - executing refresh resp. initPC via ./run_init.sh on a commit Ci
S - clean state (state after installing a new OS before running ./run_init.sh)
๐ข - set of all possible states of an OS image
โ : R_Ci x ๐ข -> ๐ข - application of the `refresh` command to the state
We want:
R_C2 โ (R_C1 โ S) = R_C2 โ S
Bug reports and pull requests are welcome, if a feature is interesting but not useful for me, I will keep it in a separate branch, I might change my mind later :D . Issues and feature requests can be created here: https://github.com/jan-revay/initPC/issues
- Merge and deprecate the InitNewPC repo InitPC repo on org GitHub and initAndroid repo.
- Merge with LogidCfg repo
- Test the Windows setup script on a VM
- Create aliases for PowerShelly
- Try merging the apt, flatpak, and snap install commands
- Have a look at popOS packages and add the useful ones to other init scripts
- Design a system for applying the configs on all my machines once they
are updated here.
- implement
refresh
alias - add notification to .bashrc if the initPC or dotfiles are not up to date
- implement
- Add more C++ tools from here: https://github.com/cpp-best-practices/cppbestpractices/blob/master/02-Use_the_Tools_Available.md
- Add Bats automated tests
- Try adding NixOS
- Create CI tests on GitHub
- Todos from the repo
- Make the core Linux init script Debian based (i.e. other distros just add stuff to the Debian base init script)
- Maybe replace the Debian variants (Ubuntu, PopOS...) with a single Ansible script with conditionals?
- Do some research on whether snap and flatpak packages work in WSL resp. which alternative package manager to use in WSL
- Consider running the whole
./run_all.sh
script as sudo and removingsudo
commands from the script. - Consider using http://www.bashbooster.net/, https://github.com/bevry/dorothy, https://www.chezmoi.io/ or similar libraries (see: https://www.chezmoi.io/comparison-table/ and https://dotfiles.github.io/utilities/).
- Format to max 82 chars in a line.
- Echo errors to stderr
- Make the script compliant with the Google Bash style guide.
- Consider running different files in different subshells i.e. not using the
source
command. - shared_gui_packages_install.sh
- Automatic formatting of markdown files
- Format markdown files (add linebreaks, beautify...)
- Consolidate branches (unmerged feature branches).
- Backup solution
- Consider using https://canonical-ubuntu-wsl.readthedocs-hosted.com/en/latest/tutorials/cloud-init/
- Why does the pre-commit hook (ShellCheck) fail locally but succeed in CI?
- Add functional tests (see GitHub runners or ThePrimagen scripts as an example.
- Try to replicate my current MX3 master setup (high-res scrolling turned off) with just the logid driver, if possible.
- Add Sway init and config files
- Install VSC as .deb pkg & add config according to https://code.visualstudio.com/docs/setup/linux