Rowan Smith 563dbc4a71
feat: add post_clone_script to dotfiles in order to support startup dependencies/coordination (#679)
## Description

Adds post_clone_script variable to the dotfiles module, enabling startup
coordination with other scripts that depend on dotfiles.

An example of how to use this, which assumes the PR has been merged:

```
module "dotfiles" {
  count                = data.coder_workspace.me.start_count
  source               = "registry.coder.com/coder/dotfiles/coder"
  version              = "1.3.0"
  agent_id             = coder_agent.main.id
  default_dotfiles_uri = "https://github.com/someuser/somedotfiles"
  post_clone_script    = <<-EOF
    coder exp sync start dotfiles && coder exp sync complete dotfiles
  EOF
}

resource "coder_script" "personalize" {
  count        = data.coder_workspace.me.start_count
  agent_id     = coder_agent.main.id
  display_name = "Personalize"
  icon         = "/icon/personalize.svg"
  run_on_start = true
  script       = <<-EOF
    trap 'coder exp sync complete personalize' EXIT
    coder exp sync want personalize dotfiles
    coder exp sync start personalize
    SCRIPT="$HOME/.config/coderv2/dotfiles/personalize"
    if [ -f "$SCRIPT" ] && [ -x "$SCRIPT" ]; then
      $SCRIPT
    fi
  EOF
}
```

## Type of Change

- [ ] New module
- [ ] New template
- [ ] Bug fix
- [x] Feature/enhancement
- [ ] Documentation
- [ ] Other

## Module Information

**Path:** `registry/coder/modules/dotfiles`  
**New version:** `v1.3.0`  
**Breaking change:** [ ] Yes [x] No

## Testing & Validation

- [ ] Tests pass (`bun test`)
- [ ] Code formatted (`bun fmt`)
- [x] Changes tested locally

## Related Issues

#678
2026-02-16 09:14:50 +11:00

2.3 KiB

display_name description icon verified tags
Dotfiles Allow developers to optionally bring their own dotfiles repository to customize their shell and IDE settings! ../../../../.icons/dotfiles.svg true
helper
dotfiles

Dotfiles

Allow developers to optionally bring their own dotfiles repository.

This will prompt the user for their dotfiles repository URL on template creation using a coder_parameter.

Under the hood, this module uses the coder dotfiles command.

module "dotfiles" {
  count    = data.coder_workspace.me.start_count
  source   = "registry.coder.com/coder/dotfiles/coder"
  version  = "1.3.0"
  agent_id = coder_agent.example.id
}

Examples

Apply dotfiles as the current user

module "dotfiles" {
  count    = data.coder_workspace.me.start_count
  source   = "registry.coder.com/coder/dotfiles/coder"
  version  = "1.3.0"
  agent_id = coder_agent.example.id
}

Apply dotfiles as another user (only works if sudo is passwordless)

module "dotfiles" {
  count    = data.coder_workspace.me.start_count
  source   = "registry.coder.com/coder/dotfiles/coder"
  version  = "1.3.0"
  agent_id = coder_agent.example.id
  user     = "root"
}

Apply the same dotfiles as the current user and root (the root dotfiles can only be applied if sudo is passwordless)

module "dotfiles" {
  count    = data.coder_workspace.me.start_count
  source   = "registry.coder.com/coder/dotfiles/coder"
  version  = "1.3.0"
  agent_id = coder_agent.example.id
}

module "dotfiles-root" {
  count        = data.coder_workspace.me.start_count
  source       = "registry.coder.com/coder/dotfiles/coder"
  version      = "1.3.0"
  agent_id     = coder_agent.example.id
  user         = "root"
  dotfiles_uri = module.dotfiles.dotfiles_uri
}

Setting a default dotfiles repository

You can set a default dotfiles repository for all users by setting the default_dotfiles_uri variable:

module "dotfiles" {
  count                = data.coder_workspace.me.start_count
  source               = "registry.coder.com/coder/dotfiles/coder"
  version              = "1.3.0"
  agent_id             = coder_agent.example.id
  default_dotfiles_uri = "https://github.com/coder/dotfiles"
}