From eecda092872b013655b97f0303af7a2d1b1c09cb Mon Sep 17 00:00:00 2001 From: Ben Potter Date: Sun, 24 Sep 2023 05:28:16 +0000 Subject: [PATCH] feat: add dotfiles module --- .gitignore | 1 + dotfiles/README.md | 16 ++++++++++++++++ dotfiles/main.tf | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 .gitignore create mode 100644 dotfiles/README.md create mode 100644 dotfiles/main.tf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..66df410 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.terraform* \ No newline at end of file diff --git a/dotfiles/README.md b/dotfiles/README.md new file mode 100644 index 0000000..8a33e45 --- /dev/null +++ b/dotfiles/README.md @@ -0,0 +1,16 @@ +--- +display_name: Dotfiles +description: Allow developers to optionally bring their own dotfiles repository to customize their shell and IDE settings! +icon: ../.icons/personalize.svg +maintainer_github: coder +verified: true +tags: [helper] +--- + +# Dotfiles + +Allow developers to optionally bring their own [dotfiles repository](https://dotfiles.github.io)! Under the hood, this module uses the [coder dotfiles](https://coder.com/docs/v2/latest/dotfiles) command. + +TODO: + +- [ ] Test it \ No newline at end of file diff --git a/dotfiles/main.tf b/dotfiles/main.tf new file mode 100644 index 0000000..fc07e79 --- /dev/null +++ b/dotfiles/main.tf @@ -0,0 +1,37 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + coder = { + source = "coder/coder" + version = ">= 0.12" + } + } +} + +variable "agent_id" { + type = string + description = "The ID of a Coder agent." +} + +data "coder_parameter" "dotfiles_uri" { + type = "string" + display_name = "Dotfiles URL (optional)" + default = "" + description = "Enter a URL for a [dotfiles repository](https://dotfiles.github.io) to personalize your workspace" + mutable = true + icon = "https://raw.githubusercontent.com/jglovier/dotfiles-logo/main/dotfiles-logo-icon.svg" +} + +resource "coder_script" "personalize" { + agent_id = var.agent_id + script =<<-EOT + DOTFILES_URI="${data.coder_parameter.dotfiles_uri.value}" + if [ -n "$${DOTFILES_URI// }" ]; then + coder dotfiles "$DOTFILES_URI" -y 2>&1 | tee -a ~/.dotfiles.log + fi + EOT + display_name = "Dotfiles" + icon = "https://raw.githubusercontent.com/jglovier/dotfiles-logo/main/dotfiles-logo-icon.svg" + run_on_start = true +}