This commit is contained in:
Brian Zalewski 2024-01-14 05:48:00 +00:00
parent 57e56aed1a
commit 30d92802ad
3 changed files with 105 additions and 0 deletions

View file

@ -195,6 +195,7 @@ export PATH="$PATH:$DETA_INSTALL/bin"
### Docker ### Docker
export DOCKER_CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}/docker" export DOCKER_CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}/docker"
export DOCKER_HOST="unix:///var/run/docker.sock"
export MACHINE_STORAGE_PATH="${XDG_DATA_HOME:-$HOME/.local/share}/docker-machine" export MACHINE_STORAGE_PATH="${XDG_DATA_HOME:-$HOME/.local/share}/docker-machine"
export PATH="$DOCKER_CONFIG/cli-plugins:$PATH" export PATH="$DOCKER_CONFIG/cli-plugins:$PATH"

View file

@ -0,0 +1,94 @@
#!/usr/bin/env zx
import osInfo from 'linux-os-info'
let archType, osId, osType
async function getOsInfo() {
return osInfo({ mode: 'sync' })
}
function getPkgData(pref, pkg) {
if (pkg[`${pref}:${this.osType()}:${this.osArch()}`]) {
// Handles case like `pipx:windows:x64:`
return `${pref}:${this.osType()}:${this.osArch()}`
} else if (pkg[`${pref}:${this.osId()}:${this.osArch()}`]) {
// Handles case like `pipx:debian:x64:`
return `${pref}:${this.osId()}:${this.osArch()}`
} else if (pkg[`${pref}:${this.osType()}`]) {
// Handles case like `pipx:darwin:`
return `${pref}:${this.osType()}`
} else if (pkg[`${pref}:${this.osId()}`]) {
// Handles case like `pipx:fedora:`
return `${pref}:${this.osType()}`
} else if (pkg[`${pref}`]) {
// Handles case like `pipx:`
return `${pref}`
}
}
async function getSoftwareDefinitions() {
try {
return YAML.parse(fs.readFileSync(`${os.homedir()}/.local/share/chezmoi/software.yml`, 'utf8'))
} catch (e) {
throw Error('Failed to load software definitions', e)
}
}
async function getSystemType() {
if (process.platform === "win32") {
return "windows"
} else if (process.platform === "linux") {
if (which.sync('apk')) {
return "apk"
} else if (which.sync('apt-get')) {
return "apt"
} else if (which.sync('dnf')) {
return "dnf"
} else if (which.sync('pacman')) {
return "pacman"
} else if (which.sync('zypper')) {
return "zypper"
} else {
return "linux"
}
} else {
return process.platform
}
}
async function main() {
const initData = await Promise.all([getOsInfo(), getSoftwareDefinitions(), getSystemType()])
archType = initData[0].arch
osId = process.platform === 'win32' ? 'win32' : (process.platform === 'linux' ? initData[0].id : process.platform)
osType = process.platform === 'win32' ? 'windows' : process.platform
const installOrder = initData[1].installOrderPreferences
const softwarePackages = initData[1].softwarePackages
const sysType = initData[2]
const installKeys = argv._
const installInstructions = softwarePackages
.filter(i => installKeys.includes(i))
.filter(async i => {
const binField = getPkgData('_bin', i)
const whenField = getPkgData('_when', i)
const binCheck = i[binField] && await which(i[binField], { nothrow: true })
const whenCheck = i[whenField] && await $`${i[whenField]}`.exitCode == 0
return (i[binField] && !binCheck) || (i[whenField] && whenCheck)
})
.map(i => {
for (const pref of installOrder) {
const pkgData = getPkgData(pref, i)
if (pkgData) {
return {
...x,
installKey
}
}
}
return false
})
.filter(i => !!i)
console.log(installInstructions)
}
main()

View file

@ -94,6 +94,7 @@ installerPreference:
- cargo - cargo
- npm - npm
- pipx - pipx
- pip
- gem - gem
- appimage - appimage
- script - script
@ -110,6 +111,7 @@ installerPreference:
- cargo - cargo
- npm - npm
- pipx - pipx
- pip
- gem - gem
- pkg-darwin - pkg-darwin
- script - script
@ -126,6 +128,7 @@ installerPreference:
- cargo - cargo
- npm - npm
- pipx - pipx
- pip
- gem - gem
- appimage - appimage
- script - script
@ -151,6 +154,7 @@ installerPreference:
- cargo - cargo
- npm - npm
- pipx - pipx
- pip
- gem - gem
- appimage - appimage
- script - script
@ -167,6 +171,7 @@ installerPreference:
- cargo - cargo
- npm - npm
- pipx - pipx
- pip
- gem - gem
- appimage - appimage
- script - script
@ -3252,6 +3257,11 @@ softwarePackages:
fi fi
logg info 'Headlessly authenticating with DockerHub registry' && echo "$DOCKERHUB_TOKEN" | docker login -u "$DOCKERHUB_USER" --password-stdin > /dev/null && logg success 'Successfully authenticated with DockerHub registry' logg info 'Headlessly authenticating with DockerHub registry' && echo "$DOCKERHUB_TOKEN" | docker login -u "$DOCKERHUB_USER" --password-stdin > /dev/null && logg success 'Successfully authenticated with DockerHub registry'
fi fi
### Symlink on macOS
if [ -f "$HOME/Library/Containers/com.docker.docker/Data/docker.raw.sock" ]; then
logg info 'Symlinking /var/run/docker.sock to macOS Library location' && sudo ln -s "$HOME/Library/Containers/com.docker.docker/Data/docker.raw.sock" /var/run/docker.sock
fi
apt: https://desktop.docker.com/linux/main/amd64/docker-desktop-4.16.2-amd64.deb apt: https://desktop.docker.com/linux/main/amd64/docker-desktop-4.16.2-amd64.deb
cask: docker cask: docker
choco: docker-desktop choco: docker-desktop