brave-apps: module init

This commit is contained in:
Zynh Ludwig 2024-10-01 22:15:33 -07:00
parent 42f3235010
commit bdcb2844c4
3 changed files with 98 additions and 3 deletions

View file

@ -0,0 +1,85 @@
{ pkgs, lib, config, ... }:
let
inherit (lib) mkEnableOption mkOption mkIf;
inherit (lib.attrsets) mapAttrsToList;
inherit (builtins) filter toString attrNames attrValues length;
inherit (pkgs) writeShellScript writeShellScriptBin coreutils;
cfg = config.snowhawk.brave-apps;
in
{
options.snowhawk.brave-apps = {
enable = mkEnableOption "brave-apps home-manager module";
chromium-package = mkOption {
description = ''
chromium package to use for the chromium apps
'';
type = with lib.types; package;
default = pkgs.brave;
};
apps = mkOption {
description = ''
chromium based desktop apps configuration
'';
type = with lib.types; attrsOf (submodule {
options = {
url = mkOption {
description = ''
the url to open as a chromium window
only one of `url` `urlEval` or `urlFile` may be set
'';
default = null;
type = with lib.types; nullOr str;
};
urlEval = mkOption {
description = ''
the bash script to evaluate to get url to open as chromium window. May be useful for secrets management
only one of `url` `urlEval` or `urlFile` may be set
'';
default = null;
type = with lib.types; nullOr str;
};
urlFile = mkOption {
description = ''
file to read which contains the url to open as a chromium window. May be useful for secrets management
only one of `url` `urlEval` or `urlFile` may be set
'';
default = null;
type = with lib.types; nullOr str;
};
};
});
};
};
config = mkIf cfg.enable {
home.packages =
let
evalString = s: "\$(${s})";
readFile = f: evalString "${coreutils}/bin/cat ${f}";
writeChromiumDesktopApp = name: app: writeShellScriptBin name ''
${lib.getExe cfg.chromium-package} --new-window --app=${app}
'';
in
mapAttrsToList
(n: v:
assert lib.assertMsg (length (filter (v: v != null) (attrValues v)) == 1)
"only one of `url` `urlEval` or `urlFile` may be set: ${toString n} = ${toString (attrNames v)}";
(writeChromiumDesktopApp n (
if v.url != null then v.url
else if v.urlEval != null then evalString v.urlEval
else if v.urlFile != null then readFile v.urlFile
else throw "grr >:( -- this should be unreachable"
)
))
cfg.apps;
};
}

View file

@ -1,4 +1,4 @@
{ pkgs, ... }: { pkgs, config, ... }:
{ {
imports = [ imports = [
@ -15,6 +15,12 @@
alacritty.enable = true; alacritty.enable = true;
defaultPrograms.enable = true; defaultPrograms.enable = true;
pipewire-controller.enable = true; pipewire-controller.enable = true;
brave-apps.enable = true;
brave-apps.apps = {
github.url = "https://github.com";
zgit.url = "https://git.zynh.me";
slack_nh.urlFile = config.sops.secrets."app_urls/nh_slack".path;
};
# Games # Games
xivlauncher.enable = true; xivlauncher.enable = true;
@ -33,6 +39,8 @@
rbw.enable = true; rbw.enable = true;
}; };
sops.secrets."app_urls/nh_slack" = { };
snowhawk.ssh = { snowhawk.ssh = {
enable = true; enable = true;
homeNetwork = true; homeNetwork = true;

View file

@ -9,6 +9,8 @@ locations:
snowhawk: snowhawk:
lat: ENC[AES256_GCM,data:N7CsvQ==,iv:BfSp2jXBZDEEyNHhpo3SAwEVIWI0timAT2S1l76ODn0=,tag:Mf99+rM/m3Wh8BmmITKjpg==,type:str] lat: ENC[AES256_GCM,data:N7CsvQ==,iv:BfSp2jXBZDEEyNHhpo3SAwEVIWI0timAT2S1l76ODn0=,tag:Mf99+rM/m3Wh8BmmITKjpg==,type:str]
lon: ENC[AES256_GCM,data:dITeYwVzSA==,iv:s+St+As7wgAaUf8/qnAdCM932WY5c9S0qUFhUlzx3W0=,tag:iqqPhmHZ+t+CRZPdZxYVxA==,type:str] lon: ENC[AES256_GCM,data:dITeYwVzSA==,iv:s+St+As7wgAaUf8/qnAdCM932WY5c9S0qUFhUlzx3W0=,tag:iqqPhmHZ+t+CRZPdZxYVxA==,type:str]
app_urls:
nh_slack: ENC[AES256_GCM,data:0QSoU9NLXNUWIwPSMAetHWQ6bnbJCALVWgMicl/e75JJ2JsMZhdbMKEGbgz6g9nGLwU=,iv:8emkdI3E67+xZ7BRMhvMKGxrSMvkfW3fYD7TUr78c8I=,tag:6OzhaCP/Qy8hO7tv0mdz7A==,type:str]
passwords: passwords:
ravenshade: ENC[AES256_GCM,data:U0s7qQ4+JI6uzrNygzvMvlBM/W+swtAu6V/iQ1Ggcqq+KJrfrwgVhew7i/E0i8Z5JqSlfeeFGpwptanM0NKKINXYk1h5wF30eA==,iv:KNgx4HfHNi8i8kHBtA9ITy8q+5C8QqAgR69CXB7WPWM=,tag:edRqEMuzNA7aTrCmUCuF3w==,type:str] ravenshade: ENC[AES256_GCM,data:U0s7qQ4+JI6uzrNygzvMvlBM/W+swtAu6V/iQ1Ggcqq+KJrfrwgVhew7i/E0i8Z5JqSlfeeFGpwptanM0NKKINXYk1h5wF30eA==,iv:KNgx4HfHNi8i8kHBtA9ITy8q+5C8QqAgR69CXB7WPWM=,tag:edRqEMuzNA7aTrCmUCuF3w==,type:str]
sops: sops:
@ -35,8 +37,8 @@ sops:
Nk1jNmhBV2hFcFVXaVl0TE02L290NDgKq0JV2vKnHUio0d6p8Wo29skOdq1uzjGh Nk1jNmhBV2hFcFVXaVl0TE02L290NDgKq0JV2vKnHUio0d6p8Wo29skOdq1uzjGh
ViIFNODIG8pPVsXQZqCXDWgZIVsAwbavS43d4wkg8iSZ4h6o6sC23Q== ViIFNODIG8pPVsXQZqCXDWgZIVsAwbavS43d4wkg8iSZ4h6o6sC23Q==
-----END AGE ENCRYPTED FILE----- -----END AGE ENCRYPTED FILE-----
lastmodified: "2024-07-31T04:34:15Z" lastmodified: "2024-10-02T05:03:22Z"
mac: ENC[AES256_GCM,data:cgZUtls4VWsbWJp4kdQn4Qj39owxOYX0Ujl7V6fQJ2+NAefyGFhh396Q9uss00N7N6gR8cUNnhUBHjuxr/9AE1afzirQxTBbvmNtf57YFhty709yB3nJWgfuBy2WtgfVi26e5BZiRW+2WBREocAR71TIVm6fiyrn1iq0EaqL1yA=,iv:g6yJUQl5eR2OGmhjvileIITSx3zSyhFou2p8/pYFlLQ=,tag:dX3Yy1RiYyZI8eda8bvBrg==,type:str] mac: ENC[AES256_GCM,data:5uu8UWdvE28qmxi9WnmA/3PjUcnKuP+F78xmeiK8gyJjK0Pd88wt06TMk55ey8BadYkhGRa3+F28q4gu0QqPSau+6OeffOokZg1JkAWymWcVYyW1cMAha3YiUfO+iR9/8O59XdTB6QkfO5j94NYWZLOgtzy9AxxEFJ7VbYoUuEc=,iv:WXzDvJM5zu3jrQ4jfCl+iYzZAC5UCdHR0ZhW3WLmBZA=,tag:mpZ7qv813nBgvsIfquzDYA==,type:str]
pgp: [] pgp: []
unencrypted_suffix: _unencrypted unencrypted_suffix: _unencrypted
version: 3.9.0 version: 3.9.0