diff --git a/cabal-install/src/Distribution/Client/CmdInstall.hs b/cabal-install/src/Distribution/Client/CmdInstall.hs
index cd1254b5fe11f1268c9a474e940bd1b3848697ee..94a4737a24d9751fb3a070e6b9a5f383ed2aa851 100644
--- a/cabal-install/src/Distribution/Client/CmdInstall.hs
+++ b/cabal-install/src/Distribution/Client/CmdInstall.hs
@@ -39,7 +39,7 @@ import Distribution.Client.Types
          , SourcePackageDb(..) )
 import qualified Distribution.Client.InstallPlan as InstallPlan
 import Distribution.Package
-         ( Package(..), PackageName, unPackageName )
+         ( Package(..), PackageName, mkPackageName, unPackageName )
 import Distribution.Types.PackageId
          ( PackageIdentifier(..) )
 import Distribution.Client.ProjectConfig
@@ -53,6 +53,7 @@ import Distribution.Client.ProjectFlags (ProjectFlags (..))
 import Distribution.Client.ProjectConfig.Types
          ( ProjectConfig(..), ProjectConfigShared(..)
          , ProjectConfigBuildOnly(..), PackageConfig(..)
+         , MapMappend(..)
          , getMapLast, getMapMappend, projectConfigLogsDir
          , projectConfigStoreDir, projectConfigBuildOnly
          , projectConfigConfigFile )
@@ -430,12 +431,24 @@ installAction flags@NixStyleFlags { extraFlags = clientInstallFlags', .. } targe
     configFlags' = disableTestsBenchsByDefault configFlags
     verbosity = fromFlagOrDefault normal (configVerbosity configFlags')
     ignoreProject = flagIgnoreProject projectFlags
-    cliConfig = commandLineFlagsToProjectConfig
-                  globalFlags
-                  flags { configFlags = configFlags' }
-                  clientInstallFlags'
+    baseCliConfig = commandLineFlagsToProjectConfig
+                        globalFlags
+                        flags { configFlags = configFlags' }
+                        clientInstallFlags'
+    cliConfig = addLocalConfigToTargets baseCliConfig targetStrings
     globalConfigFlag = projectConfigConfigFile (projectConfigShared cliConfig)
 
+-- | Treat all direct targets of install command as local packages: #8637
+addLocalConfigToTargets :: ProjectConfig -> [String] -> ProjectConfig
+addLocalConfigToTargets config targetStrings
+    = config {
+        projectConfigSpecificPackage = projectConfigSpecificPackage config
+                                       <> MapMappend (Map.fromList targetPackageConfigs)
+    }
+  where
+    localConfig = projectConfigLocalPackages config
+    targetPackageConfigs = map (\x -> (mkPackageName x, localConfig)) targetStrings
+
 -- | Verify that invalid config options were not passed to the install command.
 --
 -- If an invalid configuration is found the command will @die'@.
diff --git a/cabal-testsuite/PackageTests/LinkerOptions/NonignoredConfigs/cabal.test.hs b/cabal-testsuite/PackageTests/LinkerOptions/NonignoredConfigs/cabal.test.hs
index 2e8dac23a20c84314ba4a4b42bffe342ff79f1dc..9da924366f4b97d4c3c073c9807bc1ad6c9058ba 100644
--- a/cabal-testsuite/PackageTests/LinkerOptions/NonignoredConfigs/cabal.test.hs
+++ b/cabal-testsuite/PackageTests/LinkerOptions/NonignoredConfigs/cabal.test.hs
@@ -50,7 +50,7 @@ linkConfigFlags Dynamic =
 lrun :: [Linking]
 lrun = [Static, Dynamic, Static, Dynamic]
 
-main = cabalTest . expectBroken 8744 $ do
+main = cabalTest $ do
     -- Skip if on Windows, since my default Chocolatey Windows setup (and the CI
     -- server setup at the time, presumably) lacks support for dynamic builds
     -- since the base package appears to be static only, lacking e.g. ‘.dyn_o’
diff --git a/changelog.d/issue-8637 b/changelog.d/issue-8637
new file mode 100644
index 0000000000000000000000000000000000000000..b584e187761693e8acbb40dea4fda1cf94ebf2b1
--- /dev/null
+++ b/changelog.d/issue-8637
@@ -0,0 +1,13 @@
+synopsis: Apply command line flags to install packages
+packages: cabal-install
+prs: #8779
+issues: #8637
+
+description: {
+
+- Command line flags usually only apply to "local" packages (packages specified
+  in the cabal.project). This change causes the v2-install command to ignore
+  that distinction to better match the expected behavior for packages specified
+  directly in the command.
+
+}