Skip to content

Commit 9bf415a

Browse files
Fix default Nix configuration option in generated ~/.cabal/config file (#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>
1 parent 3674900 commit 9bf415a

File tree

7 files changed

+761
-15
lines changed

7 files changed

+761
-15
lines changed

cabal-install/src/Distribution/Client/Config.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,8 @@ commentSavedConfig = do
915915
globalInstallDirs <- defaultInstallDirs defaultCompiler False True
916916
let conf0 = mempty {
917917
savedGlobalFlags = defaultGlobalFlags {
918-
globalRemoteRepos = toNubList [defaultRemoteRepo]
918+
globalRemoteRepos = toNubList [defaultRemoteRepo],
919+
globalNix = mempty
919920
},
920921
savedInitFlags = mempty {
921922
IT.interactive = toFlag False,

cabal-install/src/Distribution/Client/Setup.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ globalCommand commands = CommandUI {
369369
optArg' "(True or False)" (maybeToFlag . (readMaybe =<<)) (\case
370370
Flag True -> [Just "enable"]
371371
Flag False -> [Just "disable"]
372-
NoFlag -> [Just "disable"]) "" ["nix"]
372+
NoFlag -> []) "" ["nix"] -- Must be empty because we need to return PP.empty from viewAsFieldDescr
373373
"Nix integration: run commands through nix-shell if a 'shell.nix' file exists (default is False)",
374374
noArg (Flag True) [] ["enable-nix"]
375375
"Enable Nix integration: run commands through nix-shell if a 'shell.nix' file exists",

cabal-install/tests/IntegrationTests2.hs

Lines changed: 230 additions & 3 deletions
Large diffs are not rendered by default.

cabal-install/tests/IntegrationTests2/nix-config/default-config renamed to cabal-install/tests/IntegrationTests2/config/default-config

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
--
1010
-- This config file was generated using the following versions
1111
-- of Cabal and cabal-install:
12-
-- Cabal library version: 3.6.2.0
13-
-- cabal-install version: 3.6.2.0
12+
-- Cabal library version: 3.11.0.0
13+
-- cabal-install version: 3.11
1414

1515

1616
repository hackage.haskell.org
@@ -19,15 +19,15 @@ repository hackage.haskell.org
1919
-- root-keys:
2020
-- key-threshold: 3
2121

22-
-- default-user-config:
2322
-- ignore-expiry: False
2423
-- http-transport:
25-
-- nix: False
26-
-- local-no-index-repo:
27-
28-
--debug-info: 1
24+
-- nix:
2925
-- store-dir:
3026
-- active-repositories:
27+
-- local-no-index-repo:
28+
remote-repo-cache: /home/colton/.cabal/packages
29+
-- logs-dir: /home/colton/.cabal/logs
30+
-- default-user-config:
3131
-- verbose: 1
3232
-- compiler: ghc
3333
-- cabal-file:
@@ -47,6 +47,7 @@ repository hackage.haskell.org
4747
-- library-profiling-detail:
4848
-- optimization: True
4949
-- debug-info: False
50+
-- build-info:
5051
-- library-for-ghci:
5152
-- split-sections: False
5253
-- split-objs: False
@@ -60,7 +61,9 @@ repository hackage.haskell.org
6061
-- deterministic:
6162
-- cid:
6263
-- extra-lib-dirs:
64+
-- extra-lib-dirs-static:
6365
-- extra-framework-dirs:
66+
extra-prog-path: /home/colton/.cabal/bin
6467
-- instantiate-with:
6568
-- tests: False
6669
-- coverage: False
@@ -71,6 +74,8 @@ repository hackage.haskell.org
7174
-- response-files:
7275
-- allow-depending-on-private-libs:
7376
-- cabal-lib-version:
77+
-- append:
78+
-- backup:
7479
-- constraint:
7580
-- preference:
7681
-- solver: modular
@@ -87,6 +92,7 @@ repository hackage.haskell.org
8792
-- fine-grained-conflicts: True
8893
-- minimize-conflict-set: False
8994
-- independent-goals: False
95+
-- prefer-oldest: False
9096
-- shadow-installed-packages: False
9197
-- strong-flags: False
9298
-- allow-boot-library-installs: False
@@ -98,11 +104,11 @@ repository hackage.haskell.org
98104
-- index-state:
99105
-- root-cmd:
100106
-- symlink-bindir:
107+
build-summary: /home/colton/.cabal/logs/build.log
101108
-- build-log:
102109
remote-build-reporting: none
103110
-- report-planning-failure: False
104111
-- per-component: True
105-
-- one-shot: False
106112
-- run-tests:
107113
jobs: $ncpus
108114
-- keep-going: False
@@ -111,6 +117,7 @@ jobs: $ncpus
111117
-- package-env:
112118
-- overwrite-policy:
113119
-- install-method:
120+
installdir: /home/colton/.cabal/bin
114121
-- username:
115122
-- password:
116123
-- password-command:
@@ -132,18 +139,28 @@ haddock
132139
-- quickjump: False
133140
-- hscolour-css:
134141
-- contents-location:
142+
-- index-location:
143+
-- base-url:
144+
-- lib:
145+
-- output-dir:
135146

136147
init
137148
-- interactive: False
138-
-- cabal-version: 2.4
149+
-- quiet: False
150+
-- no-comments: False
151+
-- minimal: False
152+
-- cabal-version: 3.0
139153
-- license:
154+
-- extra-doc-file:
140155
-- tests:
141156
-- test-dir:
157+
-- simple: False
142158
-- language: Haskell2010
143159
-- application-dir: app
144160
-- source-dir: src
145161

146162
install-dirs user
163+
-- prefix: /home/colton/.cabal
147164
-- bindir: $prefix/bin
148165
-- libdir: $prefix/lib
149166
-- libsubdir: $abi/$libname
@@ -226,4 +243,4 @@ program-default-options
226243
-- runghc-options:
227244
-- strip-options:
228245
-- tar-options:
229-
-- uhc-options:
246+
-- uhc-options:

changelog.d/pr-8878

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
synopsis: Fix default Nix configuration option in generated ~/.cabal/config file
2+
packages: cabal-install
3+
prs: #8878
4+
5+
description: {
6+
7+
Fixes the default for ~/.cabal/config file. The nix option should now be commented out by default.
8+
9+
}

0 commit comments

Comments
 (0)