From 06fe248e8f264d4303a5d592774e3ab0cc63046c Mon Sep 17 00:00:00 2001 From: Luna Simons Date: Mon, 17 Jun 2024 16:19:36 +0200 Subject: [PATCH] chore(modules/home): brain damage, pt 1 --- modules/home/comma/default.nix | 17 +++++++- modules/home/dev/default.nix | 23 +++++++++- modules/home/direnv/default.nix | 32 ++++++++++++-- modules/home/firefox/default.nix | 32 +++++++++++--- modules/home/fish/default.nix | 75 +++++++++++++++++++------------- modules/home/git/default.nix | 47 ++++++++++++++------ 6 files changed, 167 insertions(+), 59 deletions(-) diff --git a/modules/home/comma/default.nix b/modules/home/comma/default.nix index 6fa9b7f..7b12172 100644 --- a/modules/home/comma/default.nix +++ b/modules/home/comma/default.nix @@ -1,11 +1,26 @@ { inputs, + lib, + config, pkgs, ... }: let inherit (inputs.nix-index-database.hmModules) nix-index; + inherit (lib) mkIf mkOption types; + + cfg = config.sysc.comma; in { imports = [nix-index]; - home.packages = with pkgs; [comma]; + options.sysc.comma = { + enable = mkOption { + type = types.bool; + default = true; + description = "Whether to enable Comma."; + }; + }; + + config = mkIf cfg.enable { + home.packages = with pkgs; [comma]; + }; } diff --git a/modules/home/dev/default.nix b/modules/home/dev/default.nix index 9a36760..ebe849e 100644 --- a/modules/home/dev/default.nix +++ b/modules/home/dev/default.nix @@ -1,3 +1,22 @@ -{pkgs, ...}: { - home.packages = with pkgs; [nodejs] ++ (with nodePackages; [yarn pnpm]); +{ + pkgs, + lib, + config, + ... +}: let + inherit (lib) mkIf mkOption types; + + cfg = config.sysc.dev; +in { + options.sysc.dev = { + enable = mkOption { + type = types.bool; + default = true; + description = "Whether to set-up dev tools."; + }; + }; + + config = mkIf cfg.enable { + home.packages = with pkgs; [nodejs] ++ (with nodePackages; [yarn pnpm]); + }; } diff --git a/modules/home/direnv/default.nix b/modules/home/direnv/default.nix index 6abce19..63032b0 100644 --- a/modules/home/direnv/default.nix +++ b/modules/home/direnv/default.nix @@ -1,8 +1,32 @@ { - programs.direnv = { - enable = true; - nix-direnv.enable = true; + lib, + config, + ... +}: let + inherit (lib) mkIf mkOption types; + + cfg = config.sysc.direnv; +in { + options.sysc.direnv = { + enable = mkOption { + type = types.bool; + default = true; + description = "Whether to enable direnv."; + }; + + enableNixDirenv = mkOption { + type = types.bool; + default = true; + description = "Whether to enable nix-direnv integration."; + }; }; - home.persistence."/persist/home/bddvlpr".directories = [".local/share/direnv"]; + config = mkIf cfg.enable { + programs.direnv = { + enable = true; + nix-direnv.enable = cfg.enableNixDirenv; + }; + + home.persistence."/persist/home/bddvlpr".directories = [".local/share/direnv"]; + }; } diff --git a/modules/home/firefox/default.nix b/modules/home/firefox/default.nix index bd9f671..00fc5e9 100644 --- a/modules/home/firefox/default.nix +++ b/modules/home/firefox/default.nix @@ -1,12 +1,30 @@ { - programs.firefox.enable = true; + lib, + config, + ... +}: let + inherit (lib) mkIf mkOption types; - home = { - sessionVariables.BROWSER = "firefox"; - persistence."/persist/home/bddvlpr" = { - directories = [ - ".mozilla/firefox" - ]; + cfg = config.sysc.firefox; +in { + options.sysc.firefox = { + enable = mkOption { + type = types.bool; + default = true; + description = "Whether to enable firefox."; + }; + }; + + config = mkIf cfg.enable { + programs.firefox.enable = true; + + home = { + sessionVariables.BROWSER = "firefox"; + persistence."/persist/home/bddvlpr" = { + directories = [ + ".mozilla/firefox" + ]; + }; }; }; } diff --git a/modules/home/fish/default.nix b/modules/home/fish/default.nix index d56b149..5408193 100644 --- a/modules/home/fish/default.nix +++ b/modules/home/fish/default.nix @@ -1,46 +1,59 @@ { lib, pkgs, + config, ... }: let + inherit (lib) mkIf mkOption types; inherit (lib.strings) hasSuffix; + cfg = config.sysc.fish; isDarwin = hasSuffix "-darwin" pkgs.system; in { - programs.fish = { - enable = true; + options.sysc.fish = { + enable = mkOption { + type = types.bool; + default = true; + description = "Whether to enable fish."; + }; + }; - shellAbbrs = let - build-command = - if isDarwin - then "darwin-rebuild --flake ." - else "sudo nixos-rebuild --flake /etc/nixos"; - in { - n = "nix"; - nb = "nix build"; - nbn = "nix build nixpkgs#"; - nf = "nix flake"; - nfu = "nix flake update"; - nfmt = "nix fmt"; - nr = "nix run"; - nrn = "nix run nixpkgs#"; - ns = "nix shell"; - nsn = "nix shell nixpkgs#"; + config = mkIf cfg.enable { + programs.fish = { + enable = true; - snr = "${build-command} --flake /etc/nixos"; - snrs = "${build-command} switch"; - }; + shellAbbrs = let + build-command = + if isDarwin + then "darwin-rebuild --flake ." + else "sudo nixos-rebuild --flake /etc/nixos"; + in { + n = "nix"; + nb = "nix build"; + nbn = "nix build nixpkgs#"; + nf = "nix flake"; + nfu = "nix flake update"; + nfmt = "nix fmt"; + nr = "nix run"; + nrn = "nix run nixpkgs#"; + ns = "nix shell"; + nsn = "nix shell nixpkgs#"; - shellAliases = let - inherit (lib) getExe; - in { - ls = "${getExe pkgs.eza} --icons -F -H --group-directories-first --git"; - cat = "${getExe pkgs.bat} -pp --theme=base16"; - }; + snr = "${build-command} --flake /etc/nixos"; + snrs = "${build-command} switch"; + }; + + shellAliases = let + inherit (lib) getExe; + in { + ls = "${getExe pkgs.eza} --icons -F -H --group-directories-first --git"; + cat = "${getExe pkgs.bat} -pp --theme=base16"; + }; - shellInit = '' - set fish_greeting - export TERM=xterm-256color - ''; + shellInit = '' + set fish_greeting + export TERM=xterm-256color + ''; + }; }; } diff --git a/modules/home/git/default.nix b/modules/home/git/default.nix index ef32507..b56cbe0 100644 --- a/modules/home/git/default.nix +++ b/modules/home/git/default.nix @@ -1,20 +1,39 @@ -{pkgs, ...}: { - programs.git = { - enable = true; - package = pkgs.gitFull; +{ + lib, + config, + pkgs, + ... +}: let + inherit (lib) mkIf mkOption types; - userName = "Luna Simons"; - userEmail = "luna@bddvlpr.com"; - - signing = { - key = "42EDAE8164B99C3A4B835711AB69B6F3380869A8"; - signByDefault = true; + cfg = config.sysc.git; +in { + options.sysc.git = { + enable = mkOption { + type = types.bool; + default = true; + description = "Whether to enable git."; }; + }; + + config = mkIf cfg.enable { + programs.git = { + enable = true; + package = pkgs.gitFull; + + userName = "Luna Simons"; + userEmail = "luna@bddvlpr.com"; + + signing = { + key = "42EDAE8164B99C3A4B835711AB69B6F3380869A8"; + signByDefault = true; + }; - extraConfig = { - init.defaultBranch = "main"; - push.autoSetupRemote = true; - credential.helper = "libsecret"; + extraConfig = { + init.defaultBranch = "main"; + push.autoSetupRemote = true; + credential.helper = "libsecret"; + }; }; }; }