From f4f924ac84d7f2d5608d53ffdc68cde86b577ff5 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Sat, 13 Apr 2024 21:43:52 +0200 Subject: [PATCH] docs: add README --- README.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..924779a0ca4214b52bb58ff4362120ddacbf994e --- /dev/null +++ b/README.md @@ -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; + }; + }; +} + +```