Is there a possibility to run a custom Notes server for iOS? I have notes where I strongly wish to avoid 3rd party cloud storage - even Apple’s

To that end, I am trying to set up my own one. iOS supports setting custom CalDAV server, so it is possible to handle Contacts, Reminders and Calendar with my server. Obviously, it is also possible to run own Mail server.

What is left is Notes. My research shows that Notes uses IMAP protocol internally.

I can see that if I set up an Exchange server account in Settings->Accounts, Notes will sync with that server.

My requirements are:


Use of the native notes app is preferred. Functionality including file attachments, document scanning, Apple Pencil handwriting and drawing are desired. 
Sharing notes with third party is optional and not required
I would like to self host on Linux hardware using free/opensource software (MS Exchange is not free, plus it requires running Windows Server).


Is it possible?
So it looks like this is impossible. 

Yes, Notes does support IMAP and this can be set up by adding an Email account to iOS (or macOS) and checking "Notes" there. 

However those kind of Notes are handicapped: you can't draw there with Apple Pencil, can't use any markdown like tables/bullets. Basically it is just Text and (image) attachments, making this app nearly useless (most of the notes I am making are made with Apple Pencil). 

What I like about internal Notes.app is that it is automatically launched upon an apple pencil tap on the locked screen - this is why I prefer it over 3rd party apps. But, when I tap on an IMAP-connected note, I am getting an Alert "Apple Pencil is supported only on iCloud notes". Damn.