13f35677be
Move Home Manager module defaults from a centralized `desktop-home-defaults.nix` file into their respective `wisdom` slices. This change aligns with the updated documentation regarding module ownership, where defaults live with the option that owns them rather than in a shared defaults file. Additionally, update `docs/conventions.md` to reflect this new pattern for defining `mkEnableOption` defaults and move base git/encryption configurations into the core `wisdom` module. - Delete `modules/hosts/desktop-home-defaults.nix` - Update `modules/wisdom/default.nix` to include shared git and package defaults - Add `default = ...` to `mkEnableOption` in various `wisdom` modules - Update `docs/conventions.md` with new HM slice guidelines
76 lines
2.7 KiB
Nix
76 lines
2.7 KiB
Nix
{ ... }: {
|
|
flake.homeManagerModules.wisdomDesktopScreenshot =
|
|
{ config, lib, pkgs, ... }:
|
|
let
|
|
root = config.chiasson.home;
|
|
cfg = config.chiasson.home.desktop.screenshot;
|
|
hyprlandHm = lib.attrByPath [ "wayland" "windowManager" "hyprland" ] { } config;
|
|
hyprlandHmEnabled = hyprlandHm.enable or false;
|
|
keyOk = cfg.swiftshareApiKeyFile != null && cfg.swiftshareApiKeyFile != "";
|
|
uploadScript = builtins.readFile ./scripts/swiftshare-upload.sh;
|
|
screenshotScript = builtins.readFile ./scripts/swiftshare-screenshot.sh;
|
|
in
|
|
{
|
|
options.chiasson.home.desktop.screenshot.enable = lib.mkEnableOption ''
|
|
grim/slurp/swappy + SwiftShare helpers; Hyprland binds if HM Hyprland is on.
|
|
'' // {
|
|
default = true;
|
|
};
|
|
|
|
options.chiasson.home.desktop.screenshot.swiftshareApiKeyFile = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.str;
|
|
default = "/run/secrets/swiftshare/API_KEY";
|
|
description = ''
|
|
File with SwiftShare API key (sops path is fine). Required when screenshot module is on.
|
|
'';
|
|
};
|
|
|
|
config = lib.mkMerge [
|
|
(lib.mkIf (root.enable && cfg.enable) {
|
|
assertions = [
|
|
{
|
|
assertion = keyOk;
|
|
message = "chiasson.home.desktop.screenshot: set chiasson.home.desktop.screenshot.swiftshareApiKeyFile to your SwiftShare API key file path.";
|
|
}
|
|
];
|
|
})
|
|
(lib.mkIf (root.enable && cfg.enable && keyOk) (
|
|
let
|
|
apiKeyFile = cfg.swiftshareApiKeyFile;
|
|
swiftshareUpload = pkgs.writeShellScriptBin "swiftshare-upload" (
|
|
builtins.replaceStrings [ "@API_KEY_FILE@" ] [ apiKeyFile ] uploadScript
|
|
);
|
|
swiftshareScreenshot = pkgs.writeShellScriptBin "swiftshare-screenshot" screenshotScript;
|
|
in
|
|
lib.mkMerge [
|
|
{
|
|
home.packages = with pkgs; [
|
|
grim
|
|
slurp
|
|
swappy
|
|
wl-clipboard
|
|
libnotify
|
|
curl
|
|
jq
|
|
swiftshareUpload
|
|
swiftshareScreenshot
|
|
];
|
|
}
|
|
(lib.mkIf hyprlandHmEnabled {
|
|
wayland.windowManager.hyprland.settings = {
|
|
bind = [
|
|
", Print, exec, grim -g \"$(slurp)\" - | wl-copy"
|
|
"Control, Print, exec, grim -g \"$(slurp)\" - | swappy -f -"
|
|
"SUPER, Print, exec, swiftshare-screenshot"
|
|
];
|
|
windowrule = [
|
|
"float on, opacity 1.0 override, match:class ^(swappy)$"
|
|
];
|
|
};
|
|
})
|
|
]
|
|
))
|
|
];
|
|
};
|
|
}
|