Skip to content

Commit e7dd2a3

Browse files
imincikeljamm
andauthored
Update project metadata template (ngi-nix#588)
Co-authored-by: eljamm <[email protected]>
1 parent 2d9913f commit e7dd2a3

File tree

9 files changed

+121
-38
lines changed

9 files changed

+121
-38
lines changed

templates/project/default.nix

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,79 @@
33
pkgs,
44
sources,
55
}@args:
6+
67
{
78
# NOTE:
8-
# - Check `projects/models.nix` for a more detailed project structure
99
# - Each program/service must have at least one example
1010
# - Set attributes to `null` to indicate that they're needed, but not available
1111
metadata = {
12-
summary = "";
12+
summary = "Short summary that describes the project";
1313
subgrants = [
14-
"FooBar"
15-
"FooBar-cli"
14+
# 1. Navigate to the [NLnet project list](https://nlnet.nl/project/)
15+
# 2. Enter the project name in the search bar
16+
# 3. Review all the entries returned by the search
17+
# 4. Collect the links to entries that relate to the project
18+
#
19+
# For example, for a project called `Foobar`, this can be something like:
20+
#
21+
# - https://nlnet.nl/project/Foobar
22+
# - https://nlnet.nl/project/Foobar-mobile
23+
#
24+
# The subgrants will then be:
25+
#
26+
"Foobar"
27+
"Foobar-mobile"
1628
];
1729
};
1830

31+
# NOTE: Replace `_programName_` with the actual program name
1932
nixos.modules.programs = {
20-
foobar = {
21-
name = "foobar";
22-
module = ./module.nix;
23-
examples.foobar = {
24-
module = ./example.nix;
33+
_programName_ = {
34+
name = "program name";
35+
module = ./programs/_programName_/module.nix;
36+
examples.basic = {
37+
module = ./programs/_programName_/examples/basic.nix;
2538
description = "";
26-
tests.basic = ./test.nix;
39+
tests.basic = ./programs/_programName_/tests/basic.nix;
2740
};
41+
# Add relevant links to the program, for example:
2842
links = {
2943
build = {
30-
text = "FooBar Documentation";
31-
url = "https://foo.bar/build";
44+
text = "Build from source";
45+
url = "<URL>";
3246
};
3347
test = {
34-
text = "FooBar Documentation";
35-
url = "https://foo.bar/test";
48+
text = "Test instructions";
49+
url = "<URL>";
3650
};
3751
};
3852
};
3953

40-
# needed, but not available
54+
# Needed, but not available
4155
foobar-cli = null;
4256
};
4357

44-
# NOTE: same structure as programs
58+
# NOTE: Replace `_serviceName_` with the actual service name
4559
nixos.modules.services = {
60+
_serviceName_ = {
61+
name = "service name";
62+
module = ./services/_serviceName_/module.nix;
63+
examples.basic = {
64+
module = ./services/_serviceName_/examples/basic.nix;
65+
description = "";
66+
tests.basic = ./services/_serviceName_/tests/basic.nix;
67+
};
68+
# Add relevant links to the service, for example:
69+
links = {
70+
build = {
71+
text = "Build from source";
72+
url = "<URL>";
73+
};
74+
test = {
75+
text = "Test instructions";
76+
url = "<URL>";
77+
};
78+
};
79+
};
4680
};
4781
}

templates/project/example.nix

Lines changed: 0 additions & 4 deletions
This file was deleted.

templates/project/module.nix

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{ ... }:
2+
3+
{
4+
services._programName_.enable = true;
5+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
config,
3+
lib,
4+
pkgs,
5+
...
6+
}:
7+
let
8+
cfg = config.programs._programName_;
9+
in
10+
{
11+
options.programs._programName_ = {
12+
enable = lib.mkEnableOption "program name";
13+
};
14+
}

templates/project/test.nix renamed to templates/project/programs/_programName_/tests/basic.nix

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
sources,
33
...
44
}:
5+
56
{
6-
name = "foobar";
7+
name = "Program Name";
78

89
nodes = {
910
machine =
1011
{ ... }:
1112
{
1213
imports = [
1314
sources.modules.ngipkgs
14-
sources.modules.programs.foobar
15-
sources.examples.Foobar.foobar
15+
sources.modules.services._programName_
16+
sources.examples._ProjectName_._programName_
1617
];
1718
};
1819
};
@@ -22,6 +23,6 @@
2223
''
2324
start_all()
2425
25-
machine.succeed("foobar --help")
26+
machine.succeed()
2627
'';
2728
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{ ... }:
2+
3+
{
4+
services._serviceName_.enable = true;
5+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
config,
3+
lib,
4+
pkgs,
5+
...
6+
}:
7+
let
8+
cfg = config.services._serviceName_;
9+
in
10+
{
11+
options.services._serviceName_ = {
12+
enable = lib.mkEnableOption "service name";
13+
};
14+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
sources,
3+
...
4+
}:
5+
6+
{
7+
name = "Service Name";
8+
9+
nodes = {
10+
machine =
11+
{ ... }:
12+
{
13+
imports = [
14+
sources.modules.ngipkgs
15+
sources.modules.services._serviceName_
16+
sources.examples._ProjectName_._serviceName_
17+
];
18+
};
19+
};
20+
21+
testScript =
22+
{ nodes, ... }:
23+
''
24+
start_all()
25+
26+
machine.succeed()
27+
'';
28+
}

0 commit comments

Comments
 (0)