I want to edit .desktop files of some nixpkgs for customization, but they are located in /run/current-system/sw/share/applications.. and are readable only.

One possible solution would be to copy them to ~/.local/share/applications but duplicating doesnt sit right with me (this would be my last resort tho).

I would prefer to override the parameters I want to change somehow preferably in my configuration.nix only.

  • Oinks@lemmy.blahaj.zone
    link
    fedilink
    English
    arrow-up
    5
    ·
    edit-2
    1 year ago

    Another alternative approach would be to add a duplicate desktop file, but to write it declaratively using Home Manager:

    # in home.nix
    home.file.".local/share/applications/firefox.desktop".source =
      pkgs.runCommand "firefox-desktop" { } ''
        cp "${pkgs.firefox}/share/applications/firefox.desktop" "$out"
        substituteInPlace "$out" \
          --replace-fail "Terminal=false" "Terminal=true"
      '';
    
    # - or -
    home.file.".local/share/applications/firefox.desktop".text = ''
      [Desktop Entry]
      Name=Firefox
      Icon=firefox
      Exec=firefox --name firefox %U
    '';
    

    It would be possible to DIY this with user activation scripts, but I don’t really see a value in doing that over the symlinkJoin.