Domain of a random variable - sample space or probability space? In most probability theory texts you'll see a random variable definition that goes something like this:

A probability space is a triple $(\Omega, \mathcal{F}, P)$, a real valued random variable is a function $X:\Omega \rightarrow \mathbb{R}$

The computer scientist in my head can't get around what seems to be a type-error.  Is a random variable dependent on $P$ or not.  My intuition says it is, which is why we say things like 'uniformly distributed random variable', but in this case shouldn't a random variable be a function from the probability space, i.e. $X:(\Omega, \mathcal{F}, P) \rightarrow \mathbb{R}$.  In fact this is how it is defined in Wolframs mathworld.

Alternatively, one could imagine in a functional programming language a function which counts the number of heads from a set of coin tosses.  This function could be independent of whether or not the coin is fair or biased, etc, and hence in some way independent of $P$.

I understand some of this may be just for convenience when speaking, but this is how a random variable is rigorously defined, so I believe I must be missing something.  In other words, my question is, is a random variable associated with probabilities or independent of it.
Your observation is reasonable, but your suggested cure for the problem, making $(\Omega,\mathcal F,P)$ the domain of $X$, won't work because the domain of a function needs to be a set (or a type or something like that).  My impression is that, when people refer to a function $X:\Omega\to\mathbb R$ as a random variable, they always do so in the context of a probability-space structure ($\mathcal F$ and $P$) on $\Omega$.  If no such structure is given, then I wouldn't call $X$ a random variable. And if there is uncertainty about which structure is intended, then, as you said, notions like "distribution" of $X$ will not be well-defined.

If I had to formalize the notion of random variable, in Bourbaki style, I would probably say that a random variable is a pair consisting of a probability space $(\Omega,\mathcal F,P)$ together with a function $X:\Omega\to\mathbb R$.  As with many mathematical concepts, one often omits mentioning part of an entity (in this case the probability space) when it is understood from the context.
A random variable $X$ is a measurable map from the probability space $(\Omega, \mathcal{F}, P)$ to another measure space $(S, \mathcal{S})$ (usually $(\mathbb{R}, \mathcal{B}(\mathbb{R}))$. It is not just a function between $\Omega$ and $S$ - the measurability of the map (which intrinsically depends on the measure spaces $(\Omega, \mathcal{F}, P)$ and $(S, \mathcal{S})$) is a key part of the definition of the random variable $X$. 

It is just cumbersome to write out the entire measure space every time, so we just write $X: \Omega \to S$ and keep the measures and $\sigma$-fields implicit.