diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,24 @@
 # Revision History for cabal2nix
 
+## 2.21.3
+
+* Add `--src-expression` flag to `cabal2nix` which allows overriding
+  the Nix expression used for the `src` attribute of the generated
+  package expression. This can be useful when cabal2nix can't infer
+  the source expression correctly from the command line arguments,
+  the source is passed in via `--extra-arguments`, the source needs
+  to use `filterSource` etc.
+
+  See [#694](https://github.com/NixOS/cabal2nix/pull/694) and
+  [#684](https://github.com/NixOS/cabal2nix/issues/684).
+* Resolve expressions failing to evaluate if the package they're based
+  on uses an SPDX-identified license that isn't part of `lib.licenses`.
+  Note that missing licenses now generate an evaluation warning.
+  See [#707](https://github.com/NixOS/cabal2nix/issues/707) and
+  [#708](https://github.com/NixOS/cabal2nix/pull/708).
+* Update attribute name for the `odbc` library. Assumes Nixpkgs
+  with [nixpkgs#489676](https://github.com/NixOS/nixpkgs/pull/489676).
+
 ## 2.21.2
 
 * Add support for Cabal `>= 3.16`, see
diff --git a/cabal2nix.cabal b/cabal2nix.cabal
--- a/cabal2nix.cabal
+++ b/cabal2nix.cabal
@@ -1,5 +1,5 @@
 name:               cabal2nix
-version:            2.21.2
+version:            2.21.3
 synopsis:           Convert Cabal files into Nix build instructions.
 description:
   Convert Cabal files into Nix build instructions. Users of Nix can install the latest
@@ -12,7 +12,7 @@
 -- list all contributors: git log --pretty='%an' | sort | uniq
 maintainer:         sternenseemann <sternenseemann@systemli.org>
 stability:          stable
-tested-with:        GHC == 8.10.7 || == 9.0.2 || == 9.2.8 || == 9.4.8 || == 9.6.7 || == 9.8.4 || == 9.10.2 || == 9.12.2
+tested-with:        GHC == 9.0.2 || == 9.2.8 || == 9.4.8 || == 9.6.7 || == 9.8.4 || == 9.10.2 || == 9.12.2
 category:           Distribution, Nix
 homepage:           https://github.com/nixos/cabal2nix#readme
 bug-reports:        https://github.com/nixos/cabal2nix/issues
@@ -52,7 +52,7 @@
   build-depends:      base                 > 4.11 && <5
                     -- When changing the Cabal version, ensure that it builds
                     -- with all installation methods mentioned in the README!
-                    , Cabal                >= 3.0
+                    , Cabal                >= 3.0 && < 3.18
                     , aeson                > 1
                     , ansi-terminal
                     , bytestring
diff --git a/src/Cabal2nix.hs b/src/Cabal2nix.hs
--- a/src/Cabal2nix.hs
+++ b/src/Cabal2nix.hs
@@ -68,6 +68,7 @@
   , optNixpkgsIdentifier :: NixpkgsResolver
   , optUrl :: String
   , optFetchSubmodules :: FetchSubmodules
+  , optSrcExpression :: Maybe String
   }
 
 options :: Parser Options
@@ -126,6 +127,8 @@
     <- strArgument (metavar "URI")
   optFetchSubmodules
     <- flag FetchSubmodules DontFetchSubmodules  (long "dont-fetch-submodules" <> help "do not fetch git submodules from git sources")
+  optSrcExpression
+    <- optional (strOption $ long "src-expression" <> metavar "EXPR" <> help "custom Nix expression to use for src attribute")
   pure Options{..}
 
 -- | A parser for the date. Hackage updates happen maybe once or twice a month.
@@ -211,6 +214,11 @@
       flags :: FlagAssignment
       flags = configureCabalFlags (packageId (pkgCabal pkg)) `mappend` readFlagList optFlags
 
+      finalSource :: DerivationSource
+      finalSource = case optSrcExpression of
+        Nothing -> pkgSource pkg
+        Just customExpr -> (pkgSource pkg) { derivCustomSrc = Just customExpr }
+
       deriv :: Derivation
       deriv = withHpackOverrides $ fromGenericPackageDescription (const True)
                                             optNixpkgsIdentifier
@@ -219,7 +227,7 @@
                                             flags
                                             []
                                             (pkgCabal pkg)
-              & src .~ pkgSource pkg
+              & src .~ finalSource
               & subpath .~ fromMaybe "." optSubpath
               & runHaddock %~ (optHaddock &&)
               & jailbreak .~ optJailbreak
diff --git a/src/Distribution/Nixpkgs/Fetch.hs b/src/Distribution/Nixpkgs/Fetch.hs
--- a/src/Distribution/Nixpkgs/Fetch.hs
+++ b/src/Distribution/Nixpkgs/Fetch.hs
@@ -65,6 +65,7 @@
   , derivRevision :: String -- ^ Revision to use. Leave empty if the fetcher doesn't support revisions.
   , derivHash     :: String -- ^ The hash of the source.
   , derivSubmodule :: Maybe Bool -- ^ The fetchSubmodule setting (if any)
+  , derivCustomSrc :: Maybe String -- ^ Custom Nix expression to use for src attribute
   }
   deriving (Show, Generic)
 
@@ -76,24 +77,28 @@
         <*> o .: "rev"
         <*> o .: "sha256"
         <*> o .: "fetchSubmodules"
+        <*> pure Nothing
   parseJSON _ = error "invalid DerivationSource"
 
 instance PP.Pretty DerivationSource where
   pPrint DerivationSource {..} =
-    let isHackagePackage = "mirror://hackage/" `L.isPrefixOf` derivUrl
-    in if isHackagePackage then if derivHash /= "" then attr "sha256" $ string derivHash else mempty
-       else case derivKind of
-          Nothing ->  attr "src" $ text derivUrl
-          Just derivKind' -> vcat
-                 [ text "src" <+> equals <+> text (derivKindFunction derivKind') <+> lbrace
-                 , nest 2 $ vcat
-                   [ attr "url" $ string derivUrl
-                   , attr "sha256" $ string derivHash
-                   , if derivRevision /= "" then attr "rev" (string derivRevision) else PP.empty
-                   , boolattr "fetchSubmodules" (isJust derivSubmodule) (fromJust derivSubmodule)
-                   ]
-                 , rbrace PP.<> semi
-                 ]
+    case derivCustomSrc of
+      Just customExpr -> attr "src" $ text customExpr
+      Nothing ->
+        let isHackagePackage = "mirror://hackage/" `L.isPrefixOf` derivUrl
+        in if isHackagePackage then if derivHash /= "" then attr "sha256" $ string derivHash else mempty
+           else case derivKind of
+              Nothing ->  attr "src" $ text derivUrl
+              Just derivKind' -> vcat
+                     [ text "src" <+> equals <+> text (derivKindFunction derivKind') <+> lbrace
+                     , nest 2 $ vcat
+                       [ attr "url" $ string derivUrl
+                       , attr "sha256" $ string derivHash
+                       , if derivRevision /= "" then attr "rev" (string derivRevision) else PP.empty
+                       , boolattr "fetchSubmodules" (isJust derivSubmodule) (fromJust derivSubmodule)
+                       ]
+                     , rbrace PP.<> semi
+                     ]
 
 
 urlDerivationSource :: String -> String -> DerivationSource
@@ -103,7 +108,8 @@
     derivUrl = url,
     derivRevision = "",
     derivHash = hash,
-    derivSubmodule = Nothing
+    derivSubmodule = Nothing,
+    derivCustomSrc = Nothing
   }
 
 fromDerivationSource :: DerivationSource -> Source
@@ -177,7 +183,8 @@
       derivUrl = p,
       derivRevision = "",
       derivHash = "",
-      derivSubmodule = Nothing
+      derivSubmodule = Nothing,
+      derivCustomSrc = Nothing
     }
 
 data DerivKind
@@ -265,11 +272,12 @@
                                               , derivRevision = ""
                                               , derivHash = BS.unpack hash
                                               , derivSubmodule = Nothing
+                                              , derivCustomSrc = Nothing
                                               }
                             , BS.unpack l))
           _ -> case eitherDecode buf' of
                  Left err -> error ("invalid JSON: " ++ err ++ " in " ++ show buf')
-                 Right ds -> return (Just (ds { derivKind = Just kind }, BS.unpack l))
+                 Right ds -> return (Just (ds { derivKind = Just kind, derivCustomSrc = Nothing }, BS.unpack l))
 
 
 stripPrefix :: Eq a => [a] -> [a] -> [a]
diff --git a/src/Distribution/Nixpkgs/Haskell/FromCabal/License.hs b/src/Distribution/Nixpkgs/Haskell/FromCabal/License.hs
--- a/src/Distribution/Nixpkgs/Haskell/FromCabal/License.hs
+++ b/src/Distribution/Nixpkgs/Haskell/FromCabal/License.hs
@@ -53,7 +53,8 @@
     SPDX.ELicense simpl Nothing ->
       -- Not handled: license exceptions
       case simpl of
-        SPDX.ELicenseId lid -> Known ("lib.licensesSpdx.\"" ++ prettyShow lid ++ "\"")
+        -- FIXME(@sternenseemann): this is not exactly Known, but a best effort lookup
+        SPDX.ELicenseId lid -> Known ("lib.meta.getLicenseFromSpdxId \"" ++ prettyShow lid ++ "\"")
         _ ->
           -- Not handed: the '+' suffix and user-defined licences references.
           -- Use the SPDX expression as a free-form license string.
diff --git a/src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs b/src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs
--- a/src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs
+++ b/src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs
@@ -238,7 +238,7 @@
 libNixName "nix-util-c"                         = return "nix"
 libNixName "nix-util"                           = return "nix"
 libNixName "notify"                             = return "libnotify"
-libNixName "odbc"                               = return "unixODBC"
+libNixName "odbc"                               = return "unixodbc"
 libNixName "openblas"                           = return "openblasCompat"
 libNixName "panelw"                             = return "ncurses"
 libNixName "pangocairo"                         = return "pango"
diff --git a/test/Main.hs b/test/Main.hs
--- a/test/Main.hs
+++ b/test/Main.hs
@@ -71,6 +71,7 @@
                                   , derivRevision = ""
                                   , derivHash     = "deadbeef"
                                   , derivSubmodule = Nothing
+                                  , derivCustomSrc = Nothing
                                   }
                        & extraFunctionArgs %~ Set.union (Set.singleton "inherit lib")
   goldenVsFileDiff
diff --git a/test/golden-test-cases/pandoc.nix.golden b/test/golden-test-cases/pandoc.nix.golden
--- a/test/golden-test-cases/pandoc.nix.golden
+++ b/test/golden-test-cases/pandoc.nix.golden
@@ -49,6 +49,6 @@
   ];
   homepage = "https://pandoc.org";
   description = "Conversion between markup formats";
-  license = lib.licensesSpdx."GPL-2.0-or-later";
+  license = lib.meta.getLicenseFromSpdxId "GPL-2.0-or-later";
   mainProgram = "pandoc";
 }
