From 51b92ee2efb8f8767d4feba7fa1f31c688fb7f1a Mon Sep 17 00:00:00 2001 From: Yvan Sraka Date: Tue, 29 Aug 2023 09:46:17 +0200 Subject: [PATCH] Add deprecation warnings to Nix integration https://cabal.readthedocs.io/en/latest/nix-integration.html --- cabal-install/src/Distribution/Client/Nix.hs | 5 ++++- cabal-install/src/Distribution/Client/Setup.hs | 6 +++--- .../PackageTests/Freeze/enable-benchmarks.out | 1 + cabal-testsuite/PackageTests/Freeze/enable-tests.out | 1 + doc/nix-integration.rst | 9 +++++++++ 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/cabal-install/src/Distribution/Client/Nix.hs b/cabal-install/src/Distribution/Client/Nix.hs index 34a12f9157b..a2c75e897e1 100644 --- a/cabal-install/src/Distribution/Client/Nix.hs +++ b/cabal-install/src/Distribution/Client/Nix.hs @@ -47,7 +47,7 @@ import Distribution.Simple.Program , simpleProgram ) import Distribution.Simple.Setup (fromFlagOrDefault) -import Distribution.Simple.Utils (debug, existsAndIsMoreRecentThan) +import Distribution.Simple.Utils (debug, existsAndIsMoreRecentThan, warn) import Distribution.Client.Config (SavedConfig (..)) import Distribution.Client.GlobalFlags (GlobalFlags (..)) @@ -141,6 +141,9 @@ nixShell verb dist globalFlags config go = do if alreadyInShell then go else do + -- Nix integration never worked with cabal-install v2 commands ... + warn verb "Nix integration has been deprecated and will be removed in a future release. You can learn more about it here: https://cabal.readthedocs.io/en/latest/nix-integration.html" + findNixExpr globalFlags config >>= \case Nothing -> go Just shellNix -> do diff --git a/cabal-install/src/Distribution/Client/Setup.hs b/cabal-install/src/Distribution/Client/Setup.hs index 6a96fb54640..44224d9559b 100644 --- a/cabal-install/src/Distribution/Client/Setup.hs +++ b/cabal-install/src/Distribution/Client/Setup.hs @@ -502,17 +502,17 @@ globalCommand commands = ) "" ["nix"] -- Must be empty because we need to return PP.empty from viewAsFieldDescr - "Nix integration: run commands through nix-shell if a 'shell.nix' file exists (default is False)" + "[DEPRECATED] Nix integration: run commands through nix-shell if a 'shell.nix' file exists (default is False)" , noArg (Flag True) [] ["enable-nix"] - "Enable Nix integration: run commands through nix-shell if a 'shell.nix' file exists" + "[DEPRECATED] Enable Nix integration: run commands through nix-shell if a 'shell.nix' file exists" , noArg (Flag False) [] ["disable-nix"] - "Disable Nix integration" + "[DEPRECATED] Disable Nix integration" ] , option [] diff --git a/cabal-testsuite/PackageTests/Freeze/enable-benchmarks.out b/cabal-testsuite/PackageTests/Freeze/enable-benchmarks.out index b888d4fd6f1..b076aa8497e 100644 --- a/cabal-testsuite/PackageTests/Freeze/enable-benchmarks.out +++ b/cabal-testsuite/PackageTests/Freeze/enable-benchmarks.out @@ -1,4 +1,5 @@ # cabal v2-update Downloading the latest package list from test-local-repo # cabal v1-freeze +Warning: Nix integration has been deprecated and will be removed in a future release. You can learn more about it here: https://cabal.readthedocs.io/en/latest/nix-integration.html Resolving dependencies... diff --git a/cabal-testsuite/PackageTests/Freeze/enable-tests.out b/cabal-testsuite/PackageTests/Freeze/enable-tests.out index b888d4fd6f1..b076aa8497e 100644 --- a/cabal-testsuite/PackageTests/Freeze/enable-tests.out +++ b/cabal-testsuite/PackageTests/Freeze/enable-tests.out @@ -1,4 +1,5 @@ # cabal v2-update Downloading the latest package list from test-local-repo # cabal v1-freeze +Warning: Nix integration has been deprecated and will be removed in a future release. You can learn more about it here: https://cabal.readthedocs.io/en/latest/nix-integration.html Resolving dependencies... diff --git a/doc/nix-integration.rst b/doc/nix-integration.rst index 6edf595b6f0..5d4fa695cd4 100644 --- a/doc/nix-integration.rst +++ b/doc/nix-integration.rst @@ -1,6 +1,15 @@ Nix Integration =============== +.. warning:: + + Nix integration has been deprecated and will be removed in a future release. + + The original mechanism can still be easily replicated with the following commands: + + - for a ``shell.nix``: ``nix-shell --run "cabal ..."`` + - for a ``flake.nix``: ``nix develop -c cabal ...`` + .. note:: This functionality doesn't work with nix-style builds.