Selling a farm involves disposing of both business and non-business property. Land, machinery, livestock, and other assets used in farming are business property, while the farm residence is non-business property. For each type of property, the tax treatment is different. Gains and losses may be either capital or ordinary depending upon the asset.
Farmers are eligible to exclude the gain on the sale of the personal residence under the following conditions:
The farmer (taxpayer) has owned and used the home as his/her personal residence for at least 2 of the last 5 years.
The farmer has not used the exclusion in the last 2 years.
The gain on the residence does not exceed $250,000 ($500,000 on a joint tax return). IRC § 121.
See also:
Publication 225 (2008), Farmer's Tax Guide
and read carefully. You may wish to engage a professional tax preparer to help you with this; it may get complicated.
Additionally, you will be entitled to a foreign tax credit on any tax you pay in your country of residence deductible against any US tax you owe.