They can be synonyms, but only in a narrow sense. Usually their meaning or common useage is quite different.
And when they are synonyms, usually "gain" or a form of that is the word you will hear and not "derive".
For instance, an example of them being synonyms is "I derived no pleasure from that" = "I gained no pleasure from that" but is the 2nd version you will hear in conversation the vast majority of times.
The common usage of "derive" is more in academic or formal settings. An example in mathematics: "The sum is derived from adding A plus B". Or another example in business, "He derived his profits from the sale of ...". In both these examples, though, you would tend to use "gain" when speaking. "He gained his profits from the sale of ...", etc.