2 { config, lib, pkgs, ... }:
8 cfg = config.services.felix;
20 enable = mkEnableOption (lib.mdDoc "the Apache Felix OSGi service");
23 type = types.listOf types.package;
24 default = [ pkgs.felix_remoteshell ];
25 defaultText = literalExpression "[ pkgs.felix_remoteshell ]";
26 description = lib.mdDoc "List of bundles that should be activated on startup";
32 description = lib.mdDoc "User account under which Apache Felix runs.";
38 description = lib.mdDoc "Group account under which Apache Felix runs.";
48 config = mkIf cfg.enable {
49 users.groups.osgi.gid = config.ids.gids.osgi;
52 { uid = config.ids.uids.osgi;
53 description = "OSGi user";
54 home = "/homeless-shelter";
57 systemd.services.felix = {
58 description = "Felix server";
59 wantedBy = [ "multi-user.target" ];
62 # Initialise felix instance on first startup
63 if [ ! -d /var/felix ]
65 # Symlink system files
68 chown ${cfg.user}:${cfg.group} /var/felix
70 for i in ${pkgs.felix}/*
72 if [ "$i" != "${pkgs.felix}/bundle" ]
74 ln -sfn $i /var/felix/$(basename $i)
79 mkdir -p /var/felix/bundle
80 chown ${cfg.user}:${cfg.group} /var/felix/bundle
82 for i in ${pkgs.felix}/bundle/* ${toString cfg.bundles}
86 ln -sfn $i /var/felix/bundle/$(basename $i)
91 ln -sfn $j /var/felix/bundle/$(basename $j)
100 ${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh ${cfg.user} -c '${pkgs.jre}/bin/java -jar bin/felix.jar'