7 ms·
Scripting, scripting, and more scripting. I wish there were a better way, but there isn't. And it will forever be brittle, because operating systems change. Wit
by vinceguidry 4y ago
Scripting, scripting, and more scripting. I wish there were a better way, but there isn't. And it will forever be brittle, because operating systems change. With that said, here's what I do.
First, I keep a personal monorepo. It not only has all my dotfiles, but also my personal website, and binary tools I've written. A game changer for me was git submodules, which let me keep third party stuff up to date with a minimum of fuss. The only thing I keep in a separate repo is my password repository.
So the main script I use invokes a lot of other scripts in order. This is so I can just run one thing to update everything. The first thing it does is sync the monorepo and password repos. Then it runs my homebrew stow command, which is like GNU stow[1] but I have all the control I want over it because I wrote it in Ruby. This not only syncs my dotfiles but also copies all my homebrew bins over to where they're not only in $PATH, but /usr/local/bin so that they're in root's path as well.
Next is package management. I run Arch Linux and use pacdef[2] for lightweight declarative package management. If I install some random package, it will remove it at this step, unless I put it in one of my package lists that I keep in the monorepo. This tool will take any Arch Linux install with paru or yay and make it into mostly the system I use every day. It is the most brittle part of the process because, well, operating systems change.
Finally, to manage all the other package management tools out there, I use asdf.[3] My script installs all the plugins if they're not there, update them, then installs everything. Most asdf plugins support a 'default lib' config, which install a list of packages whenever you install a version of the tool. It's not the wholly declarative solution that pacdef is, but I may eventually write enough scripting to get it there.
It has to be this way because Linux is freedom, and with great freedom comes great amounts of time spent learning how it works. I used to try to keep a portable config across OSX, Windows WSL, and Linux, but that was really hard to maintain, and my life got way simpler when I decided no more OSX or Windows. It's kinda possible to do but it's a ton of work.
But the basic building blocks are, 1) dotfiles, 2) system packages, 3) secondary packages. Get those three scripted, and you're off to the races.
[1] https://www.gnu.org/software/stow/ https://www.gnu.org/software/stow/
[2] https://github.com/steven-omaha/pacdef https://github.com/steven-omaha/pacdef
[3] https://asdf-vm.com/ https://asdf-vm.com/
- guilherme-puida 4y agoNix seems like the perfect match for you.
- vinceguidry 4y agoYou would think. But Nix and Guix are still very very new. Arch Linux has the best overall package management system, nothing else even comes close. Wrapping it is a way better option than trying to reinvent it from the ground up. If Arch didn't exist, I'd lean on Debian before going Nix.
- JamesSwift 4y ago> But Nix and Guix are still very very new Uhh nix has been around since 2003 [1]. I can definitely recommend taking a look at it if you are fine with running Arch. [1] - https://en.wikipedia.org/wiki/Nix_(package_manager) https://en.wikipedia.org/wiki/Nix_(package_manager)
- rgoulter 4y agoSure, but Nix is very weird, and takes quite a different approach compared to other things. Understanding Linux is both necessary, but not sufficient. But comparing Arch an NixOS: - Arch requires more elbow grease than Ubuntu. NixOS requires more elbow grease than Ubuntu. I wouldn't recommend either to beginners. - On the other hand: NixOS is immutable and pure, whereas Arch is a system that can be beaten into shape. - Or the Arch Linux wiki is fantastic, and Nix documentation is .. all over the place. (Maybe AUR is better than Nixpkgs; but ultimately nix is a much more powerful tool than pacman strives to be).
- JamesSwift 4y agoNix is different, but I wouldn't say its _weird_. Nix the language is weird, but the packaging system is pretty straightforward. Imagine that every single thing you install is done in a chroot, so you need to declare exactly what it depends on to have it work. Thats it. My point is that if you are comfortable with the effort needed for Arch, NixOS is _probably_ a better option because I think it does the same thing but better.