2 { config, lib, pkgs, ... }:
5 cfg = config.services.felix;
17 enable = lib.mkEnableOption "the Apache Felix OSGi service";
19 bundles = lib.mkOption {
20 type = lib.types.listOf lib.types.package;
21 default = [ pkgs.felix_remoteshell ];
22 defaultText = lib.literalExpression "[ pkgs.felix_remoteshell ]";
23 description = "List of bundles that should be activated on startup";
29 description = "User account under which Apache Felix runs.";
32 group = lib.mkOption {
35 description = "Group account under which Apache Felix runs.";
45 config = lib.mkIf cfg.enable {
46 users.groups.osgi.gid = config.ids.gids.osgi;
49 { uid = config.ids.uids.osgi;
50 description = "OSGi user";
51 home = "/homeless-shelter";
54 systemd.services.felix = {
55 description = "Felix server";
56 wantedBy = [ "multi-user.target" ];
59 # Initialise felix instance on first startup
60 if [ ! -d /var/felix ]
62 # Symlink system files
65 chown ${cfg.user}:${cfg.group} /var/felix
67 for i in ${pkgs.felix}/*
69 if [ "$i" != "${pkgs.felix}/bundle" ]
71 ln -sfn $i /var/felix/$(basename $i)
76 mkdir -p /var/felix/bundle
77 chown ${cfg.user}:${cfg.group} /var/felix/bundle
79 for i in ${pkgs.felix}/bundle/* ${toString cfg.bundles}
83 ln -sfn $i /var/felix/bundle/$(basename $i)
88 ln -sfn $j /var/felix/bundle/$(basename $j)
97 ${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh ${cfg.user} -c '${pkgs.jre}/bin/java -jar bin/felix.jar'