make use of mkEnableOption

dev-docs
Moritz Böhme 2022-10-15 20:00:09 +02:00
parent a98589b6f8
commit 5c0752b891
Signed by: moritz
GPG Key ID: 970C6E89EB0547A9
43 changed files with 73 additions and 329 deletions

View File

@ -14,13 +14,7 @@ let
sxhkdHelp = import ./sxhkdHelp.nix { inherit pkgs; }; sxhkdHelp = import ./sxhkdHelp.nix { inherit pkgs; };
in in
{ {
options.my.bin = { options.my.bin.enable = mkEnableOption "bin";
enable = mkOption {
default = true;
type = types.bool;
example = false;
};
};
config = mkIf cfg.enable { config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [

View File

@ -11,22 +11,21 @@ let
in in
{ {
options.my.nix = { options.my.nix = {
gc.enable = mkOption { gc = {
default = true; enable = mkEnableOption "nix-gc";
type = types.bool; minimumFreedGB = mkOption {
example = false; default = 32;
type = types.int;
apply = number: toString (number * 1024 * 1024 * 1024);
}; };
optimise.enable = mkOption {
default = true;
type = types.bool;
example = false;
}; };
optimise.enable = mkEnableOption "nix-optimise";
}; };
config.nix = { config.nix = {
gc = { gc = {
automatic = cfg.gc.enable; automatic = cfg.gc.enable;
options = "--max-freed $((32 * 1024**3)) --delete-older-than 14d"; options = "--max-freed ${cfg.gc.minimumFreedGB} --delete-older-than 14d";
dates = "weekly"; dates = "weekly";
}; };

View File

@ -19,11 +19,7 @@ in
]; ];
options.my.theming = { options.my.theming = {
enable = mkOption { enable = mkEnableOption "theming";
default = false;
type = types.bool;
example = true;
};
scheme = mkOption { scheme = mkOption {
default = "catppuccin-macchiato"; default = "catppuccin-macchiato";
type = types.enum [ type = types.enum [

View File

@ -9,13 +9,7 @@ let
cfg = config.my.wallpapers; cfg = config.my.wallpapers;
in in
{ {
options.my.wallpapers = { options.my.wallpapers.enable = mkEnableOption "wallpapers";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = mkIf cfg.enable { config = mkIf cfg.enable {
home-manager.users.moritz.xdg = { home-manager.users.moritz.xdg = {

View File

@ -9,13 +9,7 @@ let
cfg = config.my.yubikey; cfg = config.my.yubikey;
in in
{ {
options.my.yubikey = { options.my.yubikey = mkEnableOption "yubikey";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = { config = {
services.udev.packages = [ pkgs.yubikey-personalization ]; services.udev.packages = [ pkgs.yubikey-personalization ];

View File

@ -22,6 +22,11 @@ with lib;
time.timeZone = "Europe/Berlin"; time.timeZone = "Europe/Berlin";
my = { my = {
nix = {
gc.enable = true;
optimise.enable = true;
};
bin.enable = true;
shell = { shell = {
abbreviations = { abbreviations = {
us = "systemctl --user"; us = "systemctl --user";
@ -43,10 +48,13 @@ with lib;
variables = { EDITOR = "vim"; }; variables = { EDITOR = "vim"; };
}; };
programs = { programs = {
direnv.enable = true;
fish.enable = true; fish.enable = true;
vim.enable = true; git.enable = true;
gpg.enable = true;
helix.enable = true; helix.enable = true;
kakoune.enable = true; kakoune.enable = true;
vim.enable = true;
}; };
}; };
@ -82,7 +90,6 @@ with lib;
entr entr
exa exa
gparted gparted
hub
hut hut
lazygit lazygit
neofetch neofetch

View File

@ -23,7 +23,6 @@ with lib; {
bspwm.enable = true; bspwm.enable = true;
code.enable = true; code.enable = true;
emacs.enable = true; emacs.enable = true;
email.enable = true;
firefox = { firefox = {
enable = true; enable = true;
arkenfox = { arkenfox = {
@ -119,6 +118,7 @@ with lib; {
signal-desktop signal-desktop
tlaplusToolbox tlaplusToolbox
vlc vlc
thunderbird
]; ];
home-manager.users.moritz = { home-manager.users.moritz = {

View File

@ -9,13 +9,7 @@ let
cfg = config.my.programs.adb; cfg = config.my.programs.adb;
in in
{ {
options.my.programs.adb = { options.my.programs.adb.enable = mkEnableOption "adb";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.adb.enable = true; programs.adb.enable = true;

View File

@ -9,13 +9,7 @@ let
cfg = config.my.programs.bspwm; cfg = config.my.programs.bspwm;
in in
{ {
options.my.programs.bspwm = { options.my.programs.bspwm.enable = mkEnableOption "true";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
services = { services = {

View File

@ -9,13 +9,8 @@ let
cfg = config.my.programs.code; cfg = config.my.programs.code;
in in
{ {
options.my.programs.code = { options.my.programs.code.enable = mkEnableOption "code";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = mkIf cfg.enable { config = mkIf cfg.enable {
home-manager.users.moritz = { home-manager.users.moritz = {
programs.vscode = { programs.vscode = {

View File

@ -11,7 +11,6 @@
./code.nix ./code.nix
./direnv.nix ./direnv.nix
./emacs.nix ./emacs.nix
./email.nix
./firefox.nix ./firefox.nix
./fish.nix ./fish.nix
./git.nix ./git.nix

View File

@ -9,13 +9,7 @@ let
cfg = config.my.programs.direnv; cfg = config.my.programs.direnv;
in in
{ {
options.my.programs.direnv = { options.my.programs.direnv.enable = mkEnableOption "direnv";
enable = mkOption {
default = true;
type = types.bool;
example = false;
};
};
config = mkIf cfg.enable { config = mkIf cfg.enable {
home-manager.users.moritz.programs.direnv = { home-manager.users.moritz.programs.direnv = {

View File

@ -12,13 +12,8 @@ let
(epkgs: [ epkgs.vterm ])); (epkgs: [ epkgs.vterm ]));
in in
{ {
options.my.programs.emacs = { options.my.programs.emacs.enable = mkEnableOption "emacs";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = mkIf cfg.enable { config = mkIf cfg.enable {
my.shell.aliases = { my.shell.aliases = {
emacs = "emacsclient -t -a 'emacs -t'"; emacs = "emacsclient -t -a 'emacs -t'";

View File

@ -1,25 +0,0 @@
{ config
, lib
, pkgs
, ...
}:
with lib;
let
cfg = config.my.programs.email;
in
{
options.my.programs.email = {
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = mkIf cfg.enable {
# Email Applications
users.users.moritz.packages = with pkgs; [ thunderbird ];
networking.firewall.allowedTCPPorts = [ 33728 1025 1143 ];
};
}

View File

@ -12,11 +12,7 @@ let
in in
{ {
options.my.programs.firefox = { options.my.programs.firefox = {
enable = mkOption { enable = mkEnableOption "firefox";
default = false;
type = types.bool;
example = true;
};
arkenfox = { arkenfox = {
enable = mkEnableOption "arkenfox"; enable = mkEnableOption "arkenfox";
overrides = mkOption { overrides = mkOption {

View File

@ -14,13 +14,7 @@ let
exportedVariables = lib.concatStringsSep "\n" exportVariables; exportedVariables = lib.concatStringsSep "\n" exportVariables;
in in
{ {
options.my.programs.fish = { options.my.programs.fish.enable = mkEnableOption "fish";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
# set as default shell # set as default shell

View File

@ -10,11 +10,7 @@ let
in in
{ {
options.my.programs.git = { options.my.programs.git = {
enable = mkOption { enable = mkEnableOption "git";
default = true;
type = types.bool;
example = false;
};
signing = mkOption { signing = mkOption {
default = false; default = false;
type = types.bool; type = types.bool;

View File

@ -9,13 +9,7 @@ let
cfg = config.my.programs.gnome; cfg = config.my.programs.gnome;
in in
{ {
options.my.programs.gnome = { options.my.programs.gnome.enable = mkEnableOption "gnome";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
hardware = { hardware = {

View File

@ -9,13 +9,8 @@ let
cfg = config.my.programs.gpg; cfg = config.my.programs.gpg;
in in
{ {
options.my.programs.gpg = { options.my.programs.gpg.enable = mkEnableOption "gpg";
enable = mkOption {
default = true;
type = types.bool;
example = true;
};
};
config = mkIf cfg.enable { config = mkIf cfg.enable {
home-manager.users.moritz.programs.gpg.enable = true; home-manager.users.moritz.programs.gpg.enable = true;
environment.shellInit = '' environment.shellInit = ''

View File

@ -9,13 +9,7 @@ let
cfg = config.my.programs.helix; cfg = config.my.programs.helix;
in in
{ {
options.my.programs.helix = { options.my.programs.helix.enable = mkEnableOption "helix";
enable = mkOption {
default = true;
type = types.bool;
example = false;
};
};
config = mkIf cfg.enable { config = mkIf cfg.enable {
home-manager.users.moritz.programs.helix = { home-manager.users.moritz.programs.helix = {

View File

@ -9,13 +9,8 @@ let
cfg = config.my.programs.hub; cfg = config.my.programs.hub;
in in
{ {
options.my.programs.hub = { options.my.programs.hub.enable = mkEnableOption "hub";
enable = mkOption {
default = true;
type = types.bool;
example = false;
};
};
config = mkIf cfg.enable { config = mkIf cfg.enable {
age.secrets = { age.secrets = {
github = { github = {

View File

@ -9,13 +9,7 @@ let
cfg = config.my.programs.kakoune; cfg = config.my.programs.kakoune;
in in
{ {
options.my.programs.kakoune = { options.my.programs.kakoune.enable = mkEnableOption "kakoune";
enable = mkOption {
default = true;
type = types.bool;
example = false;
};
};
config = mkIf cfg.enable { config = mkIf cfg.enable {
home-manager.users.moritz = { home-manager.users.moritz = {

View File

@ -9,13 +9,7 @@ let
cfg = config.my.programs.kitty; cfg = config.my.programs.kitty;
in in
{ {
options.my.programs.kitty = { options.my.programs.kitty.enable = mkEnableOption "kitty";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = mkIf cfg.enable { config = mkIf cfg.enable {
my.shell.aliases.ssh = "kitty +kitten ssh"; my.shell.aliases.ssh = "kitty +kitten ssh";

View File

@ -9,13 +9,7 @@ let
cfg = config.my.programs.ledger; cfg = config.my.programs.ledger;
in in
{ {
options.my.programs.ledger = { options.my.programs.ledger.enable = mkEnableOption "ledger";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = mkIf cfg.enable { config = mkIf cfg.enable {
my.shell = { my.shell = {

View File

@ -9,13 +9,7 @@ let
cfg = config.my.programs.logseq; cfg = config.my.programs.logseq;
in in
{ {
options.my.programs.logseq = { options.my.programs.logseq.enable = mkEnableOption "logseq";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = mkIf cfg.enable { config = mkIf cfg.enable {
users.users.moritz.packages = with pkgs; [ users.users.moritz.packages = with pkgs; [

View File

@ -30,7 +30,14 @@ in
example = [ "python39" ]; example = [ "python39" ];
}; };
packages = mkOption { packages = mkOption {
default = [ "isort" "pytest" "flake8" "python-lsp-server" ]; default = [
"flake8"
"isort"
"mypy"
"poetry"
"pytest"
"python-lsp-server"
];
type = with types; listOf (enum commonPackages); type = with types; listOf (enum commonPackages);
}; };
}; };

View File

@ -7,49 +7,9 @@
with lib; with lib;
let let
cfg = config.my.programs.rofi; cfg = config.my.programs.rofi;
rofi-bluetooth = with pkgs; stdenv.mkDerivation rec {
pname = "rofi-bluetooth";
version = "unstable-2021-03-05";
src = fetchFromGitHub {
repo = pname;
owner = "nickclyde";
# https://github.com/nickclyde/rofi-bluetooth/issues/19
rev = "893db1f2b549e7bc0e9c62e7670314349a29cdf2";
sha256 = "sha256-3oROJKEQCuSnLfbJ+JSSc9hcmJTPrLHRQJsrUcaOMss=";
};
nativeBuildInputs = [ makeWrapper ];
installPhase = ''
runHook preInstall
install -D --target-directory=$out/bin/ ./rofi-bluetooth
wrapProgram $out/bin/rofi-bluetooth \
--prefix PATH ":" ${lib.makeBinPath [ rofi-unwrapped bluez ] }
runHook postInstall
'';
meta = with lib; {
description = "Rofi-based interface to connect to bluetooth devices and display status info";
homepage = "https://github.com/nickclyde/rofi-bluetooth";
license = licenses.gpl3Only;
maintainers = with maintainers; [ MoritzBoehme ];
platforms = platforms.linux;
};
};
in in
{ {
options.my.programs.rofi = { options.my.programs.rofi.enable = mkEnableOption "rofi";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = mkIf cfg.enable { config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [

View File

@ -9,13 +9,7 @@ let
cfg = config.my.programs.spotify; cfg = config.my.programs.spotify;
in in
{ {
options.my.programs.spotify = { options.my.programs.spotify.enable = mkEnableOption "spotify";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = mkIf cfg.enable { config = mkIf cfg.enable {
age.secrets.spotifyd = { age.secrets.spotifyd = {

View File

@ -9,13 +9,7 @@ let
cfg = config.my.programs.sway; cfg = config.my.programs.sway;
in in
{ {
options.my.programs.sway = { options.my.programs.sway.enable = mkEnableOption "sway";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
hardware.opengl = { hardware.opengl = {

View File

@ -9,13 +9,7 @@ let
cfg = config.my.programs.thunar; cfg = config.my.programs.thunar;
in in
{ {
options.my.programs.thunar = { options.my.programs.thunar.enable = mkEnableOption "thunar";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = mkIf cfg.enable { config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [

View File

@ -9,13 +9,7 @@ let
cfg = config.my.programs.xmonad; cfg = config.my.programs.xmonad;
in in
{ {
options.my.programs.xmonad = { options.my.programs.xmonad.enable = mkEnableOption "xmonad";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
services = { services = {

View File

@ -9,13 +9,7 @@ let
cfg = config.my.programs.zathura; cfg = config.my.programs.zathura;
in in
{ {
options.my.programs.zathura = { options.my.programs.zathura.enable = mkEnableOption "zathura";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = mkIf cfg.enable { config = mkIf cfg.enable {
home-manager.users.moritz.programs.zathura = { home-manager.users.moritz.programs.zathura = {

View File

@ -11,13 +11,7 @@ let
shellConfig = config.my.shell; shellConfig = config.my.shell;
in in
{ {
options.my.programs.zsh = { options.my.programs.zsh.enable = mkEnableOption "zsh";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.pathsToLink = [ "/share/zsh" ]; environment.pathsToLink = [ "/share/zsh" ];

View File

@ -9,13 +9,7 @@ let
cfg = config.my.services.dunst; cfg = config.my.services.dunst;
in in
{ {
options.my.services.dunst = { options.my.services.dunst.enable = mkEnableOption "dunst";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
home-manager.users.moritz = { home-manager.users.moritz = {

View File

@ -13,13 +13,7 @@ let
cfg = config.my.services.kdeconnect; cfg = config.my.services.kdeconnect;
in in
{ {
options.my.services.kdeconnect = { options.my.services.kdeconnect.enable = mkEnableOption "kdeconnect";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = mkIf cfg.enable { config = mkIf cfg.enable {
home-manager.users.moritz.services.kdeconnect.enable = mkIf (!config.my.programs.gnome.enable) true; home-manager.users.moritz.services.kdeconnect.enable = mkIf (!config.my.programs.gnome.enable) true;

View File

@ -9,13 +9,7 @@ let
cfg = config.my.services.mullvad; cfg = config.my.services.mullvad;
in in
{ {
options.my.services.mullvad = { options.my.services.mullvad.enable = mkEnableOption "mullvad";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.mullvad-vpn.enable = true; services.mullvad-vpn.enable = true;

View File

@ -9,13 +9,7 @@ let
cfg = config.my.services.openconnect; cfg = config.my.services.openconnect;
in in
{ {
options.my.services.openconnect = { options.my.services.openconnect.enable = mkEnableOption "openconnect";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
networking.openconnect.interfaces = { networking.openconnect.interfaces = {

View File

@ -9,13 +9,7 @@ let
cfg = config.my.services.openvpn; cfg = config.my.services.openvpn;
in in
{ {
options.my.services.openvpn = { options.my.services.openvpn.enable = mkEnableOption "openvpn";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
age.secrets = { age.secrets = {

View File

@ -9,13 +9,7 @@ let
cfg = config.my.services.picom; cfg = config.my.services.picom;
in in
{ {
options.my.services.picom = { options.my.services.picom.enable = mkEnableOption "picom";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
home-manager.users.moritz = { home-manager.users.moritz = {

View File

@ -5,13 +5,7 @@ let
cfg = config.my.services.printing; cfg = config.my.services.printing;
in in
{ {
options.my.services.printing = { options.my.services.printing.enable = mkEnableOption "printing";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
services = { services = {

View File

@ -5,13 +5,7 @@ let
cfg = config.my.services.redshift; cfg = config.my.services.redshift;
in in
{ {
options.my.services.redshift = { options.my.services.redshift.enable = mkEnableOption "redshift";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.redshift.enable = true; services.redshift.enable = true;

View File

@ -9,13 +9,7 @@ let
cfg = config.my.virtualisation.podman; cfg = config.my.virtualisation.podman;
in in
{ {
options.my.virtualisation.podman = { options.my.virtualisation.podman.enable = mkEnableOption "podman";
enable = mkOption {
default = false;
type = types.bool;
example = false;
};
};
config = mkIf cfg.enable { config = mkIf cfg.enable {
virtualisation.podman = { virtualisation.podman = {

View File

@ -9,20 +9,17 @@ let
cfg = config.my.virtualisation.libvirtd; cfg = config.my.virtualisation.libvirtd;
in in
{ {
options.my.virtualisation.libvirtd = { options.my.virtualisation.libvirtd.enable = mkEnableOption "libvirtd";
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
config = mkIf cfg.enable { config = mkIf cfg.enable {
virtualisation.libvirtd = { virtualisation.libvirtd = {
enable = true; enable = true;
package = pkgs.libvirt; package = pkgs.libvirt;
}; };
environment.systemPackages = with pkgs; [ virt-manager ];
users.users.moritz.extraGroups = [ "libvirtd" ]; users.users.moritz = {
extraGroups = [ "libvirtd" ];
packages = with pkgs; [ virt-manager ];
};
}; };
} }