I haven't personally worked with Logic or Mainstage much, but the basic steps I'm outlining here seem to be fairly DAW-agnostic, and I have applied them in both Reaper and Ableton Live so I presume they work similarly. I'll talk about Logic here since that seems to be the more common choice.
There are a couple of basic ideas you're going to use here.
There's Automation, in which parameters (track volumes, in your case) are programmed to move independently of the audio recordings. Automation can set up by hand as a post-production step, or can be recorded in realtime, which is what you'll be doing. It sounds like you already understand this concept, but I'm including it here for completeness.
Then there's MIDI parameter control. This is where a parameter is tied to a given MIDI message, and its position continuously updates when that message arrives with a new value. By default your nanoKontrol sends MIDI Continuous Controller messages on each of its sliders, so you'll assign the corresponding message numbers.
The Basic Idea
You've probably intuited this already: for the volume of each track you're recording on, you want to assign the MIDI message to the corresponding nanoKontrol slider. So slider 1 controls Track 1 volume, slider 2 controls track 2, etc. Then, you need Logic to capture these updates as automations while you're recording your audio.
Straightforward enough, but how do we actually implement this?
First: Assign MIDI to track levels
Logic includes preset control surface support for a lot of MIDI controllers, but the nanoKontrol doesn't appear to be one of them, so you have to make those MIDI assignments yourself. According to the Logic 9 Control Surfaces Support Guide (that's a PDF link, relevant section is Chapter 2), you do this using the Controller Assignments window. Click the parameter to which you want to assign a MIDI message (so, in your case, one of the on-screen track faders), and:
Choose Logic Pro > Preferences > Control Surfaces > Learn Assignment for [parameter
name]. (Alternately, you can use the Learn new Controller Assignment key command,
default: Command-L, to open the Controller Assignments window, and activate Learn
The Controller Assignments window opens in Easy view, with the Learn Mode button
activated. In most cases, the name of the selected parameter is shown in the Parameter
Move the hardware controller you want to assign to the selected parameter.
Once the window is open you can apparently keep clicking more parameters and moving more faders to assign them. There documentation describes some other modes you can use to do more elaborate things but this will suffice for getting those assignments made.
Second: Set up automation
(I'm basically copy/pasting from the Logic Manual's section on automation, so you can read that for more detail. The images are taken from that page.)
For each of your tracks that you want controlled by your controller, you need to set the automation mode. This is done using either track headers:
or from mixer channels:
The mode you probably want is Latch, which means "overwrite automation when you move the parameter, and leave it where you put it when you let go." Since your MIDI controller is controlling that parameter, any movements on the controller should now be picked up as automation as you are recording.