Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
Signed-off-by: lucasew <[email protected]>
  • Loading branch information
lucasew committed Jan 8, 2025
1 parent b0192d8 commit 8279bc3
Show file tree
Hide file tree
Showing 109 changed files with 533 additions and 1,517 deletions.
14 changes: 6 additions & 8 deletions lib/tests/modules/merge-module-with-key.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{ lib, ... }:
let
inherit (lib) mkOption types;

moduleWithoutKey = {
config = {
raw = "pear";
Expand All @@ -17,16 +15,16 @@ let

decl = {
options = {
raw = mkOption {
type = types.lines;
raw = lib.mkOption {
type = lib.types.lines;
};
};
};
in
{
options = {
once = mkOption {
type = types.submodule {
once = lib.mkOption {
type = lib.types.submodule {
imports = [
decl
moduleWithKey
Expand All @@ -35,8 +33,8 @@ in
};
default = { };
};
twice = mkOption {
type = types.submodule {
twice = lib.mkOption {
type = lib.types.submodule {
imports = [
decl
moduleWithoutKey
Expand Down
78 changes: 28 additions & 50 deletions nixos/modules/services/networking/hylafax/options.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,6 @@
}:

let

inherit (lib.options) literalExpression mkEnableOption lib.mkOption;
inherit (lib.types)
bool
enum
ints
lines
attrsOf
nonEmptyStr
nullOr
path
str
submodule
;
inherit (lib.modules) mkDefault mkIf mkMerge;

commonDescr = ''
Values can be either strings or integers
(which will be added to the config file verbatimly)
Expand All @@ -40,15 +24,9 @@ let
# This type definition resolves all
# those types into a list of strings.
let
inherit (lib.types)
attrsOf
coercedTo
int
listOf
;
innerType = coercedTo bool (x: if x then "Yes" else "No") (coercedTo int (toString) str);
innerType = lib.types.coercedTo lib.types.bool (x: if x then "Yes" else "No") (lib.types.coercedTo lib.types.int (toString) lib.types.str);
in
attrsOf (coercedTo innerType lib.singleton (listOf innerType));
lib.types.attrsOf (lib.types.coercedTo innerType lib.singleton (lib.types.listOf innerType));

cfg = config.services.hylafax;

Expand All @@ -57,15 +35,15 @@ let
{
options = {
name = lib.mkOption {
type = nonEmptyStr;
type = lib.types.nonEmptyStr;
example = "ttyS1";
description = ''
Name of modem device,
will be searched for in {file}`/dev`.
'';
};
type = lib.mkOption {
type = nonEmptyStr;
type = lib.types.nonEmptyStr;
example = "cirrus";
description = ''
Name of modem configuration file,
Expand Down Expand Up @@ -97,7 +75,7 @@ let
let
inherit (config.security) wrapperDir;
inherit (config.services.mail.sendmailSetuidWrapper) program;
mkIfDefault = cond: value: mkIf cond (mkDefault value);
mkIfDefault = cond: value: lib.mkIf cond (lib.mkDefault value);
noWrapper = config.services.mail.sendmailSetuidWrapper == null;
# If a sendmail setuid wrapper exists,
# we add the path to the default configuration file.
Expand All @@ -108,7 +86,7 @@ let
(lib.mkIfDefault (!noWrapper) "${wrapperDir}/${program}")
];
importDefaultConfig =
file: lib.attrsets.mapAttrs (lib.trivial.const mkDefault) (import file { inherit pkgs; });
file: lib.attrsets.mapAttrs (lib.trivial.const lib.mkDefault) (import file { inherit pkgs; });
c.commonModemConfig = importDefaultConfig ./modem-default.nix;
c.faxqConfig = importDefaultConfig ./faxq-default.nix;
c.hfaxdConfig = importDefaultConfig ./hfaxd-default.nix;
Expand All @@ -118,7 +96,7 @@ let
localConfig =
let
c.hfaxdConfig.UserAccessFile = cfg.userAccessFile;
c.faxqConfig = lib.attrsets.mapAttrs (lib.trivial.const (v: mkIf (v != null) v)) {
c.faxqConfig = lib.attrsets.mapAttrs (lib.trivial.const (v: lib.mkIf (v != null) v)) {
AreaCode = cfg.areaCode;
CountryCode = cfg.countryCode;
LongDistancePrefix = cfg.longDistancePrefix;
Expand All @@ -137,7 +115,7 @@ in
enable = lib.mkEnableOption "HylaFAX server";

autostart = lib.mkOption {
type = bool;
type = lib.bool;
default = true;
example = false;
description = ''
Expand All @@ -149,35 +127,35 @@ in
};

countryCode = lib.mkOption {
type = nullOr nonEmptyStr;
type = lib.types.nullOr lib.types.nonEmptyStr;
default = null;
example = "49";
description = "Country code for server and all modems.";
};

areaCode = lib.mkOption {
type = nullOr nonEmptyStr;
type = lib.types.nullOr lib.types.nonEmptyStr;
default = null;
example = "30";
description = "Area code for server and all modems.";
};

longDistancePrefix = lib.mkOption {
type = nullOr str;
type = lib.types.nullOr lib.types.str;
default = null;
example = "0";
description = "Long distance prefix for server and all modems.";
};

internationalPrefix = lib.mkOption {
type = nullOr str;
type = lib.types.nullOr lib.types.str;
default = null;
example = "00";
description = "International prefix for server and all modems.";
};

spoolAreaPath = lib.mkOption {
type = path;
type = lib.types.path;
default = "/var/spool/fax";
description = ''
The spooling area will be created/maintained
Expand All @@ -186,7 +164,7 @@ in
};

userAccessFile = lib.mkOption {
type = path;
type = lib.types.path;
default = "/etc/hosts.hfaxd";
description = ''
The {file}`hosts.hfaxd`
Expand All @@ -210,7 +188,7 @@ in
};

sendmailPath = lib.mkOption {
type = path;
type = lib.types.path;
example = lib.literalExpression ''"''${pkgs.postfix}/bin/sendmail"'';
# '' ; # fix vim
description = ''
Expand Down Expand Up @@ -261,7 +239,7 @@ in
};

modems = lib.mkOption {
type = attrsOf (submodule [ modemConfigOptions ]);
type = lib.types.attrsOf (lib.types.submodule [ modemConfigOptions ]);
default = { };
example.ttyS1 = {
type = "cirrus";
Expand All @@ -278,7 +256,7 @@ in
};

spoolExtraInit = lib.mkOption {
type = lines;
type = lib.types.lines;
default = "";
example = "chmod 0755 . # everyone may read my faxes";
description = ''
Expand All @@ -287,13 +265,13 @@ in
'';
};

faxcron.enable.spoolInit = mkEnableOption ''
faxcron.enable.spoolInit = lib.mkEnableOption ''
purging old files from the spooling area with
{file}`faxcron`
each time the spooling area is initialized
'';
faxcron.enable.frequency = lib.mkOption {
type = nullOr nonEmptyStr;
type = lib.types.nullOr lib.types.nonEmptyStr;
default = null;
example = "daily";
description = ''
Expand All @@ -303,37 +281,37 @@ in
'';
};
faxcron.infoDays = lib.mkOption {
type = ints.positive;
type = lib.types.ints.positive;
default = 30;
description = ''
Set the expiration time for data in the
remote machine information directory in days.
'';
};
faxcron.logDays = lib.mkOption {
type = ints.positive;
type = lib.types.ints.positive;
default = 30;
description = ''
Set the expiration time for
session trace log files in days.
'';
};
faxcron.rcvDays = lib.mkOption {
type = ints.positive;
type = lib.types.ints.positive;
default = 7;
description = ''
Set the expiration time for files in
the received facsimile queue in days.
'';
};

faxqclean.enable.spoolInit = mkEnableOption ''
faxqclean.enable.spoolInit = lib.mkEnableOption ''
purging old files from the spooling area with
{file}`faxqclean`
each time the spooling area is initialized
'';
faxqclean.enable.frequency = lib.mkOption {
type = nullOr nonEmptyStr;
type = lib.types.nullOr lib.types.nonEmptyStr;
default = null;
example = "daily";
description = ''
Expand All @@ -343,7 +321,7 @@ in
'';
};
faxqclean.archiving = lib.mkOption {
type = enum [
type = lib.types.enum [
"never"
"as-flagged"
"always"
Expand All @@ -360,7 +338,7 @@ in
'';
};
faxqclean.doneqMinutes = lib.mkOption {
type = ints.positive;
type = lib.types.ints.positive;
default = 15;
example = lib.literalExpression "24*60";
description = ''
Expand All @@ -370,7 +348,7 @@ in
'';
};
faxqclean.docqMinutes = lib.mkOption {
type = ints.positive;
type = lib.types.ints.positive;
default = 60;
example = lib.literalExpression "24*60";
description = ''
Expand All @@ -382,7 +360,7 @@ in

};

config.services.hylafax = lib.mkIf (config.services.hylafax.enable) (mkMerge [
config.services.hylafax = lib.mkIf (config.services.hylafax.enable) (lib.mkMerge [
defaultConfig
localConfig
]);
Expand Down
8 changes: 1 addition & 7 deletions nixos/modules/services/networking/solanum.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
}:

let
inherit (lib)
mkEnableOption
mkIf
lib.mkOption
types
;
inherit (pkgs) solanum util-linux;
cfg = config.services.solanum;

Expand Down Expand Up @@ -69,7 +63,7 @@ in
};

motd = lib.mkOption {
type = lib.types.nullOr types.lines;
type = lib.types.nullOr lib.types.lines;
default = null;
description = ''
Solanum MOTD text.
Expand Down
Loading

0 comments on commit 8279bc3

Please sign in to comment.