~ruther/nix-tmpactivator

f4f924ac84d7f2d5608d53ffdc68cde86b577ff5 — Rutherther 11 months ago 2bad14e
docs: add README
1 files changed, 53 insertions(+), 0 deletions(-)

A README.md
A README.md => README.md +53 -0
@@ 0,0 1,53 @@
# Nix tmpactivator
This is mostly for learning purposes.
This is a lightweight home directory activator with home-manager like interface to home file linking.

## How this works
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.

## Options
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.

## Example flake

```nix
{
  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;
    };
  };
}

```

Do not follow this link