Reformat with nixfmt
This commit is contained in:
parent
3aab6ab23a
commit
8441081b6b
11 changed files with 837 additions and 674 deletions
|
|
@ -1,6 +1,7 @@
|
|||
{ lib
|
||||
, pkgs
|
||||
, ...
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
{
|
||||
options = {
|
||||
|
|
@ -18,99 +19,108 @@
|
|||
Set of files that have to be linked in {file}`/etc`.
|
||||
'';
|
||||
|
||||
type = lib.types.attrsOf (lib.types.submodule (
|
||||
{ name, config, options, ... }:
|
||||
{
|
||||
options = {
|
||||
type = lib.types.attrsOf (
|
||||
lib.types.submodule (
|
||||
{
|
||||
name,
|
||||
config,
|
||||
options,
|
||||
...
|
||||
}:
|
||||
{
|
||||
options = {
|
||||
|
||||
enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = lib.mdDoc ''
|
||||
Whether this /etc file should be generated. This
|
||||
option allows specific /etc files to be disabled.
|
||||
'';
|
||||
enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = lib.mdDoc ''
|
||||
Whether this /etc file should be generated. This
|
||||
option allows specific /etc files to be disabled.
|
||||
'';
|
||||
};
|
||||
|
||||
target = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = lib.mdDoc ''
|
||||
Name of symlink (relative to
|
||||
{file}`/etc`). Defaults to the attribute
|
||||
name.
|
||||
'';
|
||||
};
|
||||
|
||||
text = lib.mkOption {
|
||||
default = null;
|
||||
type = lib.types.nullOr lib.types.lines;
|
||||
description = lib.mdDoc "Text of the file.";
|
||||
};
|
||||
|
||||
source = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
description = lib.mdDoc "Path of the source file.";
|
||||
};
|
||||
|
||||
mode = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "symlink";
|
||||
example = "0600";
|
||||
description = lib.mdDoc ''
|
||||
If set to something else than `symlink`,
|
||||
the file is copied instead of symlinked, with the given
|
||||
file mode.
|
||||
'';
|
||||
};
|
||||
|
||||
uid = lib.mkOption {
|
||||
default = 0;
|
||||
type = lib.types.int;
|
||||
description = lib.mdDoc ''
|
||||
UID of created file. Only takes effect when the file is
|
||||
copied (that is, the mode is not 'symlink').
|
||||
'';
|
||||
};
|
||||
|
||||
gid = lib.mkOption {
|
||||
default = 0;
|
||||
type = lib.types.int;
|
||||
description = lib.mdDoc ''
|
||||
GID of created file. Only takes effect when the file is
|
||||
copied (that is, the mode is not 'symlink').
|
||||
'';
|
||||
};
|
||||
|
||||
user = lib.mkOption {
|
||||
default = "+${toString config.uid}";
|
||||
type = lib.types.str;
|
||||
description = lib.mdDoc ''
|
||||
User name of created file.
|
||||
Only takes effect when the file is copied (that is, the mode is not 'symlink').
|
||||
Changing this option takes precedence over `uid`.
|
||||
'';
|
||||
};
|
||||
|
||||
group = lib.mkOption {
|
||||
default = "+${toString config.gid}";
|
||||
type = lib.types.str;
|
||||
description = lib.mdDoc ''
|
||||
Group name of created file.
|
||||
Only takes effect when the file is copied (that is, the mode is not 'symlink').
|
||||
Changing this option takes precedence over `gid`.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
target = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = lib.mdDoc ''
|
||||
Name of symlink (relative to
|
||||
{file}`/etc`). Defaults to the attribute
|
||||
name.
|
||||
'';
|
||||
config = {
|
||||
target = lib.mkDefault name;
|
||||
source = lib.mkIf (config.text != null) (
|
||||
let
|
||||
name' = "etc-" + baseNameOf name;
|
||||
in
|
||||
lib.mkDerivedConfig options.text (pkgs.writeText name')
|
||||
);
|
||||
};
|
||||
|
||||
text = lib.mkOption {
|
||||
default = null;
|
||||
type = lib.types.nullOr lib.types.lines;
|
||||
description = lib.mdDoc "Text of the file.";
|
||||
};
|
||||
|
||||
source = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
description = lib.mdDoc "Path of the source file.";
|
||||
};
|
||||
|
||||
mode = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "symlink";
|
||||
example = "0600";
|
||||
description = lib.mdDoc ''
|
||||
If set to something else than `symlink`,
|
||||
the file is copied instead of symlinked, with the given
|
||||
file mode.
|
||||
'';
|
||||
};
|
||||
|
||||
uid = lib.mkOption {
|
||||
default = 0;
|
||||
type = lib.types.int;
|
||||
description = lib.mdDoc ''
|
||||
UID of created file. Only takes effect when the file is
|
||||
copied (that is, the mode is not 'symlink').
|
||||
'';
|
||||
};
|
||||
|
||||
gid = lib.mkOption {
|
||||
default = 0;
|
||||
type = lib.types.int;
|
||||
description = lib.mdDoc ''
|
||||
GID of created file. Only takes effect when the file is
|
||||
copied (that is, the mode is not 'symlink').
|
||||
'';
|
||||
};
|
||||
|
||||
user = lib.mkOption {
|
||||
default = "+${toString config.uid}";
|
||||
type = lib.types.str;
|
||||
description = lib.mdDoc ''
|
||||
User name of created file.
|
||||
Only takes effect when the file is copied (that is, the mode is not 'symlink').
|
||||
Changing this option takes precedence over `uid`.
|
||||
'';
|
||||
};
|
||||
|
||||
group = lib.mkOption {
|
||||
default = "+${toString config.gid}";
|
||||
type = lib.types.str;
|
||||
description = lib.mdDoc ''
|
||||
Group name of created file.
|
||||
Only takes effect when the file is copied (that is, the mode is not 'symlink').
|
||||
Changing this option takes precedence over `gid`.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
target = lib.mkDefault name;
|
||||
source = lib.mkIf (config.text != null) (
|
||||
let name' = "etc-" + baseNameOf name;
|
||||
in lib.mkDerivedConfig options.text (pkgs.writeText name')
|
||||
);
|
||||
};
|
||||
}
|
||||
));
|
||||
}
|
||||
)
|
||||
);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue