nixos-configs/nixosModules/ags/packages.nix

149 lines
3.9 KiB
Nix
Raw Normal View History

2024-11-13 19:39:01 -05:00
self: {
config,
lib,
osConfig,
pkgs,
...
}: let
inherit (self.inputs) ags gtk-session-lock;
2024-12-14 19:36:54 -05:00
inherit (lib) attrValues boolToString getExe optionalAttrs optionals removeAttrs;
2024-11-13 19:39:01 -05:00
inherit (osConfig.networking) hostName;
cfg = config.programs.ags;
cfgDesktop = osConfig.roles.desktop;
2024-12-14 19:36:54 -05:00
mainPkg = pkgs.writeShellApplication {
name = "ags";
runtimeInputs = [cfg.package];
text = ''
if [ "$#" == 0 ]; then
exec ags run ~/${cfg.configDir} -a ${hostName}
else
exec ags "$@"
fi
'';
};
2024-11-13 19:39:01 -05:00
in {
config = {
# Make these accessible outside these files
programs.ags = {
package = ags.packages.${pkgs.system}.ags.override {
extraPackages = cfg.astalLibs;
};
astalLibs =
attrValues (
removeAttrs ags.inputs.astal.packages.${pkgs.system} [
"cava"
"powerprofiles"
"river"
# Not libraries
"docs"
"gjs"
]
2024-11-13 19:39:01 -05:00
)
++ [gtk-session-lock.packages.${pkgs.system}.default];
lockPkg = pkgs.writeShellApplication {
name = "lock";
runtimeInputs = [cfg.package];
text = ''
if [ "$#" == 0 ]; then
exec ags run ~/${cfg.configDir} -a lock
2024-11-13 19:39:01 -05:00
else
exec ags "$@" -i lock
fi
'';
};
};
home = {
packages =
[
2024-12-14 19:36:54 -05:00
mainPkg
2024-11-13 19:39:01 -05:00
(pkgs.writeShellApplication {
name = "agsConf";
runtimeInputs = [cfg.package];
text = ''
exec ags run ~/${cfg.configDir} -a "$1"
2024-11-13 19:39:01 -05:00
'';
})
]
2024-12-07 22:16:34 -05:00
++ (attrValues {
2024-11-13 19:39:01 -05:00
inherit
(pkgs)
playerctl
wayfreeze
2024-11-13 19:39:01 -05:00
;
})
2024-12-07 22:16:34 -05:00
++ (optionals cfgDesktop.isTouchscreen (attrValues {
2024-11-13 19:39:01 -05:00
inherit
(pkgs)
ydotool
;
}));
file = let
inherit
(self.lib.${pkgs.system})
2024-11-13 19:39:01 -05:00
buildNodeModules
buildGirTypes
;
in (
(buildGirTypes {
pname = "ags";
configPath = "${cfg.configDir}/@girs";
packages = cfg.astalLibs;
})
// {
"${cfg.configDir}/node_modules".source =
buildNodeModules ./config (import ./config).npmDepsHash;
2024-11-13 19:39:01 -05:00
"${cfg.configDir}/tsconfig.json".source = let
inherit (ags.packages.${pkgs.system}) gjs;
in
pkgs.writers.writeJSON "tsconfig.json" {
"$schema" = "https://json.schemastore.org/tsconfig";
"compilerOptions" = {
"experimentalDecorators" = true;
"strict" = true;
"target" = "ES2023";
"moduleResolution" = "Bundler";
"jsx" = "react-jsx";
"jsxImportSource" = "${gjs}/share/astal/gjs/gtk3";
"paths" = {
"astal" = ["${gjs}/share/astal/gjs"];
"astal/*" = ["${gjs}/share/astal/gjs/*"];
};
"skipLibCheck" = true;
"module" = "ES2022";
"lib" = ["ES2023"];
};
};
"${cfg.configDir}/widgets/lockscreen/vars.ts".text =
# javascript
''
export default {
mainMonitor: '${cfgDesktop.mainMonitor}',
dupeLockscreen: ${boolToString cfgDesktop.displayManager.duplicateScreen},
hasFprintd: ${boolToString (hostName == "wim")},
};
'';
}
2024-12-14 19:36:54 -05:00
// optionalAttrs cfgDesktop.isTouchscreen {
".config/fcitx5/conf/virtualkeyboardadapter.conf".text = ''
ActivateCmd="${getExe mainPkg} request 'show-osk'"
DeactivateCmd="${getExe mainPkg} request 'hide-osk'"
'';
}
2024-11-13 19:39:01 -05:00
);
};
};
# For accurate stack trace
_file = ./default.nix;
}