Bspwm & sxhkd not work

I’m using VirtualBox to run NixOS. My configuration.nix file for installing bspwm and sxhkd is as the following

  services.xserver = {
     enable = true;
     autorun = false;
     layout = "us";
     xkbOptions = "eurosign:e";
     displayManager.defaultSession = "none+bspwm";
     windowManager.bspwm.enable = true;
     windowManager.bspwm.configFile = builtins.getEnv "HOME" + "/.config/bspwm/bspwmrc";
     windowManager.bspwm.sxhkd.configFile = builtins.getEnv "HOME" + "/.config/sxhkd/sxhkdrc";
     desktopManager.xterm.enable = false;

bspwmrc and sxhkdrc are config files I’m using in Archlinux without any problem.

In tty, I issue the following command to start X
sudo systemctl start display-manager
The following login screen is displayed

After inputting login info, all I got is a blank screen. I tried pressing Windows key + Return, which is my config in sxhkd to open a new Terminal window, but nothing shows up

Could you please point out where I’m wrong?

Have you checked versions from each repository and documentation/changelog if your config might contain stuff that is not allowed yet/anymore in the nix version?

     windowManager.bspwm.configFile = builtins.getEnv "HOME" + "/.config/bspwm/bspwmrc";
     windowManager.bspwm.sxhkd.configFile = builtins.getEnv "HOME" + "/.config/sxhkd/sxhkdrc";

It’s worth mentioning that these configurations don’t copy thee configuration file into the VM, they’re treated as strings, without any other meaning. Further $HOME/.config/bspwm/bspwmrc is the default when nothing is specified. Perhaps you need to copy these files into the VM and/or remove these values from your configuration.

Many thanks. I removed those 2 lines and it works!

I actually have these files at these locations but I don’t understand why NixOS doesn’t read them.

Supposed that I want to place these files at $HOME/.config/bspwmrc and $HOME/.config/sxhkdrc (non-default locations), how should I config these locations for windowManager.bspwm.configFile and windowManager.bspwm.sxhkd.configFile?

1 Like

From looking at the code implementing those modules (nixpkgs/bspwm.nix at 6ca121a4793ced5279e26f0d51c2d08bf21799a3 · NixOS/nixpkgs · GitHub). It seems to any configuration done there becomes an argument to bspwm when run. It’s run in a shell, under the user’s profile. Perhaps the string $HOME/.config/bspwmrc without the builtins.getEnv would work.

If I use a string like "$HOME/.config/bspwmrc", when I run sudo nixos-rebuild switch, I got the following error

The option value 'services.xserver.windowManager.bspwm.sxhkd.configFile" in /etc/nixos/configuration.nix' is not of type 'null or path'.

How can I make a path that includes $HOME environment? I tried with builtins.getEnv but obviously, NixOS can’t use these config files.

Ah, dang. What you want is not possible from the bspwm module and configuration.nix. Perhaps home manager is the solution to this?

To directly answer your question: You can’t have a path with an environment variable in it (to my knowledge).

1 Like