fix coder setup maybe

This commit is contained in:
John Doty 2023-11-10 15:52:57 +00:00
parent 880a642672
commit 93fec1c8a4
2 changed files with 63 additions and 20 deletions

61
coder-setup.py Normal file
View file

@ -0,0 +1,61 @@
import os
import pathlib
import subprocess
import urllib.request
def run(*args):
subprocess.run(args, check=True)
def install_packages():
packages = [
"atop",
"fish",
"htop",
"java-common",
"unixodbc-dev",
"wget",
]
run("sudo", "apt", "update")
run("sudo", "apt", "install", "-y", *packages)
def change_shell():
run("sudo", "chsh", "-s", "/usr/bin/fish", os.environ["USER"])
run("/usr/bin/fish", "./setup.fish")
def configure_git():
run("git", "config", "--global", "include.path", ".gitconfig.shared")
def backup_pip():
pip = pathlib.Path.home() / ".config" / "pip"
if pip.exists():
pip.rename("pip.bak")
def restore_pip():
pip = pathlib.Path.home() / ".config" / "pip.bak"
if pip.exists():
pip.rename("pip")
def configure_python():
backup_pip()
try:
run("pip3", "install", "black")
run("sudo", "npm", "install", "-g", "prettier", "pyright")
installer = urllib.request.urlopen("https://install.python-poetry.org").read()
subprocess.run(["python3", "-"], input=installer, check=True)
finally:
restore_pip()
install_packages()
change_shell()
configure_git()
configure_python()

View file

@ -10,23 +10,5 @@ cd $MY_PATH
# Run the basic setup.
python3 "./setup.py"
# # OK this stuff here is better in bash, and also is specific to setting up
# # coder.com instances, so. Add packages that I want in my coder image.
sudo apt update
sudo apt install -y wget fish java-common atop htop
# Change my shell to fish.
sudo chsh -s /usr/bin/fish $USER
# Install fish related stuff
/usr/bin/fish "./setup.fish"
# Make sure that the gitconfig that's on my computer links to my shared
# config.
git config --global include.path .gitconfig.shared
# Install blacken and prettier and some versions of python.
pip3 install --index-url=https://pypi.org/simple black
sudo npm install -g prettier pyright
curl -sSL https://install.python-poetry.org | python3 -
# Run the coder setup.
python3 "./coder-setup.py"