diff --git a/.circleci/config.yml b/.circleci/config.yml index b24b72a..a11b18c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -23,6 +23,12 @@ jobs: echo "keep-outputs = true" | sudo tee -a /etc/nix/nix.conf echo "keep-derivations = true" | sudo tee -a /etc/nix/nix.conf + # Set a new TMP because /run/user is (1) pretty small and (2) + # mounted with noexec + new_tmp=$HOME/tmp + mkdir -p $new_tmp + echo "export TMPDIR=$new_tmp" >> $BASH_ENV + # Builds everything from scratch on master. On a branch the branch's # cache is used if it exists, otherwise the latest cache generated from # master is used. diff --git a/README.md b/README.md index 3fd581a..f090ce3 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,7 @@ $ nix-env -iA niv -f https://github.com/nmattia/niv/tarball/master Inside the provided nix shell: ``` bash -$ # GHCi: -$ snack ghci -$ # run: -$ snack run -- +$ repl ``` Run the test suite with this command: diff --git a/README.tpl.md b/README.tpl.md index de1d7e4..25d64d9 100644 --- a/README.tpl.md +++ b/README.tpl.md @@ -16,10 +16,7 @@ $ nix-env -iA niv -f https://github.com/nmattia/niv/tarball/master Inside the provided nix shell: ``` bash -$ # GHCi: -$ snack ghci -$ # run: -$ snack run -- +$ repl ``` Run the test suite with this command: diff --git a/Main.hs b/app/Niv.hs similarity index 99% rename from Main.hs rename to app/Niv.hs index e0b37a9..ac90698 100644 --- a/Main.hs +++ b/app/Niv.hs @@ -6,8 +6,6 @@ {-# LANGUAGE TupleSections #-} {-# LANGUAGE ViewPatterns #-} -module Main (main) where - import Control.Applicative import Control.Monad import Control.Monad.State diff --git a/default.nix b/default.nix index bda28df..9d27d31 100644 --- a/default.nix +++ b/default.nix @@ -1,6 +1,31 @@ { pkgs ? import ./nix {} }: +with rec +{ niv-source = pkgs.lib.sourceByRegex ./. + [ "^package.yaml$" + "^app.*$" + "^README.md$" + ]; + haskellPackages = pkgs.haskellPackages.override + { overrides = _: haskellPackages: + { niv = haskellPackages.callCabal2nix "niv" niv-source {}; }; + }; + + niv-devshell = haskellPackages.shellFor + { packages = (ps: [ ps.niv ]); + shellHook = + '' + repl() { + ghci Main.hs + } + + echo "To start a REPL session, run:" + echo " > repl" + ''; + }; +}; rec -{ niv = pkgs.snack-lib.executable ./package.yaml; +{ inherit niv-source niv-devshell; + inherit (haskellPackages) niv; readme = pkgs.writeText "README.md" (with { template = builtins.readFile ./README.tpl.md; diff --git a/nix/sources.json b/nix/sources.json index 516998b..e0edb8d 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -1,15 +1,4 @@ { - "snack": { - "homepage": "", - "url": "https://github.com/nmattia/snack/archive/7b90144a01fff7e5eeb520a6b774377f75e44205.tar.gz", - "owner": "nmattia", - "branch": "master", - "url_template": "https://github.com///archive/.tar.gz", - "repo": "snack", - "sha256": "0p0bldlr83i4bigsv0ygnn7q0lv25hkjd5n4nm1vlvwm9cp8n5dn", - "description": "Nix-based incremental build tool for Haskell projects", - "rev": "7b90144a01fff7e5eeb520a6b774377f75e44205" - }, "nixpkgs": { "url": "https://github.com/NixOS/nixpkgs-channels/archive/8e70d4bd7d5e1c137006fe483d8d116311694bc2.tar.gz", "owner": "NixOS", diff --git a/package.yaml b/package.yaml index dad8f63..9ec6318 100644 --- a/package.yaml +++ b/package.yaml @@ -1,13 +1,19 @@ name: niv +license: MIT + ghc-options: - -Wall - -Werror executable: - source-dirs: . # remove when https://github.com/nmattia/snack/pull/96 is merged - main: Main.hs + main: app/Niv.hs dependencies: + - base + - hashable + - process + - text + - bytestring - aeson - aeson-pretty - directory diff --git a/shell.nix b/shell.nix index fa416db..4d49dae 100644 --- a/shell.nix +++ b/shell.nix @@ -1,4 +1,2 @@ -with { pkgs = import ./nix {}; }; -pkgs.mkShell - { buildInputs = [ pkgs.snack-exe ]; - } +{ pkgs ? import ./nix {} }: +(import ./default.nix { inherit pkgs; }).niv-devshell