more updates

This commit is contained in:
Noah Masur
2025-02-05 17:25:29 -05:00
parent bb1a36330b
commit 620c72f731
23 changed files with 423 additions and 280 deletions

View File

@ -0,0 +1,55 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.nmasur.presets.gtk;
in
{
options.nmasur.presets.gtk = {
enable = lib.mkEnableOption "Gnome GTK settings";
theme = {
name = lib.mkOption {
type = lib.types.str;
default = "Adwaita-dark";
};
package = lib.mkPackageOption pkgs "gnome-themes-extra" { };
};
};
config = lib.mkIf cfg.enable {
# Cursor
home.pointerCursor = {
name = "Adwaita";
package = pkgs.adwaita-icon-theme;
size = 24;
gtk.enable = true;
x11.enable = true;
};
# Enable num lock on login
xsession.numlock.enable = true;
# Dark theme
gtk = {
enable = true;
theme = {
name = cfg.theme.name;
package = cfg.theme.package;
};
gtk3.extraConfig = {
gtk-application-prefer-dark-theme = config.theme.mode == "dark";
};
gtk4.extraConfig = {
gtk-application-prefer-dark-theme = config.theme.mode == "dark";
};
};
};
}

View File

@ -22,12 +22,13 @@ in
path = lib.mkOption {
type = lib.types.path;
description = "Path to dotfiles on disk";
default = config.homePath + "/dev/personal/dotfiles";
default = config.home.homeDirectory + "/dev/personal/dotfiles";
};
};
config = lib.mkIf cfg.enable {
# Always make the dotfiles directory considered safe for git and direnv
programs.git.extraConfig.safe.directory = cfg.path;
programs.direnv.config.whitelist.prefix = [ cfg.path ];
@ -37,8 +38,7 @@ in
cloneDotfiles = config.lib.dag.entryAfter [ "writeBoundary" "loadkey" ] ''
if [ ! -d "${cfg.path}" ]; then
run mkdir --parents $VERBOSE_ARG $(dirname "${cfg.path}")
run ${pkgs.git}/bin/git \
clone ${cfg.repo} "${cfg.path}"
run ${lib.getExe pkgs.git} clone ${cfg.repo} "${cfg.path}"
fi
'';
};

View File

@ -67,7 +67,7 @@ in
"extensions.pocket.enabled" = false;
"toolkit.legacyUserProfileCustomizations.stylesheets" = true; # Allow userChrome.css
"layout.css.color-mix.enabled" = true;
"ui.systemUsesDarkTheme" = if config.theme.dark == true then 1 else 0;
"ui.systemUsesDarkTheme" = if config.theme.mode == "dark" then 1 else 0;
"media.ffmpeg.vaapi.enabled" = true; # Enable hardware video acceleration
"cookiebanners.ui.desktop.enabled" = true; # Reject cookie popups
"devtools.command-button-screenshot.enabled" = true; # Scrolling screenshot of entire page

View File

@ -6,12 +6,12 @@
}:
let
cfg = config.nmasur.presets.programs.msmtp;
cfg = config.nmasur.presets.programs.msmtp-system;
in
{
options.nmasur.presets.programs.msmtp.enable = lib.mkEnableOption "System outgoing mail";
options.nmasur.presets.programs.msmtp-system.enable = lib.mkEnableOption "System outgoing mail";
config = lib.mkIf cfg.enable {
programs.msmtp.enable = true;

View File

@ -13,13 +13,16 @@ in
options.nmasur.presets.programs.nixpkgs-darwin.enable = lib.mkEnableOption {
description = "Nixpkgs tools for macOS";
default = config.nmasur.presets.programs.nixpkgs && pkgs.stdenv.isDarwin;
default =
config.nmasur.presets.programs.nixpkgs.enable
&& pkgs.stdenv.isDarwin
&& config.nmasur.presets.programs.dotfiles.enable;
};
config = lib.mkIf (cfg.enable) {
programs.fish = {
shellAbbrs = {
shellAbbrs = lib.mkIf config.nmasur.presets.programs.dotfiles.enable {
nr = {
function = lib.mkForce "rebuild-darwin";
};
@ -27,23 +30,23 @@ in
function = lib.mkForce "rebuild-darwin-offline";
};
};
functions = {
functions = lib.mkIf config.nmasur.presets.programs.dotfiles.enable {
rebuild-darwin = {
body = ''
git -C ${config.dotfilesPath} add --intent-to-add --all
echo "darwin-rebuild switch --flake ${config.dotfilesPath}#lookingglass"
git -C ${config.nmasur.presets.programs.dotfiles.path} add --intent-to-add --all
echo "darwin-rebuild switch --flake ${config.nmasur.presets.programs.dotfiles.path}#lookingglass"
'';
};
rebuild-darwin-offline = {
body = ''
git -C ${config.dotfilesPath} add --intent-to-add --all
echo "darwin-rebuild switch --option substitute false --flake ${config.dotfilesPath}#lookingglass"
git -C ${config.nmasur.presets.programs.dotfiles.path} add --intent-to-add --all
echo "darwin-rebuild switch --option substitute false --flake ${config.nmasur.presets.programs.dotfiles.path}#lookingglass"
'';
};
rebuild-home = lib.mkForce {
body = ''
git -C ${config.dotfilesPath} add --intent-to-add --all
echo "${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#lookingglass";
git -C ${config.nmasur.presets.programs.dotfiles.path} add --intent-to-add --all
echo "${lib.getExe pkgs.home-manager} switch --flake ${config.nmasur.presets.programs.dotfiles.path}#lookingglass";
'';
};
};

View File

@ -24,13 +24,13 @@ in
nps = "nix repl --expr 'import <nixpkgs>{}'";
nixo = "man configuration.nix";
nixh = "man home-configuration.nix";
nr = {
nr = lib.mkIf config.nmasur.presets.programs.dotfiles.enable {
function = "rebuild-nixos";
};
nro = {
nro = lib.mkIf config.nmasur.presets.programs.dotfiles.enable {
function = "rebuild-nixos-offline";
};
hm = {
hm = lib.mkIf config.nmasur.presets.programs.dotfiles.enable {
function = "rebuild-home";
};
};
@ -56,25 +56,25 @@ in
commandline -f repaint
'';
};
rebuild-nixos = {
rebuild-nixos = lib.mkIf config.nmasur.presets.programs.dotfiles.enable {
body = # fish
''
git -C ${config.dotfilesPath} add --intent-to-add --all
echo "doas nixos-rebuild switch --flake ${config.dotfilesPath}#${config.networking.hostName}"
git -C ${config.nmasur.presets.programs.dotfiles.path} add --intent-to-add --all
echo "doas nixos-rebuild switch --flake ${config.nmasur.presets.programs.dotfiles.path}#${config.networking.hostName}"
'';
};
rebuild-nixos-offline = {
rebuild-nixos-offline = lib.mkIf config.nmasur.presets.programs.dotfiles.enable {
body = # fish
''
git -C ${config.dotfilesPath} add --intent-to-add --all
echo "doas nixos-rebuild switch --option substitute false --flake ${config.dotfilesPath}#${config.networking.hostName}"
git -C ${config.nmasur.presets.programs.dotfiles.path} add --intent-to-add --all
echo "doas nixos-rebuild switch --option substitute false --flake ${config.nmasur.presets.programs.dotfiles.path}#${config.networking.hostName}"
'';
};
rebuild-home = {
rebuild-home = lib.mkIf config.nmasur.presets.programs.dotfiles.enable {
body = # fish
''
git -C ${config.dotfilesPath} add --intent-to-add --all
echo "${lib.getExe pkgs.home-manager} switch --flake ${config.dotfilesPath}#${config.networking.hostName}";
git -C ${config.nmasur.presets.programs.dotfiles.path} add --intent-to-add --all
echo "${lib.getExe pkgs.home-manager} switch --flake ${config.nmasur.presets.programs.dotfiles.path}#${config.networking.hostName}";
'';
};
};
@ -99,7 +99,7 @@ in
# Create nix-index if doesn't exist
home.activation.createNixIndex =
let
cacheDir = "${config.homePath}/.cache/nix-index";
cacheDir = "${config.xdg.cacheHome}/nix-index";
in
lib.mkIf config.programs.nix-index.enable (
config.lib.dag.entryAfter [ "writeBoundary" ] ''
@ -141,10 +141,12 @@ in
settings = {
# Add community Cachix to binary cache
# Don't use with macOS because blocked by corporate firewall
# Don't use at work because blocked by corporate firewall
builders-use-substitutes = true;
substituters = lib.mkIf (!pkgs.stdenv.isDarwin) [ "https://nix-community.cachix.org" ];
trusted-public-keys = lib.mkIf (!pkgs.stdenv.isDarwin) [
substituters = lib.mkIf (!config.nmasur.profiles.work.enable) [
"https://nix-community.cachix.org"
];
trusted-public-keys = lib.mkIf (!config.nmasur.profiles.work.enable) [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];

View File

@ -20,7 +20,7 @@ in
path = lib.mkOption {
type = lib.types.path;
description = "Path to notes on disk";
default = config.homePath + "/dev/personal/notes";
default = config.home.homeDirectory + "/dev/personal/notes";
};
};

View File

@ -0,0 +1,24 @@
{ config, lib, ... }:
let
cfg = config.nmasur.presets.programs.notmuch;
in
{
options.nmasur.presets.programs.notmuch.enable = lib.mkEnableOption "Notmuch mail indexing";
config = lib.mkIf cfg.enable {
# Better local mail search
programs.notmuch = {
enable = true;
new.ignore = [
".mbsyncstate.lock"
".mbsyncstate.journal"
".mbsyncstate.new"
];
};
};
}

View File

@ -202,9 +202,9 @@ in
''exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"'';
"${modifier}+Shift+x" = lib.mkIf cfg.commands.lockScreen != null "exec ${cfg.commands.lockScreen}";
"${modifier}+Mod1+h" =
"exec --no-startup-id ${lib.getExe cfg.terminal} -e sh -c '${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#${config.networking.hostName} || read'";
"exec --no-startup-id ${lib.getExe cfg.terminal} -e sh -c '${pkgs.home-manager}/bin/home-manager switch --flake ${config.nmasur.presets.programs.dotfiles.path}#${config.networking.hostName} || read'";
"${modifier}+Mod1+r" =
"exec --no-startup-id ${lib.getExe cfg.terminal} -e sh -c 'doas nixos-rebuild switch --flake ${config.dotfilesPath}#${config.networking.hostName} || read'";
"exec --no-startup-id ${lib.getExe cfg.terminal} -e sh -c 'doas nixos-rebuild switch --flake ${config.nmasur.presets.programs.dotfiles.path}#${config.networking.hostName} || read'";
# Window options
"${modifier}+q" = "kill";
@ -322,7 +322,7 @@ in
# Update lock screen cache only if cache is empty
home.activation.updateLockScreenCache =
let
cacheDir = "${config.homePath}/.cache/betterlockscreen/current";
cacheDir = "${config.xdg.cacheHome}/betterlockscreen/current";
in
lib.mkIf cfg.commands.updateLockScreen != null (
config.lib.dag.entryAfter [ "writeBoundary" ] ''

View File

@ -0,0 +1,123 @@
{
config,
pkgs,
lib,
...
}:
{
options = {
mail.enable = lib.mkEnableOption "Mail service.";
mail.user = lib.mkOption {
type = lib.types.str;
description = "User name for the email address.";
default = config.user;
};
mail.server = lib.mkOption {
type = lib.types.nullOr lib.types.str;
description = "Server name for the email address.";
};
mail.imapHost = lib.mkOption {
type = lib.types.nullOr lib.types.str;
description = "Server host for IMAP (reading mail).";
};
mail.smtpHost = lib.mkOption {
type = lib.types.nullOr lib.types.str;
description = "Server host for SMTP (sending mail).";
};
};
config = lib.mkIf config.mail.enable {
home-manager.users.${config.user} = {
programs.mbsync = {
enable = true;
};
# Automatically check for mail and keep files synced locally
services.mbsync = lib.mkIf pkgs.stdenv.isLinux {
enable = true;
frequency = "*:0/5";
postExec = "${lib.getExe pkgs.notmuch} new";
};
# Used to watch for new mail and trigger sync
services.imapnotify.enable = pkgs.stdenv.isLinux;
# Allows sending email from CLI/sendmail
programs.msmtp.enable = true;
accounts.email = {
# Where email files are stored
maildirBasePath = "${config.home.homeDirectory}/mail";
accounts = {
home =
let
address = "${config.mail.user}@${config.mail.server}";
in
{
userName = address;
realName = config.fullName;
primary = true;
inherit address;
aliases = map (user: "${user}@${config.mail.server}") [
"me"
"hey"
"admin"
];
# Options for contact completion
alot = { };
imap = {
host = config.mail.imapHost;
port = 993;
tls.enable = true;
};
# Watch for mail and run notifications or sync
imapnotify = {
enable = true;
boxes = [ "Inbox" ];
onNotify = "${pkgs.isync}/bin/mbsync -a";
onNotifyPost =
lib.mkIf config.home-manager.users.${config.user}.services.dunst.enable
"${lib.getExe pkgs.libnotify} 'New mail arrived'";
};
# Name of the directory in maildir for this account
maildir = {
path = "main";
};
# Bi-directional syncing options for local files
mbsync = {
enable = true;
create = "both";
expunge = "both";
remove = "both";
patterns = [ "*" ];
extraConfig.channel = {
CopyArrivalDate = "yes"; # Sync time of original message
};
};
# Enable indexing
notmuch.enable = true;
# Used to login and send and receive emails
passwordCommand = "${pkgs.age}/bin/age --decrypt --identity ~/.ssh/id_ed25519 ${pkgs.writeText "mailpass.age" (builtins.readFile ../../../private/mailpass.age)}";
smtp = {
host = config.mail.smtpHost;
port = 465;
tls.enable = true;
};
};
};
};
};
};
}

View File

@ -1,6 +1,5 @@
{
config,
pkgs,
lib,
...
}:
@ -15,35 +14,7 @@ in
config = lib.mkIf cfg.enable {
# Cursor
home.pointerCursor = {
name = lib.mkDefault "Adwaita";
package = lib.mkDefault pkgs.adwaita-icon-theme;
size = lib.mkDefault 24;
gtk.enable = lib.mkDefault true;
x11.enable = lib.mkDefault true;
};
# Enable num lock on login
xsession.numlock.enable = lib.mkDefault true;
# Dark theme
gtk =
let
gtkExtraConfig = {
gtk-application-prefer-dark-theme = lib.mkDefault config.theme.dark;
};
in
{
enable = lib.mkDefault true;
theme = {
name = lib.mkDefault config.gtk.theme.name;
package = lib.mkDefault config.gtk.theme.package;
};
gtk3.extraConfig = lib.mkDefault gtkExtraConfig;
gtk4.extraConfig = lib.mkDefault gtkExtraConfig;
};
nmasur.gtk.enable = lib.mkDefault true;
programs.zed-editor.enable = lib.mkDefault true;
};

View File

@ -6,10 +6,10 @@
}:
let
cfg = config.nmasur.profiles.common;
cfg = config.nmasur.profiles.power-user;
in
{
options.nmasur.profiles.common.enable = lib.mkEnableOption "Extra home-manager config";
options.nmasur.profiles.power-user.enable = lib.mkEnableOption "power user home-manager config";
config = lib.mkIf cfg.enable {
home.packages = lib.mkDefault [

View File

@ -0,0 +1,26 @@
{ lib, ... }:
{
options.theme = {
name = lib.mkOption {
type = lib.types.nullOr lib.types.str;
description = "Color palette name (fallback when individual colors aren't specified)";
default = null;
};
colors = lib.mkOption {
type = lib.types.attrs;
description = "Base16 color scheme.";
default = (import ../colorscheme/gruvbox).dark;
};
mode = lib.mkOption {
type = lib.types.enum [
"light"
"dark"
];
description = "Light or dark mode";
default = "dark";
};
};
}