# Dotfiles and Custom Images

**URL:** <https://universal-blue.discourse.group/t/dotfiles-and-custom-images/596>\
**Category:** Contributing\
**Created:** [February 14, 2024, 5:52pm UTC](https://universal-blue.discourse.group/t/dotfiles-and-custom-images/596 "2024-02-14T17:52:20Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Heus-Sueh](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/heus-sueh/32/137_2.png) [@Heus-Sueh](https://universal-blue.discourse.group/u/Heus-Sueh)\
**Post date:** [February 14, 2024, 5:52pm UTC](https://universal-blue.discourse.group/t/dotfiles-and-custom-images/596/1 "2024-02-14T17:52:20Z")

</div>

What would be the best way to integrate dotfiles and custom images?

I’m trying to create a sway image with dotfiles, but the solution I found to deal with this may not be better, I’m dealing with the dotfiles directly in the image instead of having a script that clones a git repository and copies the files to the user’s home on the first boot, what would be the best solution in this case? I thought about using chezmoi together with yafti, but I don’t know if that will work

---

<div class="post-metadata">

**Author:** ![ethanjli](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/ethanjli/32/479_2.png) [@ethanjli](https://universal-blue.discourse.group/u/ethanjli)\
**Post date:** [February 15, 2024, 5:03am UTC](https://universal-blue.discourse.group/t/dotfiles-and-custom-images/596/2 "2024-02-15T05:03:00Z")

</div>

How would you feel about adding a custom justfile command (or, for a more automated experience, a systemd user service running a custom script) which ensures that you have the latest version of your dotfiles, e.g. applied with chezmoi?

---

<div class="post-metadata">

**Author:** ![fenglengshun](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/fenglengshun/32/367_2.png) [@fenglengshun](https://universal-blue.discourse.group/u/fenglengshun)\
**Post date:** [February 15, 2024, 9:04am UTC](https://universal-blue.discourse.group/t/dotfiles-and-custom-images/596/3 "2024-02-15T09:04:53Z")

</div>

I just put mine in [/usr/etc/skel](https://github.com/bayazidbh/ublue-whitesur/tree/live/usr/etc/skel). It’s not always updated though - skel is only copied at user creation, so I still need to periodically copy my files to my repo.

The other thing that I’ve been doing is putting my files in my [home-manager](https://github.com/bayazidbh/home-manager) repo, and [using tmpfiles to symlink them](https://github.com/bayazidbh/home-manager/blob/075bcdaeda41579f4ae686db2c79afe9ae97fe74/laptop/files.nix) so that the files in the local repo is always updated and I just need to commit and push them to GH repo.

---

<div class="post-metadata">

**Author:** ![j0rge](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/j0rge/32/8_2.png) [@j0rge](https://universal-blue.discourse.group/u/j0rge)\
**Post date:** [February 15, 2024, 4:04pm UTC](https://universal-blue.discourse.group/t/dotfiles-and-custom-images/596/4 "2024-02-15T16:04:01Z")

</div>

> [@ethanjli](#):
>
> applied with chezmoi?

If someone wanted to do a completely automated chezmoi setup I would ship that by default in Bluefin! It’d be nice to just have this ootb.

---

<div class="post-metadata">

**Author:** ![Heus-Sueh](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/heus-sueh/32/137_2.png) [@Heus-Sueh](https://universal-blue.discourse.group/u/Heus-Sueh)\
**Post date:** [February 15, 2024, 8:08pm UTC](https://universal-blue.discourse.group/t/dotfiles-and-custom-images/596/5 "2024-02-15T20:08:04Z")

</div>

That would be cool and would help a lot

---

<div class="post-metadata">

**Author:** ![mecattaf](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/mecattaf/32/868_2.png) [@mecattaf](https://universal-blue.discourse.group/u/mecattaf)\
**Post date:** [February 28, 2024, 9:22pm UTC](https://universal-blue.discourse.group/t/dotfiles-and-custom-images/596/6 "2024-02-28T21:22:59Z")

</div>

Opened an issue about this in blue-build/modules:

> <https://github.com/blue-build/modules/issues/155>
>
> Thanks so much for this project!
> 
> \### Context
> Creating an automatic .config (…dotfiles) management system with chezmoi can make our lives a lot easier. Most of us already have our dotfiles in a github repo, so this module could make our experience a lot smoother. 
> 
> \### Requirements: 
> We need a bash script that manages dotfiles with chezmoi:
> 1) pulls and updates the dotfiles every time the computer is turned on
> 2) pushes the changes to git every time the config files are updated (in ~/.config/chezmoi/chezmoi.toml set autoCommit and autoPush)
> And a systemd service to do this automatically
> 
> (LLM-generated skeleton)
> \- chezmoi-auto.service:
> \`\`\`
> \[Unit\]
> Description=Automatically update dotfiles with chezmoi
> After=network-online.target
> 
> \[Service\]
> Type=oneshot
> ExecStart=/path/to/your/script/chezmoi-auto.sh
> 
> \[Install\]
> WantedBy=multi-user.target
> \`\`\`
> 
> \- chezmoi-auto.sh
> \`\`\`
> \#!/usr/bin/env bash
> 
> \# Exit immediately if a command exits with a non-zero status.
> set -e
> 
> \# Pull the latest changes for your dotfiles from the source repository.
> \# chezmoi update will fetch and apply the latest changes.
> chezmoi update
> 
> \# Uncomment the following lines if your chezmoi configuration does not automatically commit and push changes,
> \# and you would like this script to do so. Ensure you have configured git credentials correctly for non-interactive use.
> \# cd $(chezmoi source-path)
> \# git add .
> \# git commit -m "Automatic update by chezmoi-auto.sh script"
> \# git push
> 
> \# Notification example (optional, for desktop environments that support libnotify)
> \# notify-send "Chezmoi Update" "Your dotfiles have been updated successfully."
> \`\`\`
> 
> \### Using the module:
> Bluebuild users could point this module to their dotfiles with:
> \`\`\`
> chezmoi:
> username: {username}
> \`\`\`
> Setting up chezmoi the first time (from the docs):
> \`\`\`
> chezmoi's install script can run chezmoi init for you by passing extra arguments to the newly installed chezmoi binary. If your dotfiles repo is github.com/$GITHUB\_USERNAME/dotfiles then installing chezmoi, running chezmoi init, and running chezmoi apply can be done in a single line of shell:
> $ sh -c "$(curl -fsLS get.chezmoi.io)" -- init --apply $GITHUB\_USERNAME
> If your dotfiles repo has a different name to dotfiles, or if you host your dotfiles on a different service, then see the reference manual for chezmoi init.
> For setting up transitory environments (e.g. short-lived Linux containers) you can install chezmoi, install your dotfiles, and then remove all traces of chezmoi, including the source directory and chezmoi's configuration directory, with a single command:
> $ sh -c "$(curl -fsLS get.chezmoi.io)" -- init --one-shot $GITHUB\_USERNAME
> \`\`\`
> 
> \### Relevant Chezmoi docs:
> \- \[Concepts\](https://www.chezmoi.io/reference/concepts)
> \- \[Daily Operations Guide\](https://www.chezmoi.io/user-guide/daily-operations/)
> 
> 
> Idea from \[ublue forums\](https://universal-blue.discourse.group/t/dotfiles-and-custom-images/596)

---

<div class="post-metadata">

**Author:** ![exponentactivity](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/exponentactivity/32/1476_2.png) [@exponentactivity](https://universal-blue.discourse.group/u/exponentactivity)\
**Post date:** [April 30, 2024, 8:14pm UTC](https://universal-blue.discourse.group/t/dotfiles-and-custom-images/596/7 "2024-04-30T20:14:57Z")

</div>

Please check out this [pull request](https://github.com/blue-build/modules/pull/215) for this feature.

---

<div class="post-metadata">

**Author:** ![visnu\_Deva](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/visnu_deva/32/1779_2.png) [@visnu\_Deva](https://universal-blue.discourse.group/u/visnu_Deva)\
**Post date:** [November 16, 2024, 9:39am UTC](https://universal-blue.discourse.group/t/dotfiles-and-custom-images/596/8 "2024-11-16T09:39:22Z")

</div>

How do you deal with the dotfiles directly in the image ? i am having difficutly doing that, it seems it doesn’t want to go to .config, can you share something please.

---

<div class="post-metadata">

**Author:** ![tulilirockz](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/tulilirockz/32/6812_2.png) [@tulilirockz](https://universal-blue.discourse.group/u/tulilirockz)\
**Post date:** [November 16, 2024, 5:30pm UTC](https://universal-blue.discourse.group/t/dotfiles-and-custom-images/596/9 "2024-11-16T17:30:06Z")

</div>

Would this still be interesting? Bluebuild’s implementation seems pretty nice, I could port it over to Bluefin quite easily following their steps. I personally dont know if it would be super cool to mess around with people’s $HOMEs tho…

---

<div class="post-metadata">

**Author:** ![tulilirockz](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/tulilirockz/32/6812_2.png) [@tulilirockz](https://universal-blue.discourse.group/u/tulilirockz)\
**Post date:** [November 16, 2024, 5:30pm UTC](https://universal-blue.discourse.group/t/dotfiles-and-custom-images/596/10 "2024-11-16T17:30:55Z")

</div>

If you are using BlueBuild just use their module, otherwise it is kind of a complicated implementation to figure out if you havent done something like that already

---

<div class="post-metadata">

**Author:** ![visnu\_Deva](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/visnu_deva/32/1779_2.png) [@visnu\_Deva](https://universal-blue.discourse.group/u/visnu_Deva)\
**Post date:** [November 16, 2024, 7:53pm UTC](https://universal-blue.discourse.group/t/dotfiles-and-custom-images/596/11 "2024-11-16T19:53:24Z")

</div>

Yes I am using bluebuild, can you be more specific please because I tried to set it up in their recipe file if it is what you mean and also I tried with a script but I don’t get the result I want which is simply to copy my dotfiles into the .config folder but I can copy them elsewhere for some reason which may not be very useful.

---

<div class="post-metadata">

**Author:** ![lorduskordus](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/lorduskordus/32/267_2.png) [@lorduskordus](https://universal-blue.discourse.group/u/lorduskordus)\
**Post date:** [November 16, 2024, 9:18pm UTC](https://universal-blue.discourse.group/t/dotfiles-and-custom-images/596/12 "2024-11-16T21:18:56Z")

</div>

Stuff you put into /etc/skel gets copied to a new user’s $HOME automatically. Put your dotfiles in there

---

<div class="post-metadata">

**Author:** ![visnu\_Deva](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/visnu_deva/32/1779_2.png) [@visnu\_Deva](https://universal-blue.discourse.group/u/visnu_Deva)\
**Post date:** [November 17, 2024, 5:12am UTC](https://universal-blue.discourse.group/t/dotfiles-and-custom-images/596/13 "2024-11-17T05:12:17Z")

</div>

Thanx for your answer, I will try that.

---

<div class="post-metadata">

**Author:** ![visnu\_Deva](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/visnu_deva/32/1779_2.png) [@visnu\_Deva](https://universal-blue.discourse.group/u/visnu_Deva)\
**Post date:** [November 19, 2024, 12:54pm UTC](https://universal-blue.discourse.group/t/dotfiles-and-custom-images/596/14 "2024-11-19T12:54:46Z")

</div>

I did as you said, put the dotfiles in the etc/skel/.config folder and added the source and destination in the modules of the recipe then created a new user on my laptop and after rebooting all the dotfiles got copied at the right place.  
Thank you very much !
