Running a desktop in a NixOS container with remote access

Do you know if it would be possible to run a desktop environment (like Gnome) in a NixOS container on my server (who does not have any physical monitor attached) and access it remotely via RDP. I would also like to install some apps like firefox or darktable.

I would like to setup something like this to experiment with a remote desktop. At the same time, this would allow me to stop it when I don’t need it (so don’t have gnome running all the time) and remove it if at some point get tired. When I remove the container, it would be nice that all the apps configs are in a specific dir (that I guess I should specify in the container configuration) so I can just wipe that folder and not being worried that my system is cluttered with config files in different places.

Never played with nixos containers and I am bit on beginner level with Nixos. However, at the moment I am achieving something similar with the docker images of linuxserver webtop and rdekstop but wanted to have a NixOS desktop instead of using an ubuntu or arch image provided by linuxserver.

I hope I have been enough clear :slight_smile:

Sure, it’s just a linux system. It’s of course possible.

Thanks. Do you know how it would work in connection with config folders? For example, if one of the package I install inside this container is Firefox and then I execute it remotely, do you know where its config folder will be located? On my user home folder under .config?
My plan was to avoid that and specify a folder that I can later remove if I delete the container.

By the way, google search results (the AI quick snippet) generated on the fly the below config to have a gnome deskop with nixos container. Does it look legit as an example or there is something more I should consider?

{
  services.containers.gnome-container = {
    autoStart = true;
    localImage = false;
    source.enable = true;
    source.type = "nixos";
    source.nixosVersion = "25.05"; # Replace with the NixOS version you want
    host Nixpkgs = config.nixpkgs;
    host NixosConfig = config.nixos;
    rootfs.source = builtins.fetchTarball {
      url = "https://nixos.org/channels/nixos-25.05/nixexprs.tar.xz"; # Replace with the NixOS version you want
    };
    config = {
      services.xserver.enable = true;
      services.xserver.displayManager.gdm.enable = true; # GNOME Display Manager
      services.xserver.desktopManager.gnome.enable = true; # GNOME Desktop Environment
      services.xserver.displayManager.gdm.wayland.enable = true; # Enable Wayland
      services.xserver.displayManager.gdm.autoLogin.enable = true;
      services.xserver.displayManager.gdm.autoLogin.user = "your_user"; # Replace with your username
      environment.systemPackages = with pkgs; [
        gnome # Install GNOME and its dependencies
      ];
    };
  };
}