Hacker News new | ask | show | jobs
by m000 396 days ago
My main gripe with dotfile managers (including lnk) is that they assume a uniform environment. I haven't found one that doesn't make this fundamendal assumption.

Some scenarios where dot fils may differ between computers:

- My .gitconfig is different on my work laptop than my desktop.

- I don't have neovim installed on my pi zero running DNS for my home network.

- My zsh functions for making animated gifs won't work if specific tools are not installed.

- An alias to open an image with the default image viewer is different between macos and linux.

- I only have rust toolchain installed on my home desktop, so I shouldn't see it in my PATH on my work laptop.

Is there any solution out there that can handle similar cases? Or are these requirements unique to me? (I don't quite believe they are.)

8 comments

I believe most dotfile managers offer the possibility to switch config based on hosts (e.g. chez-moi has templates https://www.chezmoi.io/user-guide/manage-machine-to-machine-... ). I guess with lnk being git centric that would be through branches.

In any case you can manage your bashrc/profile and handle conditional logic to install packages there.

Check out YADM which allows you to link files based on criteria such as hostname.
This is my answer too. I extract the stuff that is unique from my config files to files sourced by my configs and then make it unique by hostname with yadm. It works so well
For shell stuff, I use fish, and my fish config has a bunch of if...end blocks around most things, for example:

```if command -q exa alias ls="exa" alias ll="exa -lah" alias tree="exa --tree" end

if command -q eza alias ls="eza" alias ll="eza -lah" alias tree="eza --tree" end```

This plugin simplifies that workflow:

https://github.com/jabirali/fish-abbrfile

That's pretty neat, thanks!
Fish seems to keep it contained to .config/fish which is nice. Most others tend to spread out outside of .config

I’ve started modeling fish with zsh and OMZ customs

I handled this by just writing a simple install script that symlinks different files depending the OS (but could use any criteria—hostname, installed packages, etc). Updating the dot files is just a matter of a git pull. If I’ve added a new dotfile, then I run the install script again.
Git supports conditional configuration so you can tell it to load different config files based on file system location or what have you. I use it to swap signing keys and author info depending on whether the repo is personal or for work based.
I solve this locally by having a bash_profile that is universal and then OS-specific files that get loaded by a function that checks the OS. It’s slightly more to manage, but works perfectly. Completely compatible with any dotfiles management tool I’ve encountered. No reason this couldn’t be expanded to factor additional variables.
It is significantly more complicated, but what about a symlink manager driven by a programming language, such as guix home or nix's home-manager?