Files
coder/docs/dotfiles.md
T

62 lines
1.6 KiB
Markdown
Raw Normal View History

2022-06-16 18:48:18 -05:00
# Dotfiles
2022-10-23 17:09:58 -05:00
<!-- markdown-link-check-disable -->
2022-12-05 12:21:09 +01:00
2022-06-16 18:48:18 -05:00
Coder offers the `coder dotfiles <repo>` command which simplifies workspace
personalization. Our behavior is consistent with Codespaces, so
[their documentation](https://docs.github.com/en/codespaces/customizing-your-codespace/personalizing-codespaces-for-your-account#dotfiles)
explains how it loads your repo.
2022-12-05 12:21:09 +01:00
2022-10-23 17:09:58 -05:00
<!-- markdown-link-check-enable -->
2022-06-16 18:48:18 -05:00
You can read more on dotfiles best practices [here](https://dotfiles.github.io).
## Templates
Templates can prompt users for their dotfiles repo using the following pattern:
```hcl
variable "dotfiles_uri" {
description = <<-EOF
Dotfiles repo URI (optional)
see https://dotfiles.github.io
EOF
# The codercom/enterprise-* images are only built for amd64
default = ""
}
resource "coder_agent" "main" {
2022-06-16 18:48:18 -05:00
...
startup_script = var.dotfiles_uri != "" ? "coder dotfiles -y ${var.dotfiles_uri}" : null
2022-06-16 18:48:18 -05:00
}
```
[Here's a complete example.](https://github.com/coder/coder/tree/main/examples/templates/docker-with-dotfiles#how-it-works)
## Persistent Home
2022-10-19 22:57:37 -06:00
Sometimes you want to support personalization without
2022-06-16 18:48:18 -05:00
requiring dotfiles.
In such cases:
- Mount a persistent volume to the `/home` directory
- Set the `startup_script` to call a `~/personalize` script that the user can edit
```hcl
resource "coder_agent" "main" {
2022-06-16 18:48:18 -05:00
...
startup_script = "/home/coder/personalize"
}
```
The user can even fill `personalize` with `coder dotfiles <repo>`, but those
looking for a simpler approach can inline commands like so:
```bash
#!/bin/bash
sudo apt update
# Install some of my favorite tools every time my workspace boots
sudo apt install -y neovim fish cargo
```