Nixos configuration set wallpaper / write files to user/root home [without home-manager]

Writing an nixos ISO I was wondering

  • how to set a wallpaper via the configuration.nix [in the context of sddm and kde/plasma5]?

  • I couldn’t find a nixos option for this purpose.

  • It doesn’t look to be contained in the

/etc/sddm.conf cat /etc/sddm.conf [General] DefaultSession=plasma.desktop HaltCommand=/run/current-system/systemd/bin/systemctl poweroff Numlock=none RebootCommand=/run/current-system/systemd/bin/systemctl reboot

[Theme]
Current=breeze
FacesDir=/run/current-system/sw/share/sddm/faces
ThemeDir=/run/current-system/sw/share/sddm/themes

[Users]
HideShells=/run/current-system/sw/bin/nologin
HideUsers=nixbld1,nixbld10,nixbld11,nixbld12,nixbld13,nixbld14,nixbld15,nixbld16,nixbld17,nixbld18,nixbld19,nixbld2,nixbld20,nixbld21,nixbld22,nixbld23,nixbld24,nixbld25,nixbld26,nixbld27,nixbld28,nixbld29,nixbld3,nixbld30,nixbld31,nixbld32,nixbld4,nixbld5,nixbld6,nixbld7,nixbld8,nixbld9
MaximumUid=30000

[Wayland]
EnableHiDPI=true
SessionDir=/nix/store/xkiir7rycm17fkj2hp3sx92j0n1mfiq6-desktops/share/wayland-sessions

[X11]
DisplayCommand=/nix/store/pkbir1m8r5rbfbli3gx9zb6hq9fy0wr8-Xsetup
DisplayStopCommand=/nix/store/f65a4xsnppr1bkd97lvs3iklc5kll3p0-Xstop
EnableHiDPI=true
MinimumVT=7
ServerPath=/nix/store/589p9881zq3zjj0sbd35z6ycg3j4dl3l-xserver-wrapper
SessionCommand=/nix/store/ivav73slg6i8an1if0ghrd51c6h32bn2-xsession-wrapper
SessionDir=/nix/store/xkiir7rycm17fkj2hp3sx92j0n1mfiq6-desktops/share/xsessions
XauthPath=/nix/store/gdarrflk8yg6261r0m0pr2p0xn8cvyrb-xauth-1.1.2/bin/xauth
XephyrPath=/nix/store/y9l9mbf313idyqck1zbv6s72xj1a4phy-xorg-server-21.1.8/bin/Xephyr

and because

In the doc one can find:
services.xserver.desktopManager.wallpaper.mode

services.xserver.desktopManager.wallpaper.mode

~/.background-image

It raises the question, how to write a file into the user space [without home-manager - which is no option to use]?


If a file gets written into nix/store Write binary file to nix store

  • how to symlink it into the root/user space home?

or to create the home user folder

things like

  • environment.home = {
    – doesn’t work

Well, this is how that option is applied: nixpkgs/nixos/modules/services/x11/desktop-managers/default.nix at d8bb6c681cf86265fdcf3cc3119f757bbb085835 · NixOS/nixpkgs · GitHub

So there’s no way to set the background declaratively currnently. An easy fix would be to change that module to also allow setting an actual image; just takes adding a new option and using it in that command.

I too thought there was an easy way, but it seems there isn’t - I suspect this is because it’s hard to guarantee the directories exist correctly upfront if mutable users is in use.

As an alternative, consider creating a systemd oneshot user unit that copies the image, or populating the skel directory.

1 Like