feat: auto generate remmina desktop entries
This commit is contained in:
@@ -133,6 +133,7 @@ sessionVariables.BROWSER = if device.isDarwin then "open" else "xdg-open";
|
|||||||
2. **DO NOT add shell scripts** - use Nix expressions
|
2. **DO NOT add shell scripts** - use Nix expressions
|
||||||
3. **All configurations must use Nix expressions** when possible
|
3. **All configurations must use Nix expressions** when possible
|
||||||
4. **Follow existing naming conventions** and directory structure
|
4. **Follow existing naming conventions** and directory structure
|
||||||
|
5. Create custom application entries in `~/.local/share/applications/{appname}.desktop`
|
||||||
|
|
||||||
## Secrets Management
|
## Secrets Management
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,10 @@
|
|||||||
device,
|
device,
|
||||||
cratesNix,
|
cratesNix,
|
||||||
...
|
...
|
||||||
}:
|
}: let
|
||||||
lib.mkIf (!device.isServer) {
|
cargo-credential-1password = cratesNix.buildCrate "cargo-credential-1password" {};
|
||||||
|
in
|
||||||
|
lib.mkIf (!device.isServer) {
|
||||||
home.file.".cargo/config.toml".text =
|
home.file.".cargo/config.toml".text =
|
||||||
# toml
|
# toml
|
||||||
''
|
''
|
||||||
@@ -19,9 +21,9 @@ lib.mkIf (!device.isServer) {
|
|||||||
index = "sparse+https://crates.darksailor.dev/api/v1/crates/"
|
index = "sparse+https://crates.darksailor.dev/api/v1/crates/"
|
||||||
|
|
||||||
[registry]
|
[registry]
|
||||||
global-credential-providers = ["cargo:token", "/etc/profiles/per-user/fs0c131y/bin/cargo-credential-1password --account my.1password.com"]
|
global-credential-providers = ["cargo:token", "${lib.getExe cargo-credential-1password} --account my.1password.com"]
|
||||||
'';
|
'';
|
||||||
home.packages = [
|
home.packages = [
|
||||||
(cratesNix.buildCrate "cargo-credential-1password" {})
|
cargo-credential-1password
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,68 @@
|
|||||||
{device, ...}: {
|
{
|
||||||
|
device,
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
with lib; let
|
||||||
|
remminaDir = "${config.home.homeDirectory}/.local/share/remmina";
|
||||||
|
applicationsDir = "${config.home.homeDirectory}/.local/share/applications";
|
||||||
|
|
||||||
|
# Script to generate desktop entries for Remmina connections
|
||||||
|
generateRemminaDesktopEntries = pkgs.writeShellScript "generate-remmina-desktop-entries" ''
|
||||||
|
REMMINA_DIR="${remminaDir}"
|
||||||
|
APPS_DIR="${applicationsDir}"
|
||||||
|
|
||||||
|
# Create applications directory if it doesn't exist
|
||||||
|
mkdir -p "$APPS_DIR"
|
||||||
|
|
||||||
|
# Remove old remmina desktop entries
|
||||||
|
rm -f "$APPS_DIR"/remmina-*.desktop
|
||||||
|
|
||||||
|
# Exit if remmina directory doesn't exist
|
||||||
|
[[ ! -d "$REMMINA_DIR" ]] && exit 0
|
||||||
|
|
||||||
|
# Generate desktop entries for each .remmina file
|
||||||
|
find "$REMMINA_DIR" -name "*.remmina" -type f | while read -r file; do
|
||||||
|
# Extract connection details
|
||||||
|
name=$(${pkgs.gnugrep}/bin/grep "^name=" "$file" | ${pkgs.coreutils}/bin/cut -d'=' -f2-)
|
||||||
|
server=$(${pkgs.gnugrep}/bin/grep "^server=" "$file" | ${pkgs.coreutils}/bin/cut -d'=' -f2-)
|
||||||
|
protocol=$(${pkgs.gnugrep}/bin/grep "^protocol=" "$file" | ${pkgs.coreutils}/bin/cut -d'=' -f2-)
|
||||||
|
|
||||||
|
# Use filename as fallback if name is empty
|
||||||
|
[[ -z "$name" ]] && name=$(${pkgs.coreutils}/bin/basename "$file" .remmina)
|
||||||
|
[[ -z "$protocol" ]] && protocol="Unknown"
|
||||||
|
|
||||||
|
# Generate desktop entry filename
|
||||||
|
desktop_name=$(${pkgs.coreutils}/bin/basename "$file" .remmina | ${pkgs.gnused}/bin/sed 's/[^a-zA-Z0-9_-]/-/g')
|
||||||
|
desktop_file="$APPS_DIR/remmina-$desktop_name.desktop"
|
||||||
|
|
||||||
|
# Create desktop entry
|
||||||
|
cat > "$desktop_file" <<EOF
|
||||||
|
[Desktop Entry]
|
||||||
|
Type=Application
|
||||||
|
Name=Remmina - $name
|
||||||
|
GenericName=$protocol Connection to $server
|
||||||
|
Comment=Connect to $server via $protocol
|
||||||
|
Exec=${pkgs.remmina}/bin/remmina -c "$file"
|
||||||
|
Icon=org.remmina.Remmina
|
||||||
|
Terminal=false
|
||||||
|
Categories=Network;RemoteAccess;
|
||||||
|
EOF
|
||||||
|
done
|
||||||
|
'';
|
||||||
|
in {
|
||||||
services.remmina = {
|
services.remmina = {
|
||||||
enable = device.is "ryu";
|
enable = device.is "ryu";
|
||||||
systemdService.enable = true;
|
systemdService.enable = true;
|
||||||
addRdpMimeTypeAssoc = true;
|
addRdpMimeTypeAssoc = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Activation script to generate desktop entries
|
||||||
|
home.activation.generateRemminaDesktopEntries = mkIf (device.is "ryu") (
|
||||||
|
lib.hm.dag.entryAfter ["writeBoundary"] ''
|
||||||
|
run ${generateRemminaDesktopEntries}
|
||||||
|
''
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user