Skip to content

Instantly share code, notes, and snippets.

@lspitzner
Last active July 29, 2018 23:46
Show Gist options
  • Save lspitzner/fcd41eb5c3111a2bbd192a77b7697663 to your computer and use it in GitHub Desktop.
Save lspitzner/fcd41eb5c3111a2bbd192a77b7697663 to your computer and use it in GitHub Desktop.
nix-local-build
old-style new-style
install --only-dependencies part of new-build
install path-to-local-dir add a ./cabal.project file, add your local dependency, then use new-build (cabal.project syntax is described in the announcement)
install path-to-local-sdist does not exist yet
install remote-package-uri does not exist yet
install [--bindir=..] does not exist (yet)
configure new-configure
build (part of) new-build
clean does not exist yet; you have to remove ./dist-newstyle/ and ./cabal.project.local by hand, and potentially ./dist/ as well, i may have observed that it got touched by new-build (not sure, really). This needs to be done for each package referenced from the cabal.project as well.
run does not exist yet; you can new-build and ./dist-newstyle/build/PACKAGE-VERSION/build/EXECUTABLE/EXECUTABLE
repl new-repl
test does not exist yet; you can new-build --enable-tests and ./dist-newstyle/build/PACKAGE-VERSION/build/TEST/TEST
bench does not exist yet; see above.
haddock does not exist yet
freeze does not exist yet

semantics

new-configure FLAGS

  • (over)write ./cabal.project.local according to FLAGS

new-build [FLAGS] [TARGET..]

  • builds one or more components, including setting up/building local and non-local dependencies.

  • project setup is read from ./cabal.project. If only a foo.cabal package description is present, applies an implicit one-package setup.

  • configuration flags are read, in ascending priority, from

    1. $HOME/.cabal/config
    2. ./cabal.project
    3. ./cabal.project.local (see new-configure)
    4. FLAGS from the commandline (these will not be persisted in any way) note that ./cabal.config is not considered.
  • each TARGET has the form PACKAGEPATH | PACKAGEFILEPATH | [PACKAGE][:][[COMPONENTTYPE:]COMPONENT] where

    • PACKAGEPATH is the path of a directory containing a .cabal file
    • PACKAGEFILEPATH is the path of a .cabal file
    • COMPONENTTYPE is "lib", "exe", "test" or "bench".
  • if no TARGETs are specified, acts like there is one TARGET "./", i.e. build the package in the current directory. Note that nothing will be built if there is no package in "./".

  • PACKAGE must be a packagename from the set of visible packages. Visible packages are: If present, those specified in cabal.project; Otherwise, all packages located at any */*.cabal, i.e. packages in the current directory or its direct children.

  • effects:

    1. install remote dependencies into the user-local "store" ($HOME/.cabal/store/) (as time of writing, uri dependencies are not supported; not sure where those would be put. just to clarify "remote".)
    2. build COMPONENTS and their local dependencies; by default all buildable cabal package components for all packages in the project setup, respecting configuration like --enable/disable-tests [TODO: clarify default]
    3. local dependencies are registered locally only.
    4. for all local dependencies, (re)building is omitted if no changes (to configuration, local package contents and used (remote) dependency (versions)) are detected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment