~ruther/nix-tmpactivator

ref: 51790c2bb1a15d51848d3f433d80ccf01b0fbde7 nix-tmpactivator/README.md -rw-r--r-- 1.9 KiB
51790c2b — Rutherther feat: add pathsToLink option to not link everything 8 months ago

#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

{
  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