This is mostly for learning purposes. This is a lightweight home directory activator with home-manager like interface to home file linking.
Internally a tmpfiles.d
file is made. This file is then activated using systemd-tmpfiles
command. Maybe it would be better to just symlink manually at this point...
config.tmpfiles.activationPackage
is the package you want to use for activation. The binary file to activate is bin/activate
. To remove the files use bin/deactivate
.
CAUTION: the deactivation will remove even files that were not created by the tool. Activation will override
files that already exist and were not created by this tool! Make sure that you are not going to override anything.
For home files, use home.file
. The interface is the same as for NixOS environment.etc
. home.user
and home.group
should be configured. home.homeDirectory
is exposed as well and is set to /home/${config.home.user}
by default.
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.tmpactivator.url = "github:Rutherther/nix-tmpactivator";
inputs.tmpactivator.inputs.nixpkgs.follows = "nixpkgs";
outputs = { self, nixpkgs, tmpactivator }: let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
environment = tmpactivator.lib.mkTmpActivator {
inherit pkgs;
modules = [
{
home = {
user = "ruther";
group = "users";
file."testing".text = "Hello world!";
};
systemd.services.test = {
script = ''
echo "Hello world!"
'';
};
}
];
};
in {
packages.${system} = {
default = self.packages.${system}.activationPackage;
activationPackage = environment.config.tmpfiles.activationPackage;
};
};
}