Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File is in the way of symlinking (shell history, .zsh_history) #233

Open
yeldiRium opened this issue Nov 20, 2024 · 1 comment
Open

File is in the way of symlinking (shell history, .zsh_history) #233

yeldiRium opened this issue Nov 20, 2024 · 1 comment

Comments

@yeldiRium
Copy link

I'm trying to persist my zsh history using the home manager impermanence module like this:

{
  home = {
    persistence = {
      "/persist/${config.home.homeDirectory}" = {
        files = [
          ".zsh_history"
        ];
      };
    };
  };
}

Most of the time this works fine. Sometimes, when switching, the activation script fails.
I assume this is the case because some zsh session is writing to the file in the wrong moment, and a regular file exists when home manager tries to symlink over it. The systemd unit logs this:

...: Activating checkLinkTargets
...: Existing file '/home/yeldir/.zsh_history' is in the way of '/nix/store/wwvczw7sk7gnxn4gf0gkb0kd1x182x1x-home-manager-files/.zsh_history'
...: Please do one of the following:
...: - Move or remove the above files and try again.
...: - In standalone mode, use 'home-manager switch -b backup' to back up
...:   files automatically.
...: - When used as a NixOS or nix-darwin module, set
...:     'home-manager.backupFileExtension'
...:   to, for example, 'backup' and rebuild.

I don't think this is a bug in impermanence and I also don't have a suggestion on how to prevent this code-wise.

I just want to ask: Has anyone done something similar? Has anyone solved this or a similar problem?

@body20002
Copy link

I read somewhere to do something like

home-manager.backupFileExtension = "backup-"
      + pkgs.lib.readFile
        "${pkgs.runCommand "timestamp" {} "echo -n `date '+%Y%m%d%H%M%S'` > $out"}";

but it doesn't really work if you try to build multiple times not sure why :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants