GithubHelp home page GithubHelp logo

Comments (8)

talyz avatar talyz commented on May 31, 2024

I don't think you want to persist the entire .config directory, since that kind of defeats the purpose of using the module.

To begin with, you need to use home-manager as a NixOS module (in the nixos directory of the home-manager repo). This makes sure home-manager's configuration is persisted and applied on boot, before you log in. This should also solve any directory conflicts, since it makes sure the bind mounts are set up very early in your session.

When you've made big changes to your configuration, you may have to run a nixos-rebuild boot and reboot to not have to solve the directory conflicts manually.

from impermanence.

robbins avatar robbins commented on May 31, 2024

Oh, ok thanks, I mistakenly thought that was meant for Impermanence as a NixOS module.

I've added home-manager as a NixOS module, and tested adding a file to be persisted:
home.persistence."/persist/home/nate" = { directories = [ ]; files = [ ".config/testfile" ]; allowOther = true; };
The file doesn't exist, so when I run nixos-rebuild switch I do see it created in ~/.config. It shows as a symlink to /nix/store/mdqq8fgjc8fwx5k1qrhiki5hj1h7bcpp-home-manager-files/.config/testfile, which is a symlink to /nix/store/vfib3x4nhr4wdxmsgfy65qx478ln4vb8-persist-home-nate-config-testfile, which is a symlink to /persist/home/nate/.config/testfile. However, that file in /persist doesn't seem to exist. In fact, the .config directory doesn't even exist in /persist/home/nate.

If I do create the file in /persist manually though, everything works fine. It also happens for files that do exist. So for some reason it's not creating the actual files in the persistent directory.

from impermanence.

talyz avatar talyz commented on May 31, 2024

Oh, yeah, you're right. Apparently, I forgot to implement that logic - sorry about that. I've created #55 to address this; I would appreciate if you could try it out and make sure it solves this issue for you.

from impermanence.

robbins avatar robbins commented on May 31, 2024

Sorry, was busy with midterms and stuff :P. I see that it's now been merged, so I updated my flake.lock, and tested again with .config/testfile. I now see the .config directory in /persist/home/nate.

However, testfile itself doesn't exist. I tried again with a file that exists (~/hello.txt), and after rebuild switch boot and rebooting, the file in ~ is a symlink to the nix store, but the file contents are gone as the file doesn't exist. The chain of symlinks resolves to nothing as /persist/home/nate doesn't contain hello.txt.

If I run touch hello1.txt, the symlink is fixed and I now see the file in /persist/home/nate/hello1.txt.

from impermanence.

talyz avatar talyz commented on May 31, 2024

Yes, this is by design. When a symlink points to a nonexistent file, it's regarded as such by most programs. This means they will try to create the file, which in turn creates the real file the symlink targets. If we instead created empty files, many applications would consider them corrupt: they exist, but don't have the expected contents.

from impermanence.

robbins avatar robbins commented on May 31, 2024

Thanks, and this is even for files that already exist? So if I am persisting a file that exists in home, I should nixos rebuild boot, and then copy it manually to the persistent directory?

from impermanence.

talyz avatar talyz commented on May 31, 2024

Yes, that's correct. We don't automatically migrate any files, since that's hard or impossible to do atomically and can cause lots of issues with running applications.

from impermanence.

robbins avatar robbins commented on May 31, 2024

Cool, thanks for the help in resolving this issue!

from impermanence.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.