Add customization home-manager modules

This commit is contained in:
GHOSCHT 2023-12-27 22:49:54 +01:00
parent e27ad55ae9
commit f5044e4d8d
Signed by: ghoscht
GPG key ID: 2C2C1C62A5388E82
4 changed files with 108 additions and 1 deletions

View file

@ -2,5 +2,7 @@
# These should be stuff you would like to share with others, not your personal configurations.
{
# List your module files here
# my-module = import ./my-module.nix;
fonts = import ./fonts.nix;
monitors = import ./monitors.nix;
wallpaper = import ./wallpaper.nix;
}

View file

@ -0,0 +1,32 @@
{
lib,
config,
...
}: let
mkFontOption = kind: {
family = lib.mkOption {
type = lib.types.str;
default = null;
description = "Family name for ${kind} font profile";
example = "Fira Code";
};
package = lib.mkOption {
type = lib.types.package;
default = null;
description = "Package for ${kind} font profile";
example = "pkgs.fira-code";
};
};
cfg = config.fontProfiles;
in {
options.fontProfiles = {
enable = lib.mkEnableOption "Whether to enable font profiles";
monospace = mkFontOption "monospace";
regular = mkFontOption "regular";
};
config = lib.mkIf cfg.enable {
fonts.fontconfig.enable = true;
home.packages = [cfg.monospace.package cfg.regular.package];
};
}

View file

@ -0,0 +1,62 @@
{
lib,
config,
...
}: let
inherit (lib) mkOption types;
cfg = config.monitors;
in {
options.monitors = mkOption {
type = types.listOf (types.submodule {
options = {
name = mkOption {
type = types.str;
example = "DP-1";
};
primary = mkOption {
type = types.bool;
default = false;
};
width = mkOption {
type = types.int;
example = 1920;
};
height = mkOption {
type = types.int;
example = 1080;
};
refreshRate = mkOption {
type = types.int;
default = 60;
};
x = mkOption {
type = types.int;
default = 0;
};
y = mkOption {
type = types.int;
default = 0;
};
enabled = mkOption {
type = types.bool;
default = true;
};
workspace = mkOption {
type = types.nullOr types.str;
default = null;
};
};
});
default = [];
};
config = {
assertions = [
{
assertion =
((lib.length config.monitors) != 0)
-> ((lib.length (lib.filter (m: m.primary) config.monitors)) == 1);
message = "Exactly one monitor must be set to primary.";
}
];
};
}

View file

@ -0,0 +1,11 @@
{lib, ...}: let
inherit (lib) types mkOption;
in {
options.wallpaper = mkOption {
type = types.path;
default = "";
description = ''
Wallpaper path
'';
};
}