oizys/modules/runes/default.nix

72 lines
1.4 KiB
Nix
Raw Normal View History

2024-01-28 23:19:30 -06:00
{
2024-05-06 15:30:10 -05:00
pkgs,
config,
lib,
...
}:
let
inherit (lib)
types
2024-05-06 15:49:11 -05:00
mkMerge
2024-05-06 15:30:10 -05:00
mkOption
mkIf
mkEnableOption
;
runes = {
othalan = import ./othalan.nix;
algiz = import ./algiz.nix;
mannaz = import ./mannaz.nix;
2024-05-27 14:58:45 -05:00
naudiz = import ./naudiz.nix;
2024-05-06 15:30:10 -05:00
};
mkRune =
{
2024-05-06 15:49:11 -05:00
name,
2024-05-06 15:30:10 -05:00
number ? "6",
2024-05-06 15:49:11 -05:00
kind ? "braille",
2024-05-06 15:30:10 -05:00
}:
2024-05-06 15:49:11 -05:00
"[1;3${number}m\n" + runes.${name}.${kind} + "\n";
2024-05-06 15:30:10 -05:00
cfg = config.oizys.rune;
in
{
options.oizys = {
rune = {
enable = mkOption {
type = types.bool;
default = true;
};
motd.enable = mkEnableOption "set rune for MOTD";
name = mkOption {
default = config.networking.hostName;
type = types.either (types.enum (builtins.attrNames runes)) types.str;
description = "Name of rune (probabaly matches hostname)";
};
kind = mkOption {
type =
with types;
either (enum [
"ascii"
"braille"
]) str;
default = "ascii";
};
};
};
2024-05-06 15:49:11 -05:00
config = mkMerge [
(mkIf cfg.enable {
2024-05-06 15:30:10 -05:00
environment.etc.issue = {
source = pkgs.writeText "issue" (mkRune {
2024-05-06 15:49:11 -05:00
name = cfg.name;
kind = cfg.kind;
2024-05-06 15:30:10 -05:00
});
};
2024-05-06 15:49:11 -05:00
})
(mkIf cfg.motd.enable {
2024-05-06 15:30:10 -05:00
users.motd = mkRune {
number = "2"; # todo: autogenerate based on hostname?
2024-05-06 15:49:11 -05:00
name = cfg.name;
2024-05-06 15:30:10 -05:00
};
2024-05-06 15:49:11 -05:00
})
];
2024-01-28 23:19:30 -06:00
}