Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
}
];
};
# Stub module for home-manager on systems without impermanence
homeManagerModules.stub = import ./home-manager-stub.nix;
nixosModule = self.nixosModules.impermanence;
nixosModules.home-manager.impermanence = self.homeManagerModules.impermanence;

Expand Down
65 changes: 65 additions & 0 deletions home-manager-stub.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{ pkgs
, config
, lib
, ...
}:

let
inherit (lib)
mkOption
types
catAttrs
any
hasInfix
attrValues
;

inherit (types)
attrsOf
submodule
bool
;

inherit (config) home;

cfg = config.home.persistence;

persistentStoragePaths = catAttrs "persistentStoragePath" (attrValues cfg);
in
{
options =
{
home.persistence = mkOption {
default = { };
type = attrsOf (
submodule (
{ name, config, ... }:
import ./submodule-options.nix {
inherit pkgs lib name config;

user = home.username;
homeDir = home.homeDirectory;

# Home Manager doesn't seem to know about the user's group,
# so we default it to null here and fill it in in the NixOS
# module instead
group = null;
}
));
};
};
config = {
assertions = [
{
assertion = !(any (hasInfix home.homeDirectory) persistentStoragePaths);
message = ''
home.persistence: persistentStoragePath contains home directory path!

The API has changed - the persistent storage path should no longer
contain the path to the user's home directory, as it will be added
automatically.
'';
}
];
};
}