fleek icon indicating copy to clipboard operation
fleek copied to clipboard

Help on programs/services needed (example: syncthing service)

Open thinkbig1979 opened this issue 1 year ago • 7 comments

Hi there.,

Using fleek to add packages has worked without a hitch so far, so really cool and happy to have this tool. However, I'm struggling with programs/services. The fleek documentation is really sparse here.

Case in point: Trying to add syncthing, which needs to run as a service, and there is an entry in the home-manager documentation relating to syncthing as well, so I assume it needs to be added as a program.

Tried using the command line:

❯ fleek add --program syncthing

# fleek | vv0.8.5

## Usage
> Add a new package or program to your configuration

fleek add [package] [package] ...

## Description
Add a new package or program to your configuration.
Use the `--program` flag to specify a program which can also be configured by nix.
## Flags
-a, --apply   | apply configuration after adding
-h, --help    | help for add
-q, --quiet   | suppress logs
-v, --verbose | show more detailed output


  ERROR   unknown flag: --program

That did not work as you can see. Also tried the syntax below, but same result.

fleek add syncthing --program

Trawling through the fleek directory looking for clues, I found these two files:

~/.local/share/fleek/programs.nix
~/.local/share/fleek/user.nix

The comments in these files suggest that programs and their configs respectively should be listed in these two files before adding them to . I added programs.syncthing.enable = true; to programs.nix and services.syncthing.enable = true; to user.nix. Then added syncthing to the list of programs in the fleek.yml file and applied the config. It ran without errors, but syncthing was not installed.

A bit of help here would be appreciated. :-)

Thanks!

thinkbig1979 avatar Apr 20 '23 07:04 thinkbig1979

this is a bug in fleek. I temporarily removed the concept of programs from the add/remove commands because of confusion about what they are and how to use them. Will fix.

bketelsen avatar Apr 21 '23 17:04 bketelsen

Thanks for your reply. Looking forward to the fix. Cheers!

thinkbig1979 avatar Apr 21 '23 18:04 thinkbig1979

Here's an example config for syncthing: https://github.com/bketelsen/fleek/blob/main/user.nix note that you don't need to add it to both programs & services. Just services is fine.

bketelsen avatar Apr 26 '23 23:04 bketelsen

Thanks for that. Will give it a try. Just so I understand, how minimal or extensive should this config be? Will Fleek now go out and create a systemd service without further config for example, or should that be set up in the user.nix file as well? I've been looking at this example, which is really extensive, and also contains the tray service config and explicit systemd service configs. Don't know what Fleek handles automagically, so just wondering how much config should be added here.

thinkbig1979 avatar Apr 27 '23 05:04 thinkbig1979

I'm not sure if you figured out your last question or not, so just in case and for future readers:

The example you referenced is actually home manager's implementation of services.syncthing. That particular file tells home manager (one of the background Nix processes fleek uses) what to set up when you enable the service in your config. To enable and use it you should only need to enter this into your user.nix:

services.syncthing.enable = true;

If you want to use the tray icon (which I haven't had luck getting to work in NixOS even -- probably an ID10T error...), you would set it like this:

services.syncthing.enable = true;
services.syncthing.tray.enable = true;

Please note that services don't always automatically start as soon as you install them. You can either restart or manually tell systemd to start them: systemctl --user start syncthing. After the initial reboot/start, however, they should start automatically for you with each reboot.

ironman820 avatar Jun 19 '23 19:06 ironman820

Thank you @ironman820, that's really useful info!

thinkbig1979 avatar Jun 20 '23 07:06 thinkbig1979

You are welcome @thinkbig1979. I wanted to add that I figured out my tray issues while poking around the home manager GitHub.

They posted a workaround. If you want to use the tray notifier, along with the tray configuration I mentioned previously, you can enter this into your user.nix:

	systemd.user.targets.tray = {
		Unit = {
			Description = "Home Manager System Tray";
			Requires = [ "graphical-session-pre.target" ];
		};
	};

ironman820 avatar Jun 22 '23 00:06 ironman820