summaryrefslogtreecommitdiff
path: root/x/default.nix
blob: a06070113bdaa66c839329e422ec5a5de237671f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{
  config,
}: rec {

  pkgs = (import ../pkgs.nix).stable {};

  innerEnv = pkgs.buildEnv {
    name = "x-inner-env";
    paths = [
      pkgs.xorg.xorgserver
      pkgs.xorg.xinit
      pkgs.xorg.xauth
      pkgs.xorg.xset
      pkgs.xorg.xf86inputlibinput

      (pkgs.runCommand "xorg-conf-inner" {} ''
         mkdir -p "$out"/share/X11/xorg.conf.d/
         cp ${./xorg.conf} "$out"/share/X11/xorg.conf.d/99-loadout.conf
       '')
    ];
  };

  conf = pkgs.runCommand "xorg-conf" {} ''
    cat >>"$out" <<EOF
Section "Files"
    ModulePath "${innerEnv}/lib/xorg/modules"
EndSection

${config.xorgConfExtra}
EOF

    for f in $(ls ${innerEnv}/share/X11/xorg.conf.d | sort); do
      cat ${innerEnv}/share/X11/xorg.conf.d/"$f" >> "$out"
    done

  '';

  startx = pkgs.writeShellScriptBin "startx" ''
    export XORGCONFIG=${conf}
    export PATH=${innerEnv}/bin:$PATH
    exec startx
  '';
}