2 inputs.environment.url = "path:../environment";
3 outputs = { self, environment }: {
4 nixosModule = self.nixosModules.chatons;
5 nixosModules.chatons = { config, lib, pkgs, nodes, ... }:
7 concatValue = value: if lib.isList value then builtins.concatStringsSep "," value else builtins.toString value;
8 toProperties = properties: builtins.concatStringsSep "\n" (
11 (lib.mapAttrsRecursive
12 (path: value: builtins.concatStringsSep "." (builtins.filter (f: f != "") path) + " = " + (concatValue value))
17 status.description = "OK";
18 install.type = "PACKAGE";
19 registration.load = "OPEN";
23 server.type = "PHYSICAL";
24 provider.type = "HOSTEDSERVER";
25 server.distribution = "NixOS";
26 country.name = "Allemagne";
33 protocol = "ChatonsInfos-0.5";
34 generator = "Nix derivation";
37 legal.url = "https://www.immae.eu/mentions.html";
38 guide.technical = "https://git.immae.eu/cgit/perso/Immae/Config/Nix.git/";
39 contact.url = "https://www.immae.eu/contacts_fr.html";
40 contact.email = config.myEnv.tools.contact;
41 startdate = "01/01/2019";
46 class = "organization";
47 protocol = "ChatonsInfos-0.5";
48 datetime = "2021-01-11T22:23:00";
49 generator = "Nix derivation";
52 country.name = "France";
55 description = "ImmaeEu est un CHATONS des Alpes-Maritimes";
56 website = "https://www.immae.eu";
57 logo = "https://assets.immae.eu/logo.jpg";
59 diaspora = "https://diaspora.immae.eu/people/1a185f29cc76cb35";
60 facebook = "https://www.facebook.com/ismael.bouya";
61 mastodon = "https://mastodon.immae.eu/@immae";
62 peertube = "https://peertube.immae.eu/accounts/immae/";
63 twitter = "https://twitter.com/_immae";
66 xmpp = "ismael@immae.fr";
67 irc = "immae@freenode";
68 matrix = "#support:immae.eu";
70 contact.url = "https://www.immae.eu/contacts_fr.html";
71 contact.email = config.myEnv.tools.contact;
72 legal.url = "https://www.immae.eu/mentions.html";
73 guide.technical = "https://git.immae.eu/cgit/perso/Immae/Config/Nix.git/";
74 guide.user = "https://www.immae.eu/docs";
75 status.level = "ACTIVE";
76 status.description = "En activité";
77 startdate = "01/01/2019";
80 logo = "https://assets.immae.eu/logo.jpg";
81 name = "Ismaël Bouya";
82 website = "https://www.immae.eu";
85 startdate = "01/07/2019";
86 status.level = "ACTIVE";
87 status.description = "Participe au collectif";
91 subname = v: if v.published or true then "subs" else "subs-hidden";
92 toOrganizationProperties = name: pkgs.writeText name (toProperties organization + "\n" + (
93 builtins.concatStringsSep "\n" (lib.mapAttrsToList
94 (n: v: "${subname v}.${n} = https://www.immae.eu/.well-known/chatonsinfos/service-${n}.properties") mergedServices
96 builtins.concatStringsSep "\n" (lib.mapAttrsToList
97 (n: v: "subs.hosting-${n} = https://www.immae.eu/.well-known/chatonsinfos/hosting-${n}.properties") mergedHostings
99 toHostingProperties = name: content: pkgs.writeText name (toProperties (lib.recursiveUpdate (before "hosting") (lib.recursiveUpdate content (after "hosting"))));
100 toServiceProperties = name: content: pkgs.writeText name (toProperties (lib.recursiveUpdate (before "service") (lib.recursiveUpdate content (after "service"))));
102 cfg = config.myServices.chatonsProperties;
103 mergedServices = lib.foldr (v: o: lib.recursiveUpdate o v) {} (lib.mapAttrsToList (k: v: if (v.config.myServices or {}) ? "chatonsProperties" then v.config.myServices.chatonsProperties.services else {}) nodes);
104 mergedHostings = lib.foldr (v: o: lib.recursiveUpdate o v) {} (lib.mapAttrsToList (k: v: if (v.config.myServices or {}) ? "chatonsProperties" then v.config.myServices.chatonsProperties.hostings else {}) nodes);
107 environment.nixosModule
109 options.myServices.chatonsProperties.organization = lib.mkOption {
110 type = lib.types.attrsOf lib.types.unspecified;
113 nested attrs of strings or arrays of strings
116 options.myServices.chatonsProperties.services = lib.mkOption {
117 type = lib.types.attrsOf lib.types.unspecified;
120 nested attrs of strings or arrays of strings
123 options.myServices.chatonsProperties.hostings = lib.mkOption {
124 type = lib.types.attrsOf lib.types.unspecified;
127 nested attrs of strings or arrays of strings
130 options.myServices.chatonsProperties.propertiesPath = lib.mkOption {
131 type = lib.types.package;
133 default = pkgs.runCommand "chatons" {} ''
135 cp ${toOrganizationProperties "immae-eu"} $out/immae-eu.properties
136 ${builtins.concatStringsSep "\n" (lib.mapAttrsToList (n: c: "cp ${toHostingProperties n c} $out/hosting-${n}.properties") mergedHostings)}
137 ${builtins.concatStringsSep "\n" (lib.mapAttrsToList (n: c: "cp ${toServiceProperties n c} $out/service-${n}.properties") mergedServices)}