divnix / digga

A flake utility library to craft shell-, home-, and hosts- environments.
https://digga.divnix.com
MIT License
1k stars 108 forks source link

Integration: impermanence for home & machine state #199

Open blaggacao opened 3 years ago

blaggacao commented 3 years ago

Would your feature fix an existing issue?

180 & #187

Describe the solution you'd like

Impermanence is very handy and easy to use. It is intended for hosts with root file systems that do not persist between reboots—a strategy I also generally recommend—but is useful for consolidation of mutable state regardless. The chosen path(s) (e.g., /persistent from environment.persistence."/persistent") can then be managed as independent repositories as desired for versioning, backup, deployment, etc.

@ctem https://github.com/divnix/devos/discussions/180#discussioncomment-497534

Describe alternatives you've considered

git lfs which is probably too git centric and also doesn't solve the problem as generically as impernanence does.

Additional context

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/97544756-integration-impermanence-for-home-machine-state?utm_campaign=plugin&utm_content=tracker%2F161955272&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F161955272&utm_medium=issues&utm_source=github).
nrdxp commented 3 years ago

I am currently experimenting with impermanence along with:

{
  # load blank root on every boot
  boot.initrd.postDeviceCommands = lib.mkAfter ''
    zfs rollback -r rpool/local/root@blank
  '';
}

To allow for an essentially temporary root directory where all state is opt in via environment.persistence, thanks to grahamc. I haven't synced it yet because I was wanting to break out the relavent bits into a profile, and I've been busy figuring out how to fix performance with zfs and the nix/store.

So far it's pretty great though.

Th3Whit3Wolf commented 3 years ago

For those who want to use impermanence for root and home you can import it as not a flake and use the modules.

inputs = {

  impermanence = {
    url = "github:nix-community/impermanence";
    flake = false;
  };

};
outputs = {

  nixos = {
    hostDefaults = {
      system = "x86_64-linux";
      channelName = "nixos";
      modules = ./modules/module-list.nix;
      externalModules = [
        { _module.args.ourLib = self.lib; }
        home.nixosModules.home-manager
        "${inputs.impermanence}/nixos.nix"
        ./modules/customBuilds.nix
      ];
    };
  };

  home = {
    modules = ./users/modules/module-list.nix;
    externalModules = [ "${inputs.impermanence}/home-manager.nix" ];

  };
};

I will note that have had issues getting age to work while using impermanence home-manager module.

nrdxp commented 3 years ago

I'm doing this as well, just haven't gotten around to making a proper profile for it

Th3Whit3Wolf commented 3 years ago

I'm doing this as well, just haven't gotten around to making a proper profile for it

Have you had any issues getting age to work with it?

nrdxp commented 3 years ago

@Th3Whit3Wolf Yes, I filed my chronicles on that issue here: https://github.com/ryantm/agenix/issues/45

You need a nixpkgs with the fix mentioned merged, nixos-unstable should have it now. Not sure if it's been backported to a release yet though (or if it will be).