# How to use an existing xorg.conf, rather than a nixos-generated one?

**URL:** https://discourse.nixosstag.fcio.net/t/how-to-use-an-existing-xorg-conf-rather-than-a-nixos-generated-one/18318
**Category:** Help
**Created:** [March 23, 2022, 12:35am UTC](https://discourse.nixosstag.fcio.net/t/how-to-use-an-existing-xorg-conf-rather-than-a-nixos-generated-one/18318 "2022-03-23T00:35:31Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![smkuehnhold](https://discourse.nixosstag.fcio.net/user_avatar/discourse.nixosstag.fcio.net/smkuehnhold/32/4326_2.png) [@smkuehnhold](https://discourse.nixosstag.fcio.net/u/smkuehnhold)
#### Post date: [March 23, 2022, 12:35am UTC](https://discourse.nixosstag.fcio.net/t/how-to-use-an-existing-xorg-conf-rather-than-a-nixos-generated-one/18318/1 "2022-03-23T00:35:31Z")

</div>

Howdy!

I would like to know if there is a way to use an existing `xorg.conf` rather than the one that is generated by the nixos modules. Reason being is that I would like to see if a more conventional approach to xorg config [will get my egpu to work](https://discourse.nixosstag.fcio.net/t/the-struggle-to-get-thunderbolt-egpu-to-output-to-its-display-at-all-in-nixos/14394).

I have tried to set `services.xserver.exportConfiguration` equal to false so I could copy a file over manually, but it seems that this conflicts with my display manager (startx)

Thanks,  
smkuehnhold

---

<div class="post-metadata">

### Author: ![TLATER](https://discourse.nixosstag.fcio.net/user_avatar/discourse.nixosstag.fcio.net/tlater/32/4257_2.png) [@TLATER](https://discourse.nixosstag.fcio.net/u/TLATER)
#### Post date: [March 23, 2022, 1:48am UTC](https://discourse.nixosstag.fcio.net/t/how-to-use-an-existing-xorg-conf-rather-than-a-nixos-generated-one/18318/2 "2022-03-23T01:48:19Z")

</div>

The problem is probably this line, which to me looks like it overrides the config to use the generated one even if you set that option: [https://github.com/NixOS/nixpkgs/blob/01e87b327aa89d9d60fba192085bccddaa2d1b24/nixos/modules/services/x11/xserver.nix#L731](https://github.com/NixOS/nixpkgs/blob/01e87b327aa89d9d60fba192085bccddaa2d1b24/nixos/modules/services/x11/xserver.nix#L731)

Maybe that should be considered a bug?

I imagine you can override that with `services.xserver.displayManager.xserverArgs = ["-config" <config>];`, assuming X will override on duplicate args?

---

<div class="post-metadata">

### Author: ![smkuehnhold](https://discourse.nixosstag.fcio.net/user_avatar/discourse.nixosstag.fcio.net/smkuehnhold/32/4326_2.png) [@smkuehnhold](https://discourse.nixosstag.fcio.net/u/smkuehnhold)
#### Post date: [March 23, 2022, 9:52am UTC](https://discourse.nixosstag.fcio.net/t/how-to-use-an-existing-xorg-conf-rather-than-a-nixos-generated-one/18318/3 "2022-03-23T09:52:21Z")

</div>

> [@TLATER](#):
>
> assuming X will override on duplicate args?

Unfortunately, this does not seem to be the case. After making these changes, my `Xorg.0.log` says that it is loading the config directly from the store. (Which kind of invalidates the original idea ) ☹

---

<div class="post-metadata">

### Author: ![TLATER](https://discourse.nixosstag.fcio.net/user_avatar/discourse.nixosstag.fcio.net/tlater/32/4257_2.png) [@TLATER](https://discourse.nixosstag.fcio.net/u/TLATER)
#### Post date: [March 23, 2022, 11:02am UTC](https://discourse.nixosstag.fcio.net/t/how-to-use-an-existing-xorg-conf-rather-than-a-nixos-generated-one/18318/4 "2022-03-23T11:02:26Z")

</div>

😑 You can try prepending with `lib.mkBefore` and completely overriding with `lib.mkForce` too, I think.

Can you see the args X is running with anywhere to confirm? `ps` should show them while it’s running. If I am indeed correct, the alternative is a quick patch to nixpkgs to fix this.

---

<div class="post-metadata">

### Author: ![smkuehnhold](https://discourse.nixosstag.fcio.net/user_avatar/discourse.nixosstag.fcio.net/smkuehnhold/32/4326_2.png) [@smkuehnhold](https://discourse.nixosstag.fcio.net/u/smkuehnhold)
#### Post date: [March 23, 2022, 10:10pm UTC](https://discourse.nixosstag.fcio.net/t/how-to-use-an-existing-xorg-conf-rather-than-a-nixos-generated-one/18318/5 "2022-03-23T22:10:43Z")

</div>

> [@TLATER](#):
>
> Can you see the args X is running with anywhere to confirm? `ps` should show them while it’s running. If I am indeed correct, the alternative is a quick patch to nixpkgs to fix this.

It seems that the args are duplicated which is interesting.

```auto
/nix/store/mxg8z2h658hgdpv6gcyyjk4xbnj601gp-xorg-server-1.20.13/bin/X -config /etc/X11/xorg2.conf -config /nix/store/d4k2kxdjhcx376xmmmqqx3ykdmw4npni-xserver.conf -xkbdir /nix/store/mkhijsslpa19kynnhi4cyag3j27k3dw2-xkeyboard-config-2.33/etc/X11/xkb :0 vt7 -dpi 192 -verbose 3 -nolisten tcp -terminate :0 vt1 -keeptty -auth /home/smkuehnhold/.serverauth.1563

```

My logfile however still says that it is reading the config from the store, so I wonder if there is a defined precedence.

---

<div class="post-metadata">

### Author: ![smkuehnhold](https://discourse.nixosstag.fcio.net/user_avatar/discourse.nixosstag.fcio.net/smkuehnhold/32/4326_2.png) [@smkuehnhold](https://discourse.nixosstag.fcio.net/u/smkuehnhold)
#### Post date: [March 23, 2022, 10:30pm UTC](https://discourse.nixosstag.fcio.net/t/how-to-use-an-existing-xorg-conf-rather-than-a-nixos-generated-one/18318/6 "2022-03-23T22:30:26Z")

</div>

> [@TLATER](#):
>
> I imagine you can override that with `services.xserver.displayManager.xserverArgs = ["-config" <config>]`

> [@TLATER](#):
>
> You can try prepending with `lib.mkBefore` and completely overriding with `lib.mkForce` too, I think.

> [@smkuehnhold](#):
>
> I wonder if there is a defined precedence.

It seems from a quick test that X uses the later definition of config. So by using `lib.mkAfter` instead, I was able to point to the existing xorg.conf within my filesystem. And with that manual config, I was finally able to get _an_ output from my eGPU (or at least I was able to get my monitor connected to my eGPU to display a screen) 🎉

---

<div class="post-metadata">

### Author: ![smkuehnhold](https://discourse.nixosstag.fcio.net/user_avatar/discourse.nixosstag.fcio.net/smkuehnhold/32/4326_2.png) [@smkuehnhold](https://discourse.nixosstag.fcio.net/u/smkuehnhold)
#### Post date: [March 23, 2022, 10:34pm UTC](https://discourse.nixosstag.fcio.net/t/how-to-use-an-existing-xorg-conf-rather-than-a-nixos-generated-one/18318/7 "2022-03-23T22:34:00Z")

</div>

A bit off-topic, but do you have any knowledge of xserver configuration? If so, I’d appreciate your help over on [the other thread](https://discourse.nixosstag.fcio.net/t/the-struggle-to-get-thunderbolt-egpu-to-output-to-its-display-at-all-in-nixos/14394). My manual config and the one generated via nixos are not that different, so I don’t expect it to be a lot of work to diagnose the issue.

---

<div class="post-metadata">

### Author: ![TLATER](https://discourse.nixosstag.fcio.net/user_avatar/discourse.nixosstag.fcio.net/tlater/32/4257_2.png) [@TLATER](https://discourse.nixosstag.fcio.net/u/TLATER)
#### Post date: [March 24, 2022, 1:16am UTC](https://discourse.nixosstag.fcio.net/t/how-to-use-an-existing-xorg-conf-rather-than-a-nixos-generated-one/18318/8 "2022-03-24T01:16:06Z")

</div>

I’ve dabbled, I’ll take a look some time; I live near GMT so should probably not be browsing the discourse at this hour 😉

I think this is worth an upstream issue, too, by the way. You shouldn’t need to override the config twice. I’ll make one tomorrow, and a quick patch while I’m at it.
