Skip to content

Commit

Permalink
Fix default Nix configuration option in generated ~/.cabal/config file (
Browse files Browse the repository at this point in the history
#8878)

* default to commented line for nix config

* Fix whitespace

* Remove vscode folder

* Remove default config file for test

* Remove test generated file

* Add changelog

* Add test for default config values

* Remove config file

* Remove parsing file

* Add config file back for tests

* Remove reference to default config to try to get the new test to pass

* Rewrite test to be more verbose WIP

* Stop testing for values and only test for whether it is commented or not

* Fill out rest of tests WIP

* Clean up

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
cbclemmer and mergify[bot] authored May 18, 2023
1 parent 3674900 commit 9bf415a
Show file tree
Hide file tree
Showing 7 changed files with 761 additions and 15 deletions.
3 changes: 2 additions & 1 deletion cabal-install/src/Distribution/Client/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,8 @@ commentSavedConfig = do
globalInstallDirs <- defaultInstallDirs defaultCompiler False True
let conf0 = mempty {
savedGlobalFlags = defaultGlobalFlags {
globalRemoteRepos = toNubList [defaultRemoteRepo]
globalRemoteRepos = toNubList [defaultRemoteRepo],
globalNix = mempty
},
savedInitFlags = mempty {
IT.interactive = toFlag False,
Expand Down
2 changes: 1 addition & 1 deletion cabal-install/src/Distribution/Client/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ globalCommand commands = CommandUI {
optArg' "(True or False)" (maybeToFlag . (readMaybe =<<)) (\case
Flag True -> [Just "enable"]
Flag False -> [Just "disable"]
NoFlag -> [Just "disable"]) "" ["nix"]
NoFlag -> []) "" ["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)",
noArg (Flag True) [] ["enable-nix"]
"Enable Nix integration: run commands through nix-shell if a 'shell.nix' file exists",
Expand Down
233 changes: 230 additions & 3 deletions cabal-install/tests/IntegrationTests2.hs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
--
-- This config file was generated using the following versions
-- of Cabal and cabal-install:
-- Cabal library version: 3.6.2.0
-- cabal-install version: 3.6.2.0
-- Cabal library version: 3.11.0.0
-- cabal-install version: 3.11


repository hackage.haskell.org
Expand All @@ -19,15 +19,15 @@ repository hackage.haskell.org
-- root-keys:
-- key-threshold: 3

-- default-user-config:
-- ignore-expiry: False
-- http-transport:
-- nix: False
-- local-no-index-repo:

--debug-info: 1
-- nix:
-- store-dir:
-- active-repositories:
-- local-no-index-repo:
remote-repo-cache: /home/colton/.cabal/packages
-- logs-dir: /home/colton/.cabal/logs
-- default-user-config:
-- verbose: 1
-- compiler: ghc
-- cabal-file:
Expand All @@ -47,6 +47,7 @@ repository hackage.haskell.org
-- library-profiling-detail:
-- optimization: True
-- debug-info: False
-- build-info:
-- library-for-ghci:
-- split-sections: False
-- split-objs: False
Expand All @@ -60,7 +61,9 @@ repository hackage.haskell.org
-- deterministic:
-- cid:
-- extra-lib-dirs:
-- extra-lib-dirs-static:
-- extra-framework-dirs:
extra-prog-path: /home/colton/.cabal/bin
-- instantiate-with:
-- tests: False
-- coverage: False
Expand All @@ -71,6 +74,8 @@ repository hackage.haskell.org
-- response-files:
-- allow-depending-on-private-libs:
-- cabal-lib-version:
-- append:
-- backup:
-- constraint:
-- preference:
-- solver: modular
Expand All @@ -87,6 +92,7 @@ repository hackage.haskell.org
-- fine-grained-conflicts: True
-- minimize-conflict-set: False
-- independent-goals: False
-- prefer-oldest: False
-- shadow-installed-packages: False
-- strong-flags: False
-- allow-boot-library-installs: False
Expand All @@ -98,11 +104,11 @@ repository hackage.haskell.org
-- index-state:
-- root-cmd:
-- symlink-bindir:
build-summary: /home/colton/.cabal/logs/build.log
-- build-log:
remote-build-reporting: none
-- report-planning-failure: False
-- per-component: True
-- one-shot: False
-- run-tests:
jobs: $ncpus
-- keep-going: False
Expand All @@ -111,6 +117,7 @@ jobs: $ncpus
-- package-env:
-- overwrite-policy:
-- install-method:
installdir: /home/colton/.cabal/bin
-- username:
-- password:
-- password-command:
Expand All @@ -132,18 +139,28 @@ haddock
-- quickjump: False
-- hscolour-css:
-- contents-location:
-- index-location:
-- base-url:
-- lib:
-- output-dir:

init
-- interactive: False
-- cabal-version: 2.4
-- quiet: False
-- no-comments: False
-- minimal: False
-- cabal-version: 3.0
-- license:
-- extra-doc-file:
-- tests:
-- test-dir:
-- simple: False
-- language: Haskell2010
-- application-dir: app
-- source-dir: src

install-dirs user
-- prefix: /home/colton/.cabal
-- bindir: $prefix/bin
-- libdir: $prefix/lib
-- libsubdir: $abi/$libname
Expand Down Expand Up @@ -226,4 +243,4 @@ program-default-options
-- runghc-options:
-- strip-options:
-- tar-options:
-- uhc-options:
-- uhc-options:
9 changes: 9 additions & 0 deletions changelog.d/pr-8878
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
synopsis: Fix default Nix configuration option in generated ~/.cabal/config file
packages: cabal-install
prs: #8878

description: {

Fixes the default for ~/.cabal/config file. The nix option should now be commented out by default.

}
Loading

0 comments on commit 9bf415a

Please sign in to comment.