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; };
in
{
options.my.bin = {
enable = mkOption {
default = true;
type = types.bool;
example = false;
};
};
options.my.bin.enable = mkEnableOption "bin";
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [

View File

@ -11,22 +11,21 @@ let
in
{
options.my.nix = {
gc.enable = mkOption {
default = true;
type = types.bool;
example = false;
};
optimise.enable = mkOption {
default = true;
type = types.bool;
example = false;
gc = {
enable = mkEnableOption "nix-gc";
minimumFreedGB = mkOption {
default = 32;
type = types.int;
apply = number: toString (number * 1024 * 1024 * 1024);
};
};
optimise.enable = mkEnableOption "nix-optimise";
};
config.nix = {
gc = {
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";
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,13 +12,8 @@ let
(epkgs: [ epkgs.vterm ]));
in
{
options.my.programs.emacs = {
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
options.my.programs.emacs.enable = mkEnableOption "emacs";
config = mkIf cfg.enable {
my.shell.aliases = {
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
{
options.my.programs.firefox = {
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
enable = mkEnableOption "firefox";
arkenfox = {
enable = mkEnableOption "arkenfox";
overrides = mkOption {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -7,49 +7,9 @@
with lib;
let
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
{
options.my.programs.rofi = {
enable = mkOption {
default = false;
type = types.bool;
example = true;
};
};
options.my.programs.rofi.enable = mkEnableOption "rofi";
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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