beginning of big refactoring

This commit is contained in:
Charlie Root 2024-07-20 13:18:01 +02:00
commit 7d73d14ea5
68 changed files with 358 additions and 2818 deletions

View file

@ -0,0 +1,118 @@
{
config,
lib,
...
}: let
inherit (builtins) elemAt;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.modules) mkMerge;
inherit (lib.lists) optionals;
inherit (lib.types) enum listOf str nullOr bool package;
in {
imports = [
# configuration options for nixos activation scripts
# ./activation.nix
# boot/impermanence mounts
# ./boot.nix
# ./impermanence.nix
# network and overall hardening
./networking
# ./security.nix
# ./encryption.nix
# filesystems
# ./fs.nix
# emulation and virtualization
# ./emulation.nix
# ./virtualization.nix
# package and program related options
# ./services
./programs
# systemd-nspawn containers
# ./containers.nix
];
config = {
warnings = mkMerge [
(optionals (config.modules.system.users == []) [
''
You have not added any users to be supported by your system. You may end up with an unbootable system!
Consider setting {option}`config.modules.system.users` in your configuration
''
])
];
};
options.modules.system = {
mainUser = mkOption {
type = enum config.modules.system.users;
default = elemAt config.modules.system.users 0;
description = ''
The username of the main user for your system.
In case of a multiple systems, this will be the user with priority in ordered lists and enabled options.
'';
};
users = mkOption {
type = listOf str;
default = ["charlie"];
description = "A list of home-manager users on the system.";
};
autoLogin = mkOption {
type = bool;
default = false;
description = ''
Whether to enable passwordless login. This is generally useful on systems with
FDE (Full Disk Encryption) enabled. It is a security risk for systems without FDE.
'';
};
yubikeySupport = {
enable = mkEnableOption "yubikey support";
deviceType = mkOption {
type = nullOr (enum ["NFC5" "nano"]);
default = null;
description = "A list of device models to enable Yubikey support for";
};
};
sound = {
enable = mkEnableOption "sound related programs and audio-dependent programs";
};
video = {
enable = mkEnableOption "video drivers and programs that require a graphical user interface";
};
bluetooth = {
enable = mkEnableOption "bluetooth modules, drivers and configuration program(s)";
};
# should the device enable printing module and try to load common printer modules
# you might need to add more drivers to the printing module for your printer to work
printing = {
enable = mkEnableOption "printing";
extraDrivers = mkOption {
type = listOf str;
default = [];
description = "A list of extra drivers to enable for printing";
};
"3d" = {
enable = mkEnableOption "3D printing suite";
extraPrograms = mkOption {
type = listOf package;
default = [];
description = "A list of extra programs to enable for 3D printing";
};
};
};
};
}

View file

@ -0,0 +1,7 @@
{lib, ...}: let
inherit (lib) mkEnableOption mkOption types;
in {
options.modules.system.networking = {
nftbles.enable = mkEnableOption "Nftables firewall";
};
}

View file

@ -0,0 +1,53 @@
{lib, ...}: let
inherit (lib) mkEnableOption mkOption types;
in {
options.modules.system.programs = {
editors = {
emacs.enable = mkEnableOption "Emacs operatig system";
neovim.enable = mkEnableOption "Neovim text editor";
helix.enable = mkEnableOption "Helix text editor";
kakoune.enable = mkEnableOption "Kakoune text editor";
};
discord.enable = mkEnableOption "Discord messenger";
spotify.enable = mkEnableOption "Spotify music client";
zathura.enable = mkEnableOption "Zathura pdf viewer";
nextcloud.enable = mkEnableOption "Nextcloud sync client";
firefox.enable = mkEnableOption "Firefox web browser";
terminals = {
foot.enable = mkEnableOption "Foot terminal emulator";
kitty.enable = mkEnableOption "Kitty terminal emulator";
};
git = {
signingKey = mkOption {
type = types.str;
default = "";
description = "The default gpg key used for signing commits";
};
};
default = {
terminal = mkOption {
type = types.enum ["foot" "kitty"];
default = "foot";
};
fileManager = mkOption {
type = types.enum ["thunar" "dolphin" "nemo"];
default = "thunar";
};
browser = mkOption {
type = types.enum ["firefox" "librewolf" "chromium"];
default = "firefox";
};
editor = mkOption {
type = types.enum ["neovim" "helix" "emacs"];
default = "emacs";
};
launcher = mkOption {
type = types.enum ["anyrun" "rofi" "wofi"];
default = "anyrun";
};
};
};
}

View file

@ -0,0 +1,77 @@
{
inputs,
config,
pkgs,
lib,
...
}: let
cfg = config.modules.usrEnv;
inherit (lib.options) mkOption;
inherit (lib.types) bool enum package;
in {
options.modules.usrEnv = {
desktop = mkOption {
type = enum ["none" "Hyprland" "sway" "awesomewm" "i3"];
default = "none";
description = ''
The desktop environment to be used.
'';
};
desktops = {
hyprland = {
enable = mkOption {
type = bool;
default = cfg.desktop == "Hyprland";
description = ''
Whether to enable Hyprland wayland compositor.
Will be enabled automatically when `modules.usrEnv.desktop`
is set to "Hyprland".
'';
};
package = mkOption {
type = package;
default = inputs.hyprland.packages.${pkgs.system}.hyprland;
description = ''
The Hyprland package to be used.
'';
};
};
awesomwm.enable = mkOption {
type = bool;
default = cfg.desktop == "awesomewm";
description = ''
Whether to enable Awesome window manager
Will be enabled automatically when `modules.usrEnv.desktop`
is set to "awesomewm".
'';
};
i3 = {
enable = mkOption {
type = bool;
default = cfg.desktop == "i3";
description = ''
Whether to enable i3 window manager
Will be enabled automatically when `modules.usrEnv.desktop`
is set to "i3".
'';
};
package = mkOption {
type = package;
default = pkgs.i3;
description = ''
The i3 package to be used.
'';
};
};
};
};
}

View file

@ -0,0 +1,9 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption;
in {
options.modules.usrEnv.programs.launchers = {
anyrun.enable = mkEnableOption "anyrun application launcher";
rofi.enable = mkEnableOption "rofi application launcher";
tofi.enable = mkEnableOption "tofi application launcher";
};
}

View file

@ -0,0 +1,60 @@
{
config,
pkgs,
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) bool listOf package;
in {
options.modules.usrEnv.programs.media = {
addDefaultPackages = mkOption {
type = bool;
default = true;
description = ''
Whether to enable the default list of media-related packages ranging from audio taggers
to video editors.
'';
};
extraPackages = mkOption {
type = listOf package;
default = [];
description = ''
Additional packages that will be appended to media related packages.
'';
};
ncmpcpp.enable = mkEnableOption "ncmpcpp TUI music player";
beets.enable =
mkEnableOption ''
beets media library system.
Will be enabled automatically if {option}`config.modules.usrEnv.services.mpd.enabled`
is set to true
''
// {default = config.modules.usrEnv.services.media.mpd.enable;};
mpv = {
enable = mkEnableOption "mpv media player";
scripts = mkOption {
type = listOf package;
description = "A list of MPV scripts that will be enabled";
example = literalExpression ''[ pkgs.mpvScripts.cutter ]'';
default = with pkgs.mpvScripts; [
# from nixpkgs
cutter # cut and automatically concat videos
mpris # MPRIS plugin
thumbnail # OSC seekbar thumbnails
thumbfast # on-the-fly thumbnailer
sponsorblock # skip sponsored segments
uosc # proximity UI
quality-menu # ytdl-format quality menu
seekTo # seek to specific pos.
];
};
};
};
}