Skip to content

Commit

Permalink
configurations -> examples (#258)
Browse files Browse the repository at this point in the history
* configurations -> examples

configurations are a legacy name, these really are examples for
consumer-facing documentation.
  • Loading branch information
fricklerhandwerk authored Jun 6, 2024
1 parent b877abc commit 0743234
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 24 deletions.
10 changes: 5 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,18 @@
importNgiProjects = {
pkgs ? {},
sources ? {
configurations = rawNixosConfigurations;
examples = rawExamples;
modules = extendedNixosModules;
},
}:
import ./projects {inherit lib pkgs sources;};

# The above definition reimports `rawNixosConfigurations` and `extendedNixosModules` into `sources`.
# The above definition reimports `rawExamples` and `extendedNixosModules` into `sources`.
# As configurations and modules are system-agnostic, they are defined by passing `{}` to `importNgiProjects`.
rawNgiProjects = importNgiProjects {};

rawNixosConfigurations = flattenAttrsSlash (mapAttrs (_: v: mapAttrs (_: v: v.path) v) (
mapAttrByPath ["nixos" "configurations"] {} rawNgiProjects
rawExamples = flattenAttrsSlash (mapAttrs (_: v: mapAttrs (_: v: v.path) v) (
mapAttrByPath ["nixos" "examples"] {} rawNgiProjects
));

rawNixosModules = flattenAttrsDot (lib.foldl recursiveUpdate {} (attrValues (
Expand All @@ -107,7 +107,7 @@
extendedNixosConfigurations =
mapAttrs
(_: config: nixosSystem {modules = [config ./dummy.nix] ++ attrValues extendedNixosModules;})
rawNixosConfigurations;
rawExamples;

# Then, define the system-specific outputs.
eachDefaultSystemOutputs = flake-utils.lib.eachDefaultSystem (system: let
Expand Down
20 changes: 10 additions & 10 deletions overview/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
filter
(option: any ((flip hasPrefix) (dottedLoc option)) spec)
(attrValues options);
configurations = project: attrValues (project.nixos.configurations or {});
examples = project: attrValues (project.nixos.examples or {});
packages = project: attrValues (project.packages or {});
};

Expand Down Expand Up @@ -113,20 +113,20 @@
'';
};

configurations = rec {
one = configuration: ''
examples = rec {
one = example: ''
<li>
<p>${configuration.description}</p>
<p>${example.description}</p>
```nix
${readFile configuration.path}
${readFile example.path}
```
</li>
'';
many = configurations:
optionalString (!empty configurations)
many = examples:
optionalString (!empty examples)
''
<section><details><summary>${heading 3 "Configurations"}</summary><ul>
${concatLines (map one configurations)}
<section><details><summary>${heading 3 "Examples"}</summary><ul>
${concatLines (map one examples)}
</ul></details></section>
'';
};
Expand All @@ -138,7 +138,7 @@
${render.packages.many (pick.packages project)}
${render.options.many (pick.options project)}
${render.configurations.many (pick.configurations project)}
${render.examples.many (pick.examples project)}
</details></section>
'';
many = projects: concatLines (mapAttrsToList one projects);
Expand Down
4 changes: 2 additions & 2 deletions projects/Kbin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
packages = {inherit (pkgs) kbin kbin-frontend kbin-backend;};
nixos = {
modules.services.kbin = ./service.nix;
configurations = {
examples = {
base = {
path = ./configuration.nix;
path = ./example.nix;
description = "Basic configuration, mainly used for testing purposes.";
};
};
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion projects/Kbin/test.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ in {
sources.modules.default
sources.modules."services.kbin"
sources.modules.unbootable
sources.configurations."Kbin/base"
sources.examples."Kbin/base"
];

unbootable = mkForce false;
Expand Down
8 changes: 4 additions & 4 deletions projects/Pretalx/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@
nixos = {
modules.services.ngi-pretalx = ./service.nix;
tests.pretalx = import ./test args;
configurations = {
examples = {
base = {
path = ./config/base.nix;
path = ./examples/base.nix;
description = ''
Basic configuration for Pretalx, incl. secret management with SOPS, excl. database settings.
'';
};
postgresql = {
path = ./config/postgresql.nix;
path = ./examples/postgresql.nix;
description = ''
Supplementary to `base.nix`, adds database configuration for PostgreSQL.
'';
};
mysql = {
path = ./config/mysql.nix;
path = ./examples/mysql.nix;
description = ''
Supplementary to `base.nix`, adds database configuration for MySQL.
'';
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions projects/Pretalx/test/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ in {
...
}: {
imports = [
sources.configurations."Pretalx/base"
sources.configurations."Pretalx/postgresql"
sources.examples."Pretalx/base"
sources.examples."Pretalx/postgresql"
sources.modules.default
sources.modules."services.ngi-pretalx"
sources.modules.sops-nix
Expand Down

0 comments on commit 0743234

Please sign in to comment.