How to remove "Desktop" from the Nemo sidebar?

In dconf-editor, you should be able to set org/nemo/desktop/show-desktop-icons is false but in NixOS I don’t see a org/nemo/desktop entry. Do I need to add something to my configuration.nix file to get this to show up?

You have to search for it, but there is a org.gnome.desktop.background.show-desktop-icons, which is slightly different from the schema listed in the github issue below, but it’s set to false and the Desktop link is still in the sidebar.

For details, please see: https://github.com/linuxmint/nemo/issues/1442

This is intentional. See GSettings schema of installed software not available to gsettings program or dconf-editor · Issue #33277 · NixOS/nixpkgs · GitHub for a workaround.

I’m not sure where to get the nemo specific file path for XDG_DATA_DIRS. In the example shown, it looks like it’s for gedit?

I tried running that script and it doesn’t seem to do anything. Here’s the output I got:

Usage:
  gsettings --version
  gsettings [--schemadir SCHEMADIR] COMMAND [ARGS…]

Commands:
  help                      Show this information
  list-schemas              List installed schemas
  list-relocatable-schemas  List relocatable schemas
  list-keys                 List keys in a schema
  list-children             List children of a schema
  list-recursively          List keys and values, recursively
  range                     Queries the range of a key
  describe                  Queries the description of a key
  get                       Get the value of a key
  set                       Set the value of a key
  reset                     Reset the value of a key
  reset-recursively         Reset all values in a given schema
  writable                  Check if a key is writable
  monitor                   Watch for changes

Use “gsettings help COMMAND” to get detailed help.

Any suggestions?

You can run nix-build -A cinnamon.nemo in Nixpkgs directory to get something like /nix/store/a2i5iffkbyzkmg5d2hwgxl705f9dc47g-nemo-6.0.2. Then you can append /share/gsettings-schemas/nemo-6.0.2 to that.

Alternately, you can open a REPL in Nixpkgs directory and run the command below:

$ nix repl .
nix-repl> glib.getSchemaDataDirPath cinnamon.nemo
"/nix/store/a2i5iffkbyzkmg5d2hwgxl705f9dc47g-nemo-6.0.2/share/gsettings-schemas/nemo-6.0.2"

Or if you want non-interactive method:

$ nix-instantiate --eval --expr 'let pkgs = import <nixpkgs> {}; in pkgs.glib.getSchemaDataDirPath pkgs.cinnamon.nemo'
"/nix/store/a2i5iffkbyzkmg5d2hwgxl705f9dc47g-nemo-6.0.2/share/gsettings-schemas/nemo-6.0.2"

Don’t forget the double quotes are not part of the path.

Now we’re starting to get somewhere. Here’s what the command and output look like:

❯ env XDG_DATA_DIRS=/nix/store/db8g9qvkzbfmkhs315ksr249b7jfqbix-nemo-6.0.2/share/gsettings-schemas/nemo-6.0.2 gsettings list-schemas
org.nemo
org.nemo.compact-view
org.nemo.desktop
org.nemo.icon-view
org.nemo.list-view
org.nemo.plugins
org.nemo.preferences
org.nemo.preferences.menu-config
org.nemo.search
org.nemo.sidebar-panels
org.nemo.sidebar-panels.tree
org.nemo.window-state

But it says “no schemas installed” when I run: gsettings set org.nemo.desktop show-desktop-icons false

How are no schemas installed when it’s able to list them?

Did you run gsettings set with the XDG_DATA_DIRS environment variable too? env will only pass the variables to the command specified as env’s argument.

That worked! Thank you for guiding me through that.

For anyone else that stumbles on this, I was able to set the gsettings schema with:
env XDG_DATA_DIRS=/nix/store/db8g9qvkzbfmkhs315ksr249b7jfqbix-nemo-6.0.2/share/gsettings-schemas/nemo-6.0.2 gsettings set org.nemo.desktop show-desktop-icons false

Note that the path will change as you upgrade Nixpkgs, and the old one will stop working when it is eventually garbage collected, so remember to obtain it from scratch after each update.

1 Like

There’s no way to safely add something to the configuration.nix file to avoid having to redo this after ever update I take it?

GSettings system is somewhat global by nature, which is antithesis of Nix. There are countless potentially unsafe ways (e.g. environment.essionVariables or sessionPath) but they do not really follow the Nix way™.

Cleanest safe method will probably be creating a separate program that has necessary schemas passed to it hermetically, something like the following:

environment.systemPackages = [
  (let
    packagesWithSchemas = [
      pkgs.cinnamon.nemo
    ];
  in
  pkgs.runCommand "ngsettings" {
    nativeBuildInputs = [
      pkgs.makeWrapper
    ];
  } ''
    mkdir -p "$out/bin"
    # Creates ngsettings program (wrapped gsettings)
    makeWrapper "${pkgs.glib.bin}/bin/gsettings" "$out/bin/ngsettings" \
      --set XDG_DATA_DIRS "${lib.concatMapStringsSep ":" pkgs.glib.getSchemaDataDirPath packagesWithSchemas}"
  '')
  ];
1 Like

It’s not liking the duplicate environment statement. I have a long list of packages and would like to avoid adding “pkgs.” in front of every app to get this all into one statement. Is there a way to work it in with my package list:

environment.systemPackages = with pkgs; [
alacritty

zoxide
];

Just put the in parentheses (including parentheses) inside your environment.systemPackages. And since you use with expression, you will be able to remove pkgs. prefixes (but it will work if you keep them as well).

Fantastic! That survived an update and reboot. Thanks again for the help.