Here is my derivation for this,
$$\int |x|dx= \int \sqrt {x^2} dx = I$$
By integration by parts we know that,
$$ \int u(x)v(x)\,dx=u(x)\int v(x) \ dx-\int u'(x) \left [ \int v(x) \ dx \right ]dx$$
This is just a extension of the product rule in diffrentiation. Check out the wiki page.
So taking $u(x) = |x|$ and $v(x) =1$,
$$I = \int |x| \times 1 \ \ dx = |x| \int 1\ dx - \int \left [ \frac{d(|x|) }{dx}\int 1 \ dx \right ]dx $$
Now we can differentiate the absolute value of $x$ using chain rule,
$$\frac{d(|x|) }{dx} = \frac{d(\sqrt {x^2}) }{dx} = \frac{1}{2\sqrt{x^2}} (2x)= \frac{x}{\sqrt{x^2}} $$
Trivially we can say $ \int 1 \ dx = x$.
Substituting this in $I$,
$$I = |x|x \ - \ \int\frac{x}{\sqrt{x^2}} \ x \ dx$$
$$I = |x|x \ - \ \int\frac{x^2}{\sqrt{x^2}} \ dx$$
Because both $x^2$ and $\sqrt{x^2}$ are positive, we can rewrite this as,
$$I = |x|x \ - \ \int{\sqrt{x^2}} \ dx =|x|x \ - I $$
So as we have the same integral in the RHS, we take it to the LHS.
$$2I = |x|x$$
So we can conclude,
$$I(x) = \frac{x|x|}{2}$$
Try this out for yourself the area under the $|x|$ curve from $x=a$ to $x=b$ can be expressed as $I(b) - I(a)$.
The antiderivative of $|x|$ is a function $g(x)$ such that $g'(x) = |x|$. Note that for any value of $C$, $g(x) + C$ can also be such an antiderivative. So we add a Constant of integration.
SIDE NOTE :
In case the integration by parts formula I gave above is confusing,
consider
$$\frac{d(a(x) \ b(x)) }{dx} = a'(x) \ b(x) + a(x) \ b'(x)$$
Integrating both sides,
$$\int \frac{d(a(x) \ b(x)) }{dx} = a(x) \ b(x) = \int a'(x) \ b(x) + \int a(x) \ b'(x)$$
If we substitute $a(x) = u(x)$ and $b'(x) = v(x)$, so $b(x) = \int v(x)$ and $a'(x) = u'(x)$
$$u(x)\int v(x) = \int u'(x) \left [ \int v(x) \ dx \right ]dx + \int u(x) \ v(x)$$
Thus we get the formula for integration by parts shown above.