1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7 cfg = config.services.flashpolicyd;
8
9 flashpolicyd = pkgs.stdenv.mkDerivation {
10 name = "flashpolicyd-0.6";
11
12 src = pkgs.fetchurl {
13 name = "flashpolicyd_v0.6.zip";
14 url = "http://www.adobe.com/content/dotcom/en/devnet/flashplayer/articles/socket_policy_files/_jcr_content/articlePrerequistes/multiplefiles/node_1277808777771/file.res/flashpolicyd_v0.6%5B1%5D.zip";
15 sha256 = "16zk237233npwfq1m4ksy4g5lzy1z9fp95w7pz0cdlpmv0fv9sm3";
16 };
17
18 buildInputs = [ pkgs.unzip pkgs.perl ];
19
20 installPhase = "mkdir $out; cp -pr * $out/; chmod +x $out/*/*.pl";
21 };
22
23 flashpolicydWrapper = pkgs.writeScriptBin "flashpolicyd"
24 ''
25 #! ${pkgs.stdenv.shell}
26 exec ${flashpolicyd}/Perl_xinetd/in.flashpolicyd.pl \
27 --file=${pkgs.writeText "flashpolixy.xml" cfg.policy} \
28 2> /dev/null
29 '';
30
31in
32
33{
34
35 ###### interface
36
37 options = {
38
39 services.flashpolicyd = {
40
41 enable = mkOption {
42 default = false;
43 description =
44 ''
45 Whether to enable the Flash Policy server. This is
46 necessary if you want Flash applications to make
47 connections to your server.
48 '';
49 };
50
51 policy = mkOption {
52 default =
53 ''
54 <?xml version="1.0"?>
55 <!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">
56 <cross-domain-policy>
57 <site-control permitted-cross-domain-policies="master-only"/>
58 <allow-access-from domain="*" to-ports="*" />
59 </cross-domain-policy>
60 '';
61 description = "The policy to be served. The default is to allow connections from any domain to any port.";
62 };
63
64 };
65
66 };
67
68
69 ###### implementation
70
71 config = mkIf cfg.enable {
72
73 services.xinetd.enable = true;
74
75 services.xinetd.services = singleton
76 { name = "flashpolicy";
77 port = 843;
78 unlisted = true;
79 server = "${flashpolicydWrapper}/bin/flashpolicyd";
80 };
81
82 };
83
84}