fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge branch 'literalExpression' [#2371]4fa1ba72

master
1.3 KiB52 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  cfg = config.services.nextcloud-client;
8
9in {
10  options = {
11    services.nextcloud-client = {
12      enable = mkEnableOption "Nextcloud Client";
13
14      package = mkOption {
15        type = types.package;
16        default = pkgs.nextcloud-client;
17        defaultText = literalExpression "pkgs.nextcloud-client";
18        description = "The package to use for the nextcloud client binary.";
19      };
20
21      startInBackground = mkOption {
22        type = types.bool;
23        default = false;
24        description =
25          "Whether to start the Nextcloud client in the background.";
26      };
27    };
28  };
29
30  config = mkIf cfg.enable {
31    assertions = [
32      (lib.hm.assertions.assertPlatform "services.nextcloud-client" pkgs
33        lib.platforms.linux)
34    ];
35
36    systemd.user.services.nextcloud-client = {
37      Unit = {
38        Description = "Nextcloud Client";
39        After = [ "graphical-session-pre.target" ];
40        PartOf = [ "graphical-session.target" ];
41      };
42
43      Service = {
44        Environment = "PATH=${config.home.profileDirectory}/bin";
45        ExecStart = "${cfg.package}/bin/nextcloud"
46          + (optionalString cfg.startInBackground " --background");
47      };
48
49      Install = { WantedBy = [ "graphical-session.target" ]; };
50    };
51  };
52}