-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Janik-Haag/develop
add service template things
- Loading branch information
Showing
6 changed files
with
88 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ utils }: { lib, ... }: | ||
{ | ||
imports = [ | ||
./service-template.nix | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ config, lib, utils }: | ||
{ | ||
options = { | ||
nixbox = { | ||
serviceTemplate = lib.types.attrsOf (lib.types.submodule { | ||
options = { | ||
name = lib.mkOption { | ||
description = '' | ||
A service or protocol name. | ||
''; | ||
type = lib.types.str; | ||
example = "https"; | ||
}; | ||
protocol = lib.mkOption { | ||
description = '' | ||
The wire protocol on which the service runs. | ||
''; | ||
type = lib.types.enum [ "tcp" "udp" "sctp" ]; | ||
example = "tcp"; | ||
}; | ||
ports = lib.mkOption { | ||
description = '' | ||
One or more numeric ports to which the service is bound. Multiple ports can be expressed using lists and `utils.networking.portrange`. | ||
''; | ||
type = lib.types.listOf lib.types.int; | ||
example = [ 443 ]; | ||
}; | ||
}; | ||
}); | ||
servicePrests = { }; | ||
}; | ||
}; | ||
config = { | ||
nixbox = { }; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ lib }: | ||
let | ||
utils = lib.makeExtensible (self: | ||
let | ||
callUtils = file: import file { inherit lib; utils = self; }; | ||
in | ||
{ | ||
networking = callUtils ./networking.nix; | ||
}); | ||
in | ||
utils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ lib, ... }: { | ||
networking = { | ||
/* | ||
Generates inclusive portrange given a lower and a higher number | ||
Type: | ||
utils.networking.portrange:: Int -> Int -> [ Int ] | ||
*/ | ||
portrange = | ||
from: | ||
to: | ||
let | ||
helper = input: | ||
if input.counter >= 0 then | ||
helper | ||
{ | ||
list = [ (from + input.counter) ] ++ input.list; | ||
counter = input.counter - 1; | ||
} else input.list; | ||
in | ||
lib.throwIf (from > to) "the second input has to be larger then the first one, otherwise you have a negative range which is impossible or not a range." | ||
helper | ||
{ list = [ ]; counter = (to - from); } | ||
; | ||
}; | ||
} |