Move colors and machinevars into modules
This commit is contained in:
72
modules/colors.nix
Normal file
72
modules/colors.nix
Normal file
@@ -0,0 +1,72 @@
|
||||
{ pkgs, lib, config, ... }:
|
||||
let
|
||||
cfg = config.colors;
|
||||
inherit (lib) types mkOption;
|
||||
in {
|
||||
options.colors = let
|
||||
colorType = types.str;
|
||||
|
||||
mkColorOption = mkOption {
|
||||
# name =
|
||||
type = colorType;
|
||||
};
|
||||
|
||||
colorSetType = types.submodule ({ name, ... }: {
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
default = name;
|
||||
};
|
||||
foreground = mkColorOption;
|
||||
background = mkColorOption;
|
||||
black = mkColorOption;
|
||||
red = mkColorOption;
|
||||
green = mkColorOption;
|
||||
yellow = mkColorOption;
|
||||
blue = mkColorOption;
|
||||
magenta = mkColorOption;
|
||||
cyan = mkColorOption;
|
||||
white = mkColorOption;
|
||||
});
|
||||
|
||||
in {
|
||||
colorSets = mkOption {
|
||||
type = types.attrsof colorSetType;
|
||||
};
|
||||
defaultColorSet = mkOption {
|
||||
description = "the default color to use for applications";
|
||||
type = colorSetType;
|
||||
default = cfg.color.colorSets.monokai;
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
colors.colorSets = {
|
||||
monokai = rec {
|
||||
foreground = white;
|
||||
background = black;
|
||||
black = "#272822";
|
||||
red = "#f92672";
|
||||
green = "#a6e22e";
|
||||
yellow = "#f4bf75";
|
||||
blue = "#66d9ef";
|
||||
magenta = "#ae81ff";
|
||||
cyan = "#a1efe4";
|
||||
white = "#f8f8f2";
|
||||
};
|
||||
|
||||
paper = {
|
||||
background = "#f2e3bd";
|
||||
foreground = "#2f343f";
|
||||
black = "#222222";
|
||||
red = "#C30771";
|
||||
green = "#10A778";
|
||||
yellow = "#A89C14";
|
||||
blue = "#008ec4";
|
||||
magenta = "#523C79";
|
||||
cyan = "#20A5BA";
|
||||
white = "#f7f3ee";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
7
modules/default.nix
Normal file
7
modules/default.nix
Normal file
@@ -0,0 +1,7 @@
|
||||
{ ... }:
|
||||
{
|
||||
imports = [
|
||||
./colors.nix
|
||||
./machineVars.nix
|
||||
];
|
||||
}
|
72
modules/machineVars.nix
Normal file
72
modules/machineVars.nix
Normal file
@@ -0,0 +1,72 @@
|
||||
{ pkgs, config, ... }:
|
||||
let
|
||||
inherit (pkgs) lib;
|
||||
inherit (lib) types mkEnableOption mkOption mkIf;
|
||||
cfg = config.machineVars;
|
||||
in {
|
||||
options.machineVars = {
|
||||
headless = mkEnableOption "Whether or not the machine should have graphical output.";
|
||||
|
||||
screens = mkOption {
|
||||
type = types.attrsOf (types.submodule ( { name, ...}: {
|
||||
options = {
|
||||
resolution = mkOption {
|
||||
type = types.str;
|
||||
example = "1920x1080";
|
||||
description = "The resolution of the screen";
|
||||
};
|
||||
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
default = name;
|
||||
example = "DP-1";
|
||||
description = "The name of the screen";
|
||||
};
|
||||
|
||||
freq = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
example = "60.00";
|
||||
description = "The update frequency of the screen, defined in Hz";
|
||||
};
|
||||
};
|
||||
}));
|
||||
default = { };
|
||||
description = "A detailed description of the machines screens.";
|
||||
};
|
||||
|
||||
gaming = mkEnableOption "Whether or not the machine should have gaming software installed.";
|
||||
development = mkEnableOption "Whether or not the machine should come with developmen
|
||||
t tools preinstalled.";
|
||||
creative = mkEnableOption "Whether or not the machine should have creative software
|
||||
(music, video and image editing) installed.";
|
||||
|
||||
laptop = mkEnableOption "Whether the machine is a laptop";
|
||||
|
||||
fixDisplayCommand = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
assertions = [
|
||||
{
|
||||
assertion = cfg.headless -> !cfg.creative;
|
||||
message = "A headless machine can't have creative software installed.";
|
||||
}
|
||||
{
|
||||
assertion = cfg.headless -> !cfg.gaming;
|
||||
message = "A headless machine can't have gaming software installed.";
|
||||
}
|
||||
{
|
||||
assertion = cfg.headless -> (cfg.screens == { } && cfg.fixDisplayCommand == null);
|
||||
message = "A headless machine can't have any screens.";
|
||||
}
|
||||
];
|
||||
|
||||
warnings = lib.optionals (0 < (lib.length (builtins.attrNames cfg.screens)) && (cfg.fixDisplayCommand != null)) [
|
||||
"You are overriding the fixDisplayCommand even though machineVars.screens is defined. One of these should be omitted"
|
||||
];
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user