<commit_before># User settings

You can customise Hadrian by copying the file `hadrian/src/UserSettings.hs` to
`hadrian/UserSettings.hs` and overriding the default build settings (if you don't
copy the file your changes will be tracked by `git` and you can accidentally commit
them). Here we document currently supported settings.

## Build directory

Hadrian puts build results into `_build` directory by default, which is
specified by `buildRootPath`:
```haskell
-- | All build results are put into 'buildRootPath' directory.
buildRootPath :: FilePath
buildRootPath = "_build"
```

## Build flavour

Build _flavour_ is a collection of build settings that fully define a GHC build
(see `src/Flavour.hs`):
```haskell
data Flavour = Flavour
    { name               :: String    -- ^ Flavour name, to set from command line.
    , args               :: Args      -- ^ Use these command line arguments.
    , packages           :: Packages  -- ^ Build these packages.
    , integerLibrary     :: Package   -- ^ Either 'integerGmp' or 'integerSimple'.
    , libraryWays        :: Ways      -- ^ Build libraries these ways.
    , rtsWays            :: Ways      -- ^ Build RTS these ways.
    , splitObjects       :: Predicate -- ^ Build split objects.
    , buildHaddock       :: Predicate -- ^ Build Haddock and documentation.
    , dynamicGhcPrograms :: Bool      -- ^ Build dynamic GHC programs.
    , ghciWithDebugger   :: Bool      -- ^ Enable GHCi debugger.
    , ghcProfiled        :: Bool      -- ^ Build profiled GHC.
    , ghcDebugged        :: Bool }    -- ^ Build GHC with debug information.
```
Hadrian provides several built-in flavours (`defaultFlavour`, `quickFlavour`, and
a few others), which can be activated from the command line, e.g. `--flavour=quick`.
Users can define new build flavours by adding them to `userFlavours` list:
```haskell
userFlavour :: Flavour
userFlavour = defaultFlavour { name = "user", ... } -- modify the default build flavour

userFlavours :: [Flavour]
userFlavours = [userFlavour]
```
Now `--flavour=user` will run Hadrian with `userFlavour` settings. In the
following sections we look at specific fields of the `Flavour` record in
more detail. Note: `defaultFlavour`, as well as its individual fields such
as `defaultArgs`, `defaultPackages`, etc. that we use below, are defined in module
`Settings.Default`. Import it as
`import {-# SOURCE #-} Settings.Default` to handle cyclic module dependencies. 

## Command line arguments

One of the key features of Hadrian is that users can easily modify any build command.
The build system will detect the change and will rerun all
affected build rules during the next build, without requiring a full rebuild.

For example, here is how to pass an extra argument `-O0` to all invocations of
GHC when compiling package `cabal`:
```haskell
userFlavour :: Flavour
userFlavour = defaultFlavour { name = "user", args = defaultArgs <> userArgs }<commit_msg>Link to build flavours doc<commit_after># User settings

You can customise Hadrian by copying the file `hadrian/src/UserSettings.hs` to
`hadrian/UserSettings.hs` and overriding the default build settings (if you don't
copy the file your changes will be tracked by `git` and you can accidentally commit
them). Here we document currently supported settings.

## Build directory

Hadrian puts build results into `_build` directory by default, which is
specified by `buildRootPath`:
```haskell
-- | All build results are put into 'buildRootPath' directory.
buildRootPath :: FilePath
buildRootPath = "_build"
```

## Build flavour

Build _flavour_ is a collection of build settings that fully define a GHC build
(see `src/Flavour.hs`):
```haskell
data Flavour = Flavour
    { name               :: String    -- ^ Flavour name, to set from command line.
    , args               :: Args      -- ^ Use these command line arguments.
    , packages           :: Packages  -- ^ Build these packages.
    , integerLibrary     :: Package   -- ^ Either 'integerGmp' or 'integerSimple'.
    , libraryWays        :: Ways      -- ^ Build libraries these ways.
    , rtsWays            :: Ways      -- ^ Build RTS these ways.
    , splitObjects       :: Predicate -- ^ Build split objects.
    , buildHaddock       :: Predicate -- ^ Build Haddock and documentation.
    , dynamicGhcPrograms :: Bool      -- ^ Build dynamic GHC programs.
    , ghciWithDebugger   :: Bool      -- ^ Enable GHCi debugger.
    , ghcProfiled        :: Bool      -- ^ Build profiled GHC.
    , ghcDebugged        :: Bool }    -- ^ Build GHC with debug information.
```
Hadrian provides several
[built-in flavours](https://github.com/snowleopard/hadrian/blob/master/doc/flavours.md)
(`defaultFlavour`, `quickFlavour`, and
a few others), which can be activated from the command line, e.g. `--flavour=quick`.
Users can define new build flavours by adding them to `userFlavours` list:
```haskell
userFlavour :: Flavour
userFlavour = defaultFlavour { name = "user", ... } -- modify the default build flavour

userFlavours :: [Flavour]
userFlavours = [userFlavour]
```
Now `--flavour=user` will run Hadrian with `userFlavour` settings. In the
following sections we look at specific fields of the `Flavour` record in
more detail. Note: `defaultFlavour`, as well as its individual fields such
as `defaultArgs`, `defaultPackages`, etc. that we use below, are defined in module
`Settings.Default`. Import it as
`import {-# SOURCE #-} Settings.Default` to handle cyclic module dependencies. 

## Command line arguments

One of the key features of Hadrian is that users can easily modify any build command.
The build system will detect the change and will rerun all
affected build rules during the next build, without requiring a full rebuild.

For example, here is how to pass an extra argument `-O0` to all invocations of
GHC when compiling package `cabal`:
```haskell
userFlavour :: Flavour
userFlavour = defaultFlavour { name = "user", args = defaultArgs <> userArgs }
{'fraction_non_alphanumeric': 0.09115326506630854, 'fraction_numerical': 0.00033573946617424877, 'mean_word_length': 3.320522117476432, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1637516', 'n_tokens_mistral': 1720, 'n_tokens_neox': 1593, 'n_words': 698}