diff --git a/modules/common/default.nix b/modules/common/default.nix index 5827ee9..1acb573 100644 --- a/modules/common/default.nix +++ b/modules/common/default.nix @@ -37,40 +37,22 @@ description = "Path to existing private key file."; default = "/etc/ssh/ssh_host_ed25519_key"; }; - gui = { - enable = lib.mkEnableOption { - description = "Enable graphics."; - default = false; - }; - }; - theme = { - colors = lib.mkOption { - type = lib.types.attrs; - description = "Base16 color scheme."; - default = (import ../colorscheme/gruvbox).dark; - }; - dark = lib.mkOption { - type = lib.types.bool; - description = "Enable dark mode."; - default = true; - }; - }; - homePath = lib.mkOption { - type = lib.types.path; - description = "Path of user's home directory."; - default = builtins.toPath ( - if pkgs.stdenv.isDarwin then "/Users/${config.user}" else "/home/${config.user}" - ); - }; - dotfilesPath = lib.mkOption { - type = lib.types.path; - description = "Path of dotfiles repository."; - default = config.homePath + "/dev/personal/dotfiles"; - }; - dotfilesRepo = lib.mkOption { - type = lib.types.str; - description = "Link to dotfiles repository HTTPS URL."; - }; + # homePath = lib.mkOption { + # type = lib.types.path; + # description = "Path of user's home directory."; + # default = builtins.toPath ( + # if pkgs.stdenv.isDarwin then "/Users/${config.user}" else "/home/${config.user}" + # ); + # }; + # dotfilesPath = lib.mkOption { + # type = lib.types.path; + # description = "Path of dotfiles repository."; + # default = config.homePath + "/dev/personal/dotfiles"; + # }; + # dotfilesRepo = lib.mkOption { + # type = lib.types.str; + # description = "Link to dotfiles repository HTTPS URL."; + # }; unfreePackages = lib.mkOption { type = lib.types.listOf lib.types.str; description = "List of unfree packages to allow."; @@ -81,88 +63,88 @@ description = "List of insecure packages to allow."; default = [ ]; }; - hostnames = { - audiobooks = lib.mkOption { - type = lib.types.str; - description = "Hostname for audiobook server (Audiobookshelf)."; - }; - budget = lib.mkOption { - type = lib.types.str; - description = "Hostname for budgeting server (ActualBudget)."; - }; - files = lib.mkOption { - type = lib.types.str; - description = "Hostname for files server (Filebrowser)."; - }; - git = lib.mkOption { - type = lib.types.str; - description = "Hostname for git server (Gitea)."; - }; - metrics = lib.mkOption { - type = lib.types.str; - description = "Hostname for metrics server."; - }; - minecraft = lib.mkOption { - type = lib.types.str; - description = "Hostname for Minecraft server."; - }; - paperless = lib.mkOption { - type = lib.types.str; - description = "Hostname for document server (paperless-ngx)."; - }; - photos = lib.mkOption { - type = lib.types.str; - description = "Hostname for photo management (Immich)."; - }; - prometheus = lib.mkOption { - type = lib.types.str; - description = "Hostname for Prometheus server."; - }; - influxdb = lib.mkOption { - type = lib.types.str; - description = "Hostname for InfluxDB2 server."; - }; - secrets = lib.mkOption { - type = lib.types.str; - description = "Hostname for passwords and secrets (Vaultwarden)."; - }; - stream = lib.mkOption { - type = lib.types.str; - description = "Hostname for video/media library (Jellyfin)."; - }; - content = lib.mkOption { - type = lib.types.str; - description = "Hostname for personal content system (Nextcloud)."; - }; - books = lib.mkOption { - type = lib.types.str; - description = "Hostname for books library (Calibre-Web)."; - }; - download = lib.mkOption { - type = lib.types.str; - description = "Hostname for download services."; - }; - irc = lib.mkOption { - type = lib.types.str; - description = "Hostname for IRC services."; - }; - n8n = lib.mkOption { - type = lib.types.str; - description = "Hostname for n8n automation."; - }; - notifications = lib.mkOption { - type = lib.types.str; - description = "Hostname for push notification services (ntfy)."; - }; - status = lib.mkOption { - type = lib.types.str; - description = "Hostname for status page (Uptime-Kuma)."; - }; - transmission = lib.mkOption { - type = lib.types.str; - description = "Hostname for peer2peer downloads (Transmission)."; - }; - }; + # hostnames = { + # audiobooks = lib.mkOption { + # type = lib.types.str; + # description = "Hostname for audiobook server (Audiobookshelf)."; + # }; + # budget = lib.mkOption { + # type = lib.types.str; + # description = "Hostname for budgeting server (ActualBudget)."; + # }; + # files = lib.mkOption { + # type = lib.types.str; + # description = "Hostname for files server (Filebrowser)."; + # }; + # git = lib.mkOption { + # type = lib.types.str; + # description = "Hostname for git server (Gitea)."; + # }; + # metrics = lib.mkOption { + # type = lib.types.str; + # description = "Hostname for metrics server."; + # }; + # minecraft = lib.mkOption { + # type = lib.types.str; + # description = "Hostname for Minecraft server."; + # }; + # paperless = lib.mkOption { + # type = lib.types.str; + # description = "Hostname for document server (paperless-ngx)."; + # }; + # photos = lib.mkOption { + # type = lib.types.str; + # description = "Hostname for photo management (Immich)."; + # }; + # prometheus = lib.mkOption { + # type = lib.types.str; + # description = "Hostname for Prometheus server."; + # }; + # influxdb = lib.mkOption { + # type = lib.types.str; + # description = "Hostname for InfluxDB2 server."; + # }; + # secrets = lib.mkOption { + # type = lib.types.str; + # description = "Hostname for passwords and secrets (Vaultwarden)."; + # }; + # stream = lib.mkOption { + # type = lib.types.str; + # description = "Hostname for video/media library (Jellyfin)."; + # }; + # content = lib.mkOption { + # type = lib.types.str; + # description = "Hostname for personal content system (Nextcloud)."; + # }; + # books = lib.mkOption { + # type = lib.types.str; + # description = "Hostname for books library (Calibre-Web)."; + # }; + # download = lib.mkOption { + # type = lib.types.str; + # description = "Hostname for download services."; + # }; + # irc = lib.mkOption { + # type = lib.types.str; + # description = "Hostname for IRC services."; + # }; + # n8n = lib.mkOption { + # type = lib.types.str; + # description = "Hostname for n8n automation."; + # }; + # notifications = lib.mkOption { + # type = lib.types.str; + # description = "Hostname for push notification services (ntfy)."; + # }; + # status = lib.mkOption { + # type = lib.types.str; + # description = "Hostname for status page (Uptime-Kuma)."; + # }; + # transmission = lib.mkOption { + # type = lib.types.str; + # description = "Hostname for peer2peer downloads (Transmission)."; + # }; + # }; }; config = diff --git a/overlays/pkgs.nix b/overlays/pkgs.nix index 9fcc572..c360d16 100644 --- a/overlays/pkgs.nix +++ b/overlays/pkgs.nix @@ -1,18 +1,24 @@ _final: prev: let + listToAttrsByField = + field: list: + builtins.listToAttrs ( + map (v: { + name = v.${field}; + value = v; + }) list + ); lib = prev.lib; - packages = lib.pipe [ - (lib.filesystem.listFilesRecursive ../pkgs) + packagesDirectory = lib.filesystem.listFilesRecursive ../pkgs; + packages = lib.pipe packagesDirectory [ + # Get only files called package.nix (builtins.filter (name: (lib.hasSuffix "package.nix" name))) - (builtins.map (package: prev.callPackage package)) + # Apply callPackage to create a derivation + (builtins.map prev.callPackage) + # Convert the list to an attrset + (listToAttrsByField "name") ]; in -{ - - loadkey = prev.callPackage ../pkgs/tools/misc/loadkey.nix { }; - aws-ec2 = prev.callPackage ../pkgs/tools/misc/aws-ec2 { }; - docker-cleanup = prev.callPackage ../pkgs/tools/misc/docker-cleanup { }; - nmasur-neovim = prev.callPackage ../pkgs/applications/editors/neovim/nmasur/neovim { }; -} +packages diff --git a/pkgs/applications/editors/neovim/nmasur/neovim/old-default.nix b/pkgs/applications/editors/neovim/nmasur/neovim/old-default.nix deleted file mode 100644 index 56a5d91..0000000 --- a/pkgs/applications/editors/neovim/nmasur/neovim/old-default.nix +++ /dev/null @@ -1,67 +0,0 @@ -{ - config, - pkgs, - lib, - ... -}: - -let - - neovim = import ./package { - inherit pkgs; - colors = config.theme.colors; - terraform = config.terraform.enable; - github = true; - kubernetes = config.kubernetes.enable; - }; -in -{ - - options.neovim.enable = lib.mkEnableOption "Neovim."; - - config = lib.mkIf config.neovim.enable { - home-manager.users.${config.user} = - - { - - home.packages = [ neovim ]; - - # Use Neovim as the editor for git commit messages - programs.git.extraConfig.core.editor = "nvim"; - programs.jujutsu.settings.ui.editor = "nvim"; - - # Set Neovim as the default app for text editing and manual pages - home.sessionVariables = { - EDITOR = "nvim"; - MANPAGER = "nvim +Man!"; - }; - - # Create quick aliases for launching Neovim - programs.fish = { - shellAliases = { - vim = "nvim"; - }; - shellAbbrs = { - v = lib.mkForce "nvim"; - vl = lib.mkForce "nvim -c 'normal! `0' -c 'bdelete 1'"; - vll = "nvim -c 'Telescope oldfiles'"; - }; - }; - - # Create a desktop option for launching Neovim from a file manager - # (Requires launching the terminal and then executing Neovim) - xdg.desktopEntries.nvim = lib.mkIf (pkgs.stdenv.isLinux && config.gui.enable) { - name = "Neovim wrapper"; - exec = "${config.home-manager.users.${config.user}.programs.rofi.terminal} nvim %F"; - mimeType = [ - "text/plain" - "text/markdown" - ]; - }; - xdg.mimeApps.defaultApplications = lib.mkIf pkgs.stdenv.isLinux { - "text/plain" = [ "nvim.desktop" ]; - "text/markdown" = [ "nvim.desktop" ]; - }; - }; - }; -} diff --git a/platforms/home-manager/modules/nmasur/presets/gtk.nix b/platforms/home-manager/modules/nmasur/presets/gtk.nix new file mode 100644 index 0000000..bc9591a --- /dev/null +++ b/platforms/home-manager/modules/nmasur/presets/gtk.nix @@ -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"; + }; + }; + + }; + +} diff --git a/platforms/home-manager/modules/nmasur/presets/programs/dotfiles.nix b/platforms/home-manager/modules/nmasur/presets/programs/dotfiles.nix index 708c242..3d85a33 100644 --- a/platforms/home-manager/modules/nmasur/presets/programs/dotfiles.nix +++ b/platforms/home-manager/modules/nmasur/presets/programs/dotfiles.nix @@ -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 ''; }; diff --git a/platforms/home-manager/modules/nmasur/presets/programs/firefox.nix b/platforms/home-manager/modules/nmasur/presets/programs/firefox.nix index 8461e59..ab9ef41 100644 --- a/platforms/home-manager/modules/nmasur/presets/programs/firefox.nix +++ b/platforms/home-manager/modules/nmasur/presets/programs/firefox.nix @@ -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 diff --git a/platforms/home-manager/modules/nmasur/presets/programs/msmtp.nix b/platforms/home-manager/modules/nmasur/presets/programs/msmtp-system.nix similarity index 84% rename from platforms/home-manager/modules/nmasur/presets/programs/msmtp.nix rename to platforms/home-manager/modules/nmasur/presets/programs/msmtp-system.nix index 9e6d9f8..095ad89 100644 --- a/platforms/home-manager/modules/nmasur/presets/programs/msmtp.nix +++ b/platforms/home-manager/modules/nmasur/presets/programs/msmtp-system.nix @@ -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; diff --git a/platforms/home-manager/modules/nmasur/presets/programs/nixpkgs-darwin.nix b/platforms/home-manager/modules/nmasur/presets/programs/nixpkgs-darwin.nix index f2e628b..03d680c 100644 --- a/platforms/home-manager/modules/nmasur/presets/programs/nixpkgs-darwin.nix +++ b/platforms/home-manager/modules/nmasur/presets/programs/nixpkgs-darwin.nix @@ -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"; ''; }; }; diff --git a/platforms/home-manager/modules/nmasur/presets/programs/nixpkgs.nix b/platforms/home-manager/modules/nmasur/presets/programs/nixpkgs.nix index 16be802..31f5773 100644 --- a/platforms/home-manager/modules/nmasur/presets/programs/nixpkgs.nix +++ b/platforms/home-manager/modules/nmasur/presets/programs/nixpkgs.nix @@ -24,13 +24,13 @@ in nps = "nix repl --expr 'import {}'"; 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=" ]; diff --git a/platforms/home-manager/modules/nmasur/presets/programs/notes/default.nix b/platforms/home-manager/modules/nmasur/presets/programs/notes/default.nix index 19c26a2..c79a755 100644 --- a/platforms/home-manager/modules/nmasur/presets/programs/notes/default.nix +++ b/platforms/home-manager/modules/nmasur/presets/programs/notes/default.nix @@ -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"; }; }; diff --git a/platforms/home-manager/modules/nmasur/presets/programs/notmuch.nix b/platforms/home-manager/modules/nmasur/presets/programs/notmuch.nix new file mode 100644 index 0000000..a5c60f2 --- /dev/null +++ b/platforms/home-manager/modules/nmasur/presets/programs/notmuch.nix @@ -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" + ]; + }; + + }; + +} diff --git a/platforms/home-manager/modules/nmasur/presets/services/i3.nix b/platforms/home-manager/modules/nmasur/presets/services/i3.nix index db8ebd2..05ff1a9 100644 --- a/platforms/home-manager/modules/nmasur/presets/services/i3.nix +++ b/platforms/home-manager/modules/nmasur/presets/services/i3.nix @@ -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" ] '' diff --git a/platforms/home-manager/modules/nmasur/presets/services/mbsync.nix b/platforms/home-manager/modules/nmasur/presets/services/mbsync.nix new file mode 100644 index 0000000..0471d7b --- /dev/null +++ b/platforms/home-manager/modules/nmasur/presets/services/mbsync.nix @@ -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; + }; + }; + }; + }; + }; + }; +} diff --git a/platforms/home-manager/modules/nmasur/profiles/linux-gui.nix b/platforms/home-manager/modules/nmasur/profiles/linux-gui.nix index 4a3cea0..5bd0060 100644 --- a/platforms/home-manager/modules/nmasur/profiles/linux-gui.nix +++ b/platforms/home-manager/modules/nmasur/profiles/linux-gui.nix @@ -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; }; diff --git a/platforms/home-manager/modules/nmasur/profiles/extra.nix b/platforms/home-manager/modules/nmasur/profiles/power-user.nix similarity index 91% rename from platforms/home-manager/modules/nmasur/profiles/extra.nix rename to platforms/home-manager/modules/nmasur/profiles/power-user.nix index 980d19f..7657b65 100644 --- a/platforms/home-manager/modules/nmasur/profiles/extra.nix +++ b/platforms/home-manager/modules/nmasur/profiles/power-user.nix @@ -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 [ diff --git a/platforms/home-manager/theme.nix b/platforms/home-manager/theme.nix new file mode 100644 index 0000000..b952f76 --- /dev/null +++ b/platforms/home-manager/theme.nix @@ -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"; + }; + }; + +} diff --git a/platforms/nix-darwin/modules/nmasur/presets/services/hammerspoon.nix b/platforms/nix-darwin/modules/nmasur/presets/services/hammerspoon.nix index a5ee05e..317f686 100644 --- a/platforms/nix-darwin/modules/nmasur/presets/services/hammerspoon.nix +++ b/platforms/nix-darwin/modules/nmasur/presets/services/hammerspoon.nix @@ -18,7 +18,9 @@ in homebrew.casks = [ "hammerspoon" ]; system.activationScripts.postUserActivation.text = '' - defaults write org.hammerspoon.Hammerspoon MJConfigFile "${config.homePath}/.config/hammerspoon/init.lua" + defaults write org.hammerspoon.Hammerspoon MJConfigFile "${ + config.home-manager.users.${config.user}.xdg.configHome + }/hammerspoon/init.lua" sudo killall Dock ''; diff --git a/platforms/nix-darwin/modules/nmasur/presets/services/user.nix b/platforms/nix-darwin/modules/nmasur/presets/services/user.nix index 6d3a71b..2ad2e5c 100644 --- a/platforms/nix-darwin/modules/nmasur/presets/services/user.nix +++ b/platforms/nix-darwin/modules/nmasur/presets/services/user.nix @@ -15,7 +15,7 @@ in config = lib.mkIf cfg.enable { users.users."${config.user}" = { # macOS user - home = config.homePath; + home = config.home-manager.users.${config.user}.home.homeDirectory; uid = 502; # shell = pkgs.fish; # Default shell }; diff --git a/platforms/nixos/modules/nmasur/presets/services/lightdm.nix b/platforms/nixos/modules/nmasur/presets/services/lightdm.nix index 8c7a105..353d5d6 100644 --- a/platforms/nixos/modules/nmasur/presets/services/lightdm.nix +++ b/platforms/nixos/modules/nmasur/presets/services/lightdm.nix @@ -1,5 +1,6 @@ { config, + pkgs, lib, ... }: @@ -16,6 +17,13 @@ in type = lib.types.path; description = "Wallpaper background image file"; }; + gtk.theme = { + name = lib.mkOption { + type = lib.types.str; + default = "Adwaita-dark"; + }; + package = lib.mkPackageOption pkgs "gnome-themes-extra" { }; + }; }; config = lib.mkIf cfg.enable { @@ -34,6 +42,13 @@ in extraSeatDefaults = '' greeter-hide-users = false ''; + + # Make the login screen dark + greeters.gtk.theme = { + name = cfg.gtk.theme.name; + package = cfg.gtk.theme.package; + }; + }; }; }; diff --git a/platforms/nixos/modules/nmasur/presets/services/nix-autoupgrade.nix b/platforms/nixos/modules/nmasur/presets/services/nix-autoupgrade.nix index fa6d5e3..e49ae26 100644 --- a/platforms/nixos/modules/nmasur/presets/services/nix-autoupgrade.nix +++ b/platforms/nixos/modules/nmasur/presets/services/nix-autoupgrade.nix @@ -11,7 +11,14 @@ in { - options.nmasur.presets.services.nix-autoupgrade.enable = lib.mkEnableOption "Nix auto upgrade"; + options.nmasur.presets.services.nix-autoupgrade = { + enable = lib.mkEnableOption "Nix auto upgrade"; + repo = lib.mkOption { + type = lib.types.nullOr lib.types.str; + description = "Git URL of the flake repository to use for upgrades"; + default = "git@github.com:nmasur/dotfiles"; + }; + }; config = lib.mkIf cfg.enable { @@ -19,7 +26,7 @@ in system.autoUpgrade = { enable = true; dates = "09:33"; - flake = "git+${config.dotfilesRepo}"; + flake = "git+${cfg.repo}"; randomizedDelaySec = "25min"; operation = "switch"; allowReboot = true; @@ -46,8 +53,8 @@ in set +e systemctl status $SERVICE_ID >> $TEMPFILE set -e - ${pkgs.msmtp}/bin/msmtp \ - --file=${config.homePath}/.config/msmtp/config \ + ${lib.getExe pkgs.msmtp} \ + --file=${config.home-manager.users.${config.user}.xdg.configDir}/msmtp/config \ --account=system \ ${address} < $TEMPFILE ''; diff --git a/platforms/nixos/modules/nmasur/presets/services/notes-git-sync.nix b/platforms/nixos/modules/nmasur/presets/services/notes-git-sync.nix index fe23b25..a6bdb0e 100644 --- a/platforms/nixos/modules/nmasur/presets/services/notes-git-sync.nix +++ b/platforms/nixos/modules/nmasur/presets/services/notes-git-sync.nix @@ -25,9 +25,9 @@ in Unit.Description = "Get latest notes."; Service = { Type = "oneshot"; - ExecStartPre = "${pkgs.git}/bin/git -C /data/git/notes reset --hard master"; - ExecStart = "${pkgs.git}/bin/git -C /data/git/notes pull"; - WorkingDirectory = config.homePath; + ExecStartPre = "${lib.getExe pkgs.git} -C /data/git/notes reset --hard master"; + ExecStart = "${lib.getExe pkgs.git} -C /data/git/notes pull"; + WorkingDirectory = config.home-manager.users.${config.user}.home.homeDirectory; Environment = "PATH=${pkgs.openssh}/bin"; }; }; diff --git a/platforms/nixos/modules/nmasur/profiles/gui.nix b/platforms/nixos/modules/nmasur/profiles/gui.nix index 46ec3af..9d3871f 100644 --- a/platforms/nixos/modules/nmasur/profiles/gui.nix +++ b/platforms/nixos/modules/nmasur/profiles/gui.nix @@ -82,15 +82,10 @@ in services.dbus.packages = [ pkgs.dconf ]; programs.dconf.enable = true; - # Make the login screen dark - services.xserver.displayManager.lightdm.greeters.gtk.theme = { - name = config.gtk.theme.name; - package = config.gtk.theme.package; - }; - - environment.sessionVariables = { - GTK_THEME = config.gtk.theme.name; - }; + # TODO: can we get rid of this? + # environment.sessionVariables = { + # GTK_THEME = config.gtk.theme.name; + # }; }; } diff --git a/platforms/nixos/modules/services/betterlockscreen.nix b/platforms/nixos/modules/services/betterlockscreen.nix index dc4c4b0..0ca4af2 100644 --- a/platforms/nixos/modules/services/betterlockscreen.nix +++ b/platforms/nixos/modules/services/betterlockscreen.nix @@ -7,7 +7,6 @@ let cfg = config.services.betterlockscreen; - lockCmd = "${pkgs.betterlockscreen}/bin/betterlockscreen --lock --display 1 --blur 0.5 --span"; in { @@ -29,7 +28,7 @@ in Type = "simple"; Environment = "DISPLAY=:0"; TimeoutSec = "infinity"; - ExecStart = lockCmd; + ExecStart = "${lib.getExe pkgs.betterlockscreen} --lock --display 1 --blur 0.5 --span"; ExecStartPost = "${pkgs.coreutils-full}/bin/sleep 1"; }; wantedBy = [