This commit is contained in:
Brian Zalewski 2024-01-29 05:13:53 +00:00
parent 9644f940ae
commit 1a8fdfb963
21 changed files with 2331 additions and 58 deletions

View file

@ -155,13 +155,14 @@ if [ -d /Applications ] && [ -d /System ]; then
fi fi
### SDKMan ### SDKMan
if command -v brew > /dev/null && command -v sdkman-cli > /dev/null; then ### Deprecated in favor of mise
export SDKMAN_DIR="$(brew --prefix sdkman-cli)/libexec" # if command -v brew > /dev/null && command -v sdkman-cli > /dev/null; then
. "$SDKMAN_DIR/bin/sdkman-init.sh" # export SDKMAN_DIR="$(brew --prefix sdkman-cli)/libexec"
elif [ -f "$SDKMAN_DIR/bin/sdkman-init.sh" ]; then # . "$SDKMAN_DIR/bin/sdkman-init.sh"
export SDKMAN_DIR="$XDG_DATA_HOME/sdkman" # elif [ -f "$SDKMAN_DIR/bin/sdkman-init.sh" ]; then
. "$SDKMAN_DIR/bin/sdkman-init.sh" # export SDKMAN_DIR="$XDG_DATA_HOME/sdkman"
fi # . "$SDKMAN_DIR/bin/sdkman-init.sh"
# fi
### VIM ### VIM
export GVIMINIT='let $MYGVIMRC="$XDG_CONFIG_HOME/vim/gvimrc" | source $MYGVIMRC' export GVIMINIT='let $MYGVIMRC="$XDG_CONFIG_HOME/vim/gvimrc" | source $MYGVIMRC'

View file

@ -866,7 +866,6 @@ softwareGroups:
- proxyman - proxyman
- pushpin - pushpin
- rust - rust
- sdkman-cli
- snapcraft - snapcraft
- solidity - solidity
- swimat - swimat
@ -1591,6 +1590,8 @@ softwareGroups:
note: Deprecated because browser extensions do a better job of unifying bookmarks. Namely, the extension called Floccus allows cross-browser bookmark syncing. The Raindrop package also requires a paid subscription for advanced features. note: Deprecated because browser extensions do a better job of unifying bookmarks. Namely, the extension called Floccus allows cross-browser bookmark syncing. The Raindrop package also requires a paid subscription for advanced features.
- pkg: rvm - pkg: rvm
note: Deprecated in favor of using ASDF. note: Deprecated in favor of using ASDF.
- pkg: sdkman-cli
note: Deprecated in favor of mise
- pkg: standard-notes - pkg: standard-notes
note: Deprecated in favor of Obsidian / Notion note: Deprecated in favor of Obsidian / Notion
- pkg: stubby - pkg: stubby

View file

@ -8,6 +8,19 @@
{{ includeTemplate "universal/profile" }} {{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }} {{ includeTemplate "universal/logg" }}
cleanAptGet() {
if command -v apt-get > /dev/null; then
logg info 'Running sudo apt-get autoclean' && sudo apt-get autoclean
logg info 'Running sudo apt-get -y autoremove' && sudo apt-get -y autoremove
fi
}
cleanupBrew() {
if command -v brew > /dev/null; then
logg info 'Running brew cleanup' && brew cleanup
fi
}
### Remove meta sudo file ### Remove meta sudo file
if [ -f "$HOME/.sudo_as_admin_successful" ]; then if [ -f "$HOME/.sudo_as_admin_successful" ]; then
rm -f "$HOME/.sudo_as_admin_successful" rm -f "$HOME/.sudo_as_admin_successful"
@ -43,3 +56,9 @@ if [ -d /Applications ] && [ -d /System ]; then
logg info 'Emptying trash' && m trash clean logg info 'Emptying trash' && m trash clean
fi fi
fi fi
cleanAptGet &
cleanupBrew &
wait
logg success 'Finished cleanup process'

View file

@ -123,6 +123,10 @@ else
fi fi
done done
elif [ '{{ .host.distro.id }}' = 'debian' ]; then elif [ '{{ .host.distro.id }}' = 'debian' ]; then
if command -v apt-get > /dev/null && [ -f /etc/apt/preferences.d/nosnap.pref ]; then
logg info 'Moving /etc/apt/preferences.d/nosnap.pref to /etc/apt/nosnap.pref.bak' && sudo mv -f /etc/apt/preferences.d/nosnap.pref /etc/apt/nosnap.pref.bak
fi
### Print dependency list ### Print dependency list
logg 'Installing common dependencies using apt-get' logg 'Installing common dependencies using apt-get'
logg info 'Dependencies: {{ $packages | sortAlpha | uniq | join " " -}}' logg info 'Dependencies: {{ $packages | sortAlpha | uniq | join " " -}}'
@ -239,6 +243,10 @@ else
fi fi
done done
elif [ '{{ .host.distro.id }}' = 'ubuntu' ]; then elif [ '{{ .host.distro.id }}' = 'ubuntu' ]; then
if command -v apt-get > /dev/null && [ -f /etc/apt/preferences.d/nosnap.pref ]; then
logg info 'Moving /etc/apt/preferences.d/nosnap.pref to /etc/apt/nosnap.pref.bak' && sudo mv -f /etc/apt/preferences.d/nosnap.pref /etc/apt/nosnap.pref.bak
fi
### Print dependency list ### Print dependency list
logg 'Installing common dependencies using apt-get' logg 'Installing common dependencies using apt-get'
logg info 'Dependencies: {{ $packages | sortAlpha | uniq | join " " -}}' logg info 'Dependencies: {{ $packages | sortAlpha | uniq | join " " -}}'

View file

@ -640,18 +640,42 @@ showNotificationCenter() {
fi fi
} }
installAnsible() {
if command -v pipx > /dev/null; then
if [ ! -f "${XDG_CACHE_HOME:-$HOME/.cache}/install.doctor/ansible-installed" ]; then
logg info 'Running pipx install ansible-core' && pipx install ansible-core
if [ -d /Applications ] && [ -d /System ]; then
logg info 'Injecting ansible-core pipx with ansible-core PyObjC PyObjC-core because system is macOS' && pipx inject ansible-core PyObjC PyObjC-core
fi
logg info 'Running pipx inject ansible-core docker lxml netaddr pexpect python-vagrant pywinrm requests-credssp watchdog' && pipx inject ansible-core docker lxml netaddr pexpect python-vagrant pywinrm requests-credssp watchdog
mkdir -p "${XDG_CACHE_HOME:-$HOME/.cache}/install.doctor"
touch "${XDG_CACHE_HOME:-$HOME/.cache}/install.doctor/ansible-installed"
else
logg info 'Ansible installation routine appears to have already been run'
fi
else
logg warn 'pipx is unavailable to use for installing Ansible'
fi
}
installBrewPackages() { installBrewPackages() {
ensureNodeInstalled ensureNodeInstalled
ensureDeltaInstalled ensureDeltaInstalled
ensureBrewPackageInstalled "gh"
ensureBrewPackageInstalled "go"
ensureBrewPackageInstalled "zx"
ensureBrewPackageInstalled "volta" ensureBrewPackageInstalled "volta"
volta install node@latest & volta install node@latest &
volta install yarn@latest & volta install yarn@latest &
npm install -g npm@latest & npm install -g npm@latest &
ensureBrewPackageInstalled "pipx"
pipx ensurepath &
ensureBrewPackageInstalled "gh"
ensureBrewPackageInstalled "go"
ensureBrewPackageInstalled "ruby"
ensureBrewPackageInstalled "rustup"
ensureBrewPackageInstalled "zx"
ensureBrewPackageInstalled "whalebrew"
wait wait
logg success 'Finished installing auxilary Homebrew packages' logg success 'Finished installing auxilary Homebrew packages'
logg info 'Ensuring Ansible is installed (with plugins)' && installAnsible
} }
ensureMacportsInstalled() { ensureMacportsInstalled() {
@ -666,8 +690,83 @@ ensureMacportsInstalled() {
fi fi
} }
setupSnap() {
if [ ! -d /Applications ] && [ ! -d /System ] && command -v snap > /dev/null; then
logg info 'Enabling snapd' && sudo systemctl enable snapd
logg info 'Starting snapd' && sudo systemctl start snapd
if [ -d /snap ]; then
logg info 'Linking /var/lib/snapd/snap to /snap' && sudo ln -s /var/lib/snapd/snap /snap
fi
logg info 'Running sudo snap info core' && sudo snap info core
logg info 'Running sudo snap wait system seed.loaded' && sudo snap wait system seed.loaded
logg info 'Running sudo snap install core' && sudo snap install core
fi
}
installYay() {
if [ -f /etc/arch-release ] && ! command -v yay > /dev/null
sudo rm -rf /usr/local/src/yay
sudo git clone https://aur.archlinux.org/yay.git /usr/local/src/yay
cd /usr/local/src/yay
sudo makepkg -si
fi
}
installNix() {
if ! command -v nix-shell > /dev/null; then
if [ -d /Applications ] && [ -d /System ]; then
### macOS
logg info 'Installing nix for macOS' && sh <(curl -L https://nixos.org/nix/install) --yes
else
### Linux
logg info 'Installing nix' && sh <(curl -L https://nixos.org/nix/install) --daemon --yes
fi
fi
}
rustUpInit() {
if command -v rustup-init > /dev/null && ! command -v rustc > /dev/null; then
logg info 'Running rustup-init -y' && rustup-init -y
fi
}
zapInstall() {
if ! command -v zap > /dev/null; then
### Architecture
if [ -z ${ARCH+x} ]; then
MACHINE_ARCH="$(uname -m)"
if [ "$MACHINE_ARCH" = "amd64" ]; then
ARCH="amd64"
elif [ "$MACHINE_ARCH" = "x86_64" ]; then
ARCH="amd64"
elif [ "$MACHINE_ARCH" = "i386" ]; then
ARCH="386"
elif [ "$MACHINE_ARCH" = "i686" ]; then
ARCH="386" # both are 32bit, should be compatible
elif [ "$MACHINE_ARCH" = "aarch64" ]; then
ARCH="arm64"
elif [ "$MACHINE_ARCH" = "arm64" ]; then
ARCH="arm64"
elif [ "$MACHINE_ARCH" = "arm" ]; then
ARCH="arm"
fi
export ARCH
fi
logg info 'Downloading zap to /usr/local/bin/zap' && sudo curl -sSL --output /usr/local/bin/zap "https://github.com/srevinsaju/zap/releases/download/continuous/zap-${ARCH}"
logg info 'Making /usr/local/bin/zap executable' && sudo chmod +x /usr/local/bin/zap
fi
}
addFlathub() {
if command -v flatpak > /dev/null; then
logg info 'Adding flatpak flathub repository' && sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
fi
}
# TODO - Add install on macOS for macports
if [ -n "$DEBUG" ] || [ -n "$DEBUG_MODE" ]; then if [ -n "$DEBUG" ] || [ -n "$DEBUG_MODE" ]; then
logg info 'The DEBUG or DEBUG_MODE environment variable is set so preliminary system tweaks will be run synchronously' logg info 'The DEBUG or DEBUG_MODE environment variable is set so preliminary system tweaks will be run synchronously'
addFlathub
allocateSwap allocateSwap
configureGPG configureGPG
disableDStoreFileCreation disableDStoreFileCreation
@ -679,12 +778,17 @@ if [ -n "$DEBUG" ] || [ -n "$DEBUG_MODE" ]; then
installDocker installDocker
installJumpCloud installJumpCloud
installSystemPips installSystemPips
installYay
removeLinuxBloatware removeLinuxBloatware
rustUpInit
setHostname setHostname
setNtpServer setNtpServer
setTimezone setTimezone
setupSnap
showNotificationCenter showNotificationCenter
zapInstall
else else
addFlathub &
allocateSwap & allocateSwap &
configureGPG & configureGPG &
disableDStoreFileCreation & disableDStoreFileCreation &
@ -696,11 +800,15 @@ else
installDocker & installDocker &
installJumpCloud & installJumpCloud &
installSystemPips & installSystemPips &
installYay &
removeLinuxBloatware & removeLinuxBloatware &
rustUpInit &
setHostname & setHostname &
setNtpServer & setNtpServer &
setTimezone & setTimezone &
setupSnap &
showNotificationCenter & showNotificationCenter &
zapInstall &
wait wait
fi fi

View file

@ -2,6 +2,7 @@
"age/bullseye-backports" "age/bullseye-backports"
"build-essential" "build-essential"
"gnome" "gnome"
"gnome-software-plugin-flatpak"
"gnupg-agent" "gnupg-agent"
"golang-go" "golang-go"
"hopenpgp-tools" "hopenpgp-tools"
@ -27,6 +28,7 @@
"npm" "npm"
"pcscd" "pcscd"
"pkg-config" "pkg-config"
"plasmashell"
"progress" "progress"
"ruby-dev" "ruby-dev"
"scdaemon" "scdaemon"

View file

@ -3,6 +3,7 @@
"build-essential" "build-essential"
"golang-go" "golang-go"
"gnome" "gnome"
"gnome-software-plugin-flatpak"
"gnupg-agent" "gnupg-agent"
"hopenpgp-tools" "hopenpgp-tools"
"libaio1" "libaio1"
@ -27,6 +28,7 @@
"npm" "npm"
"pcscd" "pcscd"
"pkg-config" "pkg-config"
"plasmashell"
"progress" "progress"
"ruby-dev" "ruby-dev"
"scdaemon" "scdaemon"

View file

@ -1,10 +1,12 @@
{{- $packages := list {{- $packages := list
"bash" "bash"
"bison" "bison"
"cargo"
"coreutils" "coreutils"
"cryptsetup" "cryptsetup"
"curl" "curl"
"expect" "expect"
"flatpak"
"git" "git"
"grep" "grep"
"gnupg2" "gnupg2"

View file

@ -170,13 +170,14 @@ if [ "$BASH_SUPPORT" = 'true' ] && [ -n "$BASH" ]; then
! command -v rtx > /dev/null || eval "$(rtx activate bash)" ! command -v rtx > /dev/null || eval "$(rtx activate bash)"
### SDKMan ### SDKMan
if command -v brew > /dev/null && command -v sdkman-cli > /dev/null; then ### Using mise instead for Java handling
export SDKMAN_DIR="$(brew --prefix sdkman-cli)/libexec" # if command -v brew > /dev/null && command -v sdkman-cli > /dev/null; then
source "$SDKMAN_DIR/bin/sdkman-init.sh" # export SDKMAN_DIR="$(brew --prefix sdkman-cli)/libexec"
elif [ -f "$SDKMAN_DIR/bin/sdkman-init.sh" ]; then # source "$SDKMAN_DIR/bin/sdkman-init.sh"
export SDKMAN_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/sdkman" # elif [ -f "$SDKMAN_DIR/bin/sdkman-init.sh" ]; then
source "$SDKMAN_DIR/bin/sdkman-init.sh" # export SDKMAN_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/sdkman"
fi # source "$SDKMAN_DIR/bin/sdkman-init.sh"
# fi
### Sheldon ### Sheldon
export SHELDON_CONFIG_FILE="${SHELDON_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/sheldon}/plugins.bash.toml" export SHELDON_CONFIG_FILE="${SHELDON_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/sheldon}/plugins.bash.toml"

View file

@ -356,7 +356,8 @@ export NETRC="${XDG_CONFIG_HOME:-$HOME/.config}/netrc"
export NAVI_CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}/navi/config.yaml" export NAVI_CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}/navi/config.yaml"
### Nix ### Nix
export NIX_SSL_CERT_FILE="$HOME/.local/etc/ssl/cloudflare/Cloudflare_CA.crt" # TODO: Fix this
# export NIX_SSL_CERT_FILE="$HOME/.local/etc/ssl/cloudflare/Cloudflare_CA.crt"
### nnn ### nnn
if command -v nnn > /dev/null; then if command -v nnn > /dev/null; then

View file

@ -588,13 +588,6 @@ async function afterInstall(packageManager) {
const logStage = 'Post-Install Package Manager' const logStage = 'Post-Install Package Manager'
if (packageManager === 'appimage') { if (packageManager === 'appimage') {
} else if (packageManager === 'ansible') { } else if (packageManager === 'ansible') {
log('info', logStage, `Ensuring temporary passwordless sudo privileges used by Ansible are removed`)
const gsed = which.sync('gsed', { nothrow: true })
if (gsed) {
await $`sudo gsed -i '/# TEMPORARY FOR INSTALL DOCTOR ANSIBLE/d' /etc/sudoers`
} else {
await $`sudo sed -i '/# TEMPORARY FOR INSTALL DOCTOR ANSIBLE/d' /etc/sudoers`
}
} else if (packageManager === 'apk') { } else if (packageManager === 'apk') {
} else if (packageManager === 'apt') { } else if (packageManager === 'apt') {
try { try {

File diff suppressed because it is too large Load diff

View file

@ -146,17 +146,44 @@ async function createCaskLinks() {
for (const app of caskApps) { for (const app of caskApps) {
const appField = getPkgData('_app', app, app.installType) const appField = getPkgData('_app', app, app.installType)
const binField = getPkgData('_bin', app, app.installType) const binField = getPkgData('_bin', app, app.installType)
if (fs.existsSync(`${os.homedir()}/Applications/${x[appField]}`)) { if (fs.existsSync(`${os.homedir()}/Applications/${app[appField]}`)) {
fs.writeFileSync(`${os.homedir()}/.local/bin/cask/${x[binField]}`, `open "$HOME/Applications/${x[appField]}" $*`) fs.writeFileSync(`${os.homedir()}/.local/bin/cask/${app[binField]}`, `#!/usr/bin/env bash\nopen "$HOME/Applications/${app[appField]}" $*`)
} else if (fs.existsSync(`/Applications/${x[appField]}`)) { await $`chmod +x '${os.homedir()}/.local/bin/cask/${app[binField]}'`
fs.writeFileSync(`${os.homedir()}/.local/bin/cask/${x[binField]}`, `open "/Applications/${x[appField]}" $*`) } else if (fs.existsSync(`/Applications/${app[appField]}`)) {
fs.writeFileSync(`${os.homedir()}/.local/bin/cask/${app[binField]}`, `#!/usr/bin/env bash\nopen "/Applications/${app[appField]}" $*`)
await $`chmod +x '${os.homedir()}/.local/bin/cask/${app[binField]}'`
} else { } else {
log(`Unable to create bin link to ${x[appField]}`) log(`Unable to create bin link to ${app[appField]}`)
} }
} }
caskApps.length && log(`Finished creating Homebrew cask links in ~/.local/bin/cask`) caskApps.length && log(`Finished creating Homebrew cask links in ~/.local/bin/cask`)
} }
async function createFlatpakLinks() {
const flatpakInstallations = await $`flatpak --installations`
const flatpakDir = flatpakInstallations.stdout.replace('\n', '')
const flatpakApps = pkgMap(pkgs)
.filter(x => {
if (x.installType === 'flatpak') {
const binField = getPkgData('_bin', x, x.installType)
const binFile = fs.existsSync(`${os.homedir()}/.local/bin/flatpak/${x[binField]}`)
return !binFile
}
return false
})
flatpakApps.length && await $`mkdir -p "$HOME/.local/bin/flatpak"`
for (const app of flatpakApps) {
const binField = getPkgData('_bin', app, app.installType)
if (fs.existsSync(`${flatpakDir}/app/${app.installList[0]}`)) {
fs.writeFileSync(`${os.homedir()}/.local/bin/flatpak/${app[binField]}`, `#!/usr/bin/env bash\nflatpak run ${app.installList[0]} $*`)
await $`chmod +x '${os.homedir()}/.local/bin/flatpak/${app[binField]}'`
} else {
log(`Unable to create bin link to ${x.flatpak}`)
}
}
flatpakApps.length && log(`Finished creating Flatpak links in ~/.local/bin/flatpak`)
}
async function bundleInstall(brews, casks) { async function bundleInstall(brews, casks) {
try { try {
const lines = [] const lines = []
@ -207,8 +234,10 @@ async function installPackages(pkgInstructions) {
switch (key) { switch (key) {
case 'ansible': case 'ansible':
promises.push(forEachSeries(combined[key].flatMap(x => x.installList.flatMap(i => $`${key} 127.0.0.1 -v${process.env.DEBUG && 'vv'} -e '{ ansible_connection: "local", ansible_become_user: "root", ansible_user: "${process.env.USER}", ansible_family: "${osId.charAt(0).toUpperCase() + osId.slice(1)}", install_homebrew: False }' -m include_role -a name=${i}`)))) promises.push(forEachSeries(combined[key].flatMap(x => x.installList.flatMap(i => $`${key} 127.0.0.1 -v${process.env.DEBUG && 'vv'} -e '{ ansible_connection: "local", ansible_become_user: "root", ansible_user: "${process.env.USER}", ansible_family: "${osId.charAt(0).toUpperCase() + osId.slice(1)}", install_homebrew: False }' -m include_role -a name=${i}`))))
break
case 'apk': case 'apk':
promises.push($`sudo ${key} add ${combined[key].flatMap(x => x.installList).split(' ')}`) promises.push($`sudo ${key} add ${combined[key].flatMap(x => x.installList).split(' ')}`)
break
case 'appimage': case 'appimage':
promises.push(...combined[key].flatMap(x => x.installList.flatMap(i => { promises.push(...combined[key].flatMap(x => x.installList.flatMap(i => {
if (x.substring(0, 4) === 'http') { if (x.substring(0, 4) === 'http') {
@ -219,8 +248,10 @@ async function installPackages(pkgInstructions) {
return $`zap install --select-first -q ${i}` return $`zap install --select-first -q ${i}`
} }
}))) })))
break
case 'apt': case 'apt':
promises.push($`DEBIAN_FRONTEND=noninteractive sudo apt-get -o DPkg::Options::=--force-confdef install -y ${combined[key].flatMap(x => x.installList).split(' ')}`) promises.push($`DEBIAN_FRONTEND=noninteractive sudo apt-get -o DPkg::Options::=--force-confdef install -y ${combined[key].flatMap(x => x.installList).split(' ')}`)
break
case 'basher': case 'basher':
case 'baulk': case 'baulk':
case 'cargo': case 'cargo':
@ -237,11 +268,13 @@ async function installPackages(pkgInstructions) {
case 'binary': case 'binary':
// TODO // TODO
promises.push(...combined[key].flatMap(x => x.installList.flatMap(i => $`TMP="$(mktemp)" && curl -sSL ${i} > "$TMP" && sudo mv "$TMP" /usr/local/src/${x._bin} && chmod +x /usr/local/src/${x._bin}`))) promises.push(...combined[key].flatMap(x => x.installList.flatMap(i => $`TMP="$(mktemp)" && curl -sSL ${i} > "$TMP" && sudo mv "$TMP" /usr/local/src/${x._bin} && chmod +x /usr/local/src/${x._bin}`)))
break
case 'brew': case 'brew':
case 'cask': // Handled above case 'cask': // Handled above
break break
case 'choco': case 'choco':
promises.push($`${key} install -y ${combined[key].flatMap(x => x.installList).join(' ')}`) promises.push($`${key} install -y ${combined[key].flatMap(x => x.installList).join(' ')}`)
break
case 'dnf': case 'dnf':
case 'yum': case 'yum':
case 'zypper': case 'zypper':
@ -293,17 +326,30 @@ async function installPackages(pkgInstructions) {
const installs = await Promise.allSettled(promises) const installs = await Promise.allSettled(promises)
log(`All of the installations have finished`) log(`All of the installations have finished`)
console.log('Installs:', installs) console.log('Installs:', installs)
await postInstall(combined)
}
async function postInstall(combined) {
log(`Running post-install routine`)
const promises = []
Object.keys(combined).includes('flatpak') && promises.push(createFlatpakLinks())
const postInstalls = await Promise.allSettled(promises)
console.log('Post installs:', postInstalls)
} }
async function acquireManagerList(type, command) { async function acquireManagerList(type, command) {
if (fs.existsSync(`${cacheDir}/${type}`)) { if (which.sync(type, { nothrow: true })) {
setTimeout(() => { if (fs.existsSync(`${cacheDir}/${type}`)) {
setTimeout(() => {
require('child_process').execSync(`${command} > ${cacheDir}/${type}`)
}, 0)
} else {
require('child_process').execSync(`${command} > ${cacheDir}/${type}`) require('child_process').execSync(`${command} > ${cacheDir}/${type}`)
}, 0) }
return fs.readFileSync(`${cacheDir}/${type}`).toString().split('\n')
} else { } else {
require('child_process').execSync(`${command} > ${cacheDir}/${type}`) return []
} }
return fs.readFileSync(`${cacheDir}/${type}`).toString().split('\n')
} }
function pkgMap(pkgDefs) { function pkgMap(pkgDefs) {
@ -349,21 +395,34 @@ async function main() {
installOrder = initData[1].installerPreference installOrder = initData[1].installerPreference
log(`Populating lists of pre-installed packages`) log(`Populating lists of pre-installed packages`)
const lists = [ const lists = [
acquireManagerList('apt', `dpkg -l`),
acquireManagerList('brew', `brew list -1`), acquireManagerList('brew', `brew list -1`),
acquireManagerList('cargo', `cargo install --list | awk '/^[[:alnum:]]/ {print $1}'`), acquireManagerList('cargo', `cargo install --list | awk '/^[[:alnum:]]/ {print $1}'`),
acquireManagerList('dnf', `rpm -qa`),
acquireManagerList('flatpak', `flatpak --columns=app list`),
acquireManagerList('gem', `gem list | awk '{print $1}'`), acquireManagerList('gem', `gem list | awk '{print $1}'`),
acquireManagerList('npm', `volta list --format plain | awk '{print $2}' | sed 's/@.*//'`), acquireManagerList('npm', `volta list --format plain | awk '{print $2}' | sed 's/@.*//'`),
acquireManagerList('pacman', `pacman -Qs`),
acquireManagerList('pip3', `pip3 list | awk '{print $1}'`), acquireManagerList('pip3', `pip3 list | awk '{print $1}'`),
acquireManagerList('pipx', `pipx list --short | awk '{print $1}'`) acquireManagerList('pipx', `pipx list --short | awk '{print $1}'`),
acquireManagerList('snap', `snap list`),
acquireManagerList('zap', `zap list`)
] ]
const managerLists = { const managerLists = {
brew: lists[0], appimage: lists[6],
cargo: lists[1], apt: lists[0],
cask: lists[0], brew: lists[1],
gem: lists[2], cargo: lists[2],
npm: lists[3], cask: lists[1],
pip3: lists[4], dnf: lists[3],
pipx: lists[5] flatpak: lists[4],
gem: lists[5],
npm: lists[6],
pacman: lists[7],
pip3: lists[8],
pipx: lists[9],
snap: lists[10],
zap: lists[11]
} }
log(`Acquiring installation keys`) log(`Acquiring installation keys`)
const installKeys = Object.keys(pkgs) const installKeys = Object.keys(pkgs)

View file

@ -0,0 +1,101 @@
#!/usr/bin/env bash
updateApk() {
if command -v apk > /dev/null; then
logg info 'Running sudo apk update' && sudo apk update || logg error 'Failed to run sudo apk update'
fi
}
updateAptGet() {
if command -v apt-get > /dev/null; then
logg info 'Running sudo apt-get update' && sudo apt-get update || logg error 'Failed to run sudo apt-get update'
logg info 'Running sudo apt-get upgrade -y' && sudo apt-get upgrade -y || logg error 'Failed to run sudo apt-get upgrade -y'
fi
}
updateBrew() {
logg info 'Running brew update' && brew update || logg error 'Failed to run brew update'
logg info 'Running brew upgrade' && brew upgrade || logg error 'Failed to run brew upgrade'
if [ -d /Applications ] && [ -d /System ]; then
### macOS
logg info 'Running brew upgrade --cask' && brew upgrade --cask || logg error 'Failed to run brew upgrade --cask'
fi
}
updateCrew() {
if command -v crew > /dev/null; then
logg info 'Running crew update' && crew update || logg error 'Failed to run crew update'
fi
}
updateDnf() {
if command -v dnf > /dev/null; then
logg info 'Running sudo dnf update -y' && sudo dnf update -y || logg error 'Failed to run sudo dnf update -y'
fi
}
updateFlatpak() {
if command -v flatpak > /dev/null; then
logg info 'Running sudo flatpak update -y' && sudo flatpak update -y || logg error 'Failed to run sudo flatpak update -y'
fi
}
updateNix() {
if command -v nix-channel > /dev/null; then
logg info 'Running nix-channel --update' && nix-channel --update || logg error 'Failed to run nix-channel --update'
fi
}
updatePacman() {
if command -v pacman > /dev/null; then
logg info 'Running sudo pacman -Syu' && sudo pacman -Syu || logg error 'Failed to run sudo pacman -Syu'
fi
}
updatePort() {
if command -v port > /dev/null; then
logg info 'Running sudo port sync' && sudo port sync || logg error 'Failed to run sudo port sync'
fi
}
updateSnap() {
if command -v snap > /dev/null; then
logg info 'Running sudo snap refresh' && sudo snap refresh || logg error 'Failed to run sudo snap refresh'
fi
}
updateZypper() {
if command -v zypper > /dev/null; then
logg info 'Running sudo zypper update' && sudo zypper update || logg error 'Failed to run sudo zypper update'
fi
}
if [ -n "$DEBUG" ] || [ -n "$DEBUG_MODE" ]; then
logg info 'The DEBUG or DEBUG_MODE environment variable is set so updates will be run synchronously'
updateApk
updateAptGet
updateBrew
updateCrew
updateDnf
updateFlatpak
updateNix
updatePacman
updatePort
updateSnap
updateZypper
else
updateApk &
updateAptGet &
updateBrew &
updateCrew &
updateDnf &
updateFlatpak &
updateNix &
updatePacman &
updatePort &
updateSnap &
updateZypper &
wait
fi
logg success 'Finished running update-system'

View file

@ -470,13 +470,14 @@ fi
! command -v rtx > /dev/null || eval "$(rtx activate zsh)" ! command -v rtx > /dev/null || eval "$(rtx activate zsh)"
### SDKMan ### SDKMan
if command -v brew > /dev/null && command -v sdkman-cli > /dev/null; then ### Using mise instead for Java handling
export SDKMAN_DIR="$(brew --prefix sdkman-cli)/libexec" # if command -v brew > /dev/null && command -v sdkman-cli > /dev/null; then
. "$SDKMAN_DIR/bin/sdkman-init.sh" # export SDKMAN_DIR="$(brew --prefix sdkman-cli)/libexec"
elif [ -f "$SDKMAN_DIR/bin/sdkman-init.sh" ]; then # . "$SDKMAN_DIR/bin/sdkman-init.sh"
export SDKMAN_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/sdkman" # elif [ -f "$SDKMAN_DIR/bin/sdkman-init.sh" ]; then
. "$SDKMAN_DIR/bin/sdkman-init.sh" # export SDKMAN_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/sdkman"
fi # . "$SDKMAN_DIR/bin/sdkman-init.sh"
# fi
### Sheldon ### Sheldon
export SHELDON_CONFIG_FILE="${SHELDON_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/sheldon}/plugins.zsh.toml" export SHELDON_CONFIG_FILE="${SHELDON_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/sheldon}/plugins.zsh.toml"

View file

@ -433,8 +433,8 @@ provisionLogic() {
logg info "Handling Qubes dom0 logic (if applicable)" && handleQubesDom0 logg info "Handling Qubes dom0 logic (if applicable)" && handleQubesDom0
logg info "Handling pre-provision logic" && initChezmoiAndPrompt logg info "Handling pre-provision logic" && initChezmoiAndPrompt
logg info "Running the Chezmoi provisioning" && runChezmoi logg info "Running the Chezmoi provisioning" && runChezmoi
logg info "Ensuring temporary passwordless sudo is removed" && removePasswordlessSudo
logg info "Determing whether or not reboot" && handleRequiredReboot logg info "Determing whether or not reboot" && handleRequiredReboot
logg info "Ensuring temporary passwordless sudo is removed" && removePasswordlessSudo
logg info "Handling post-provision logic" && postProvision logg info "Handling post-provision logic" && postProvision
} }
provisionLogic provisionLogic

View file

@ -1174,11 +1174,6 @@ softwarePackages:
_github: https://github.com/cupcakearmy/autorestic/ _github: https://github.com/cupcakearmy/autorestic/
_home: https://autorestic.vercel.app/ _home: https://autorestic.vercel.app/
_name: Autorestic _name: Autorestic
_post: |
#!/usr/bin/env bash
sudo mkdir -p /var/local/backups/apps
sudo mkdir -p /var/local/backups/home
sudo mkdir -p /var/local/backups/docker
ansible: professormanhattan.autorestic ansible: professormanhattan.autorestic
brew: autorestic brew: autorestic
awscli: awscli:

4
system/etc/bash.bashrc Normal file
View file

@ -0,0 +1,4 @@
### Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi

15
system/etc/bashrc Normal file
View file

@ -0,0 +1,15 @@
# System-wide .bashrc file for interactive bash(1) shells.
if [ -z "$PS1" ]; then
return
fi
PS1='\h:\W \u\$ '
# Make bash check its window size after a process completes
shopt -s checkwinsize
[ -r "/etc/bashrc_$TERM_PROGRAM" ] && . "/etc/bashrc_$TERM_PROGRAM"
### Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi

78
system/etc/zshrc Normal file
View file

@ -0,0 +1,78 @@
# System-wide profile for interactive zsh(1) shells.
# Setup user specific overrides for this in ~/.zshrc. See zshbuiltins(1)
# and zshoptions(1) for more details.
# Correctly display UTF-8 with combining characters.
if [[ "$(locale LC_CTYPE)" == "UTF-8" ]]; then
setopt COMBINING_CHARS
fi
# Disable the log builtin, so we don't conflict with /usr/bin/log
disable log
# Save command history
HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history
HISTSIZE=2000
SAVEHIST=1000
# Beep on error
setopt BEEP
# Use keycodes (generated via zkbd) if present, otherwise fallback on
# values from terminfo
if [[ -r ${ZDOTDIR:-$HOME}/.zkbd/${TERM}-${VENDOR} ]] ; then
source ${ZDOTDIR:-$HOME}/.zkbd/${TERM}-${VENDOR}
else
typeset -g -A key
[[ -n "$terminfo[kf1]" ]] && key[F1]=$terminfo[kf1]
[[ -n "$terminfo[kf2]" ]] && key[F2]=$terminfo[kf2]
[[ -n "$terminfo[kf3]" ]] && key[F3]=$terminfo[kf3]
[[ -n "$terminfo[kf4]" ]] && key[F4]=$terminfo[kf4]
[[ -n "$terminfo[kf5]" ]] && key[F5]=$terminfo[kf5]
[[ -n "$terminfo[kf6]" ]] && key[F6]=$terminfo[kf6]
[[ -n "$terminfo[kf7]" ]] && key[F7]=$terminfo[kf7]
[[ -n "$terminfo[kf8]" ]] && key[F8]=$terminfo[kf8]
[[ -n "$terminfo[kf9]" ]] && key[F9]=$terminfo[kf9]
[[ -n "$terminfo[kf10]" ]] && key[F10]=$terminfo[kf10]
[[ -n "$terminfo[kf11]" ]] && key[F11]=$terminfo[kf11]
[[ -n "$terminfo[kf12]" ]] && key[F12]=$terminfo[kf12]
[[ -n "$terminfo[kf13]" ]] && key[F13]=$terminfo[kf13]
[[ -n "$terminfo[kf14]" ]] && key[F14]=$terminfo[kf14]
[[ -n "$terminfo[kf15]" ]] && key[F15]=$terminfo[kf15]
[[ -n "$terminfo[kf16]" ]] && key[F16]=$terminfo[kf16]
[[ -n "$terminfo[kf17]" ]] && key[F17]=$terminfo[kf17]
[[ -n "$terminfo[kf18]" ]] && key[F18]=$terminfo[kf18]
[[ -n "$terminfo[kf19]" ]] && key[F19]=$terminfo[kf19]
[[ -n "$terminfo[kf20]" ]] && key[F20]=$terminfo[kf20]
[[ -n "$terminfo[kbs]" ]] && key[Backspace]=$terminfo[kbs]
[[ -n "$terminfo[kich1]" ]] && key[Insert]=$terminfo[kich1]
[[ -n "$terminfo[kdch1]" ]] && key[Delete]=$terminfo[kdch1]
[[ -n "$terminfo[khome]" ]] && key[Home]=$terminfo[khome]
[[ -n "$terminfo[kend]" ]] && key[End]=$terminfo[kend]
[[ -n "$terminfo[kpp]" ]] && key[PageUp]=$terminfo[kpp]
[[ -n "$terminfo[knp]" ]] && key[PageDown]=$terminfo[knp]
[[ -n "$terminfo[kcuu1]" ]] && key[Up]=$terminfo[kcuu1]
[[ -n "$terminfo[kcub1]" ]] && key[Left]=$terminfo[kcub1]
[[ -n "$terminfo[kcud1]" ]] && key[Down]=$terminfo[kcud1]
[[ -n "$terminfo[kcuf1]" ]] && key[Right]=$terminfo[kcuf1]
fi
# Default key bindings
[[ -n ${key[Delete]} ]] && bindkey "${key[Delete]}" delete-char
[[ -n ${key[Home]} ]] && bindkey "${key[Home]}" beginning-of-line
[[ -n ${key[End]} ]] && bindkey "${key[End]}" end-of-line
[[ -n ${key[Up]} ]] && bindkey "${key[Up]}" up-line-or-search
[[ -n ${key[Down]} ]] && bindkey "${key[Down]}" down-line-or-search
# Default prompt
PS1="%n@%m %1~ %# "
# Useful support for interacting with Terminal.app or other terminal programs
[ -r "/etc/zshrc_$TERM_PROGRAM" ] && . "/etc/zshrc_$TERM_PROGRAM"
### Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi