feat: add dotfiles module (#33)

Co-authored-by: Muhammad Atif Ali <atif@coder.com>
This commit is contained in:
Ben Potter
2023-09-26 00:31:57 +01:00
committed by GitHub
parent 61ae309a1f
commit a05030c81f
4 changed files with 60 additions and 0 deletions

12
dotfiles/README.md Normal file
View File

@@ -0,0 +1,12 @@
---
display_name: Dotfiles
description: Allow developers to optionally bring their own dotfiles repository to customize their shell and IDE settings!
icon: ../.icons/dotfiles.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.

37
dotfiles/main.tf Normal file
View File

@@ -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
}