From f68fbb3118aabaa961e24530f0105fc95578a0b5 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Sat, 26 Jan 2019 10:55:29 -0800 Subject: [PATCH 1/2] Add build instructions for nix --- .gitignore | 1 + README.md | 6 ++++++ default.nix | 13 +++++++++++++ pkgs.nix | 5 +++++ 4 files changed, 25 insertions(+) create mode 100644 default.nix create mode 100644 pkgs.nix diff --git a/.gitignore b/.gitignore index 906e747..4393459 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ local/ cabal.sandbox.config cabal.project.local .ghc.environment.* +result \ No newline at end of file diff --git a/README.md b/README.md index d42d085..da9675b 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,12 @@ log the size of the input, but _not_ the full input/output of requests.) aura -A brittany ~~~~ +- via `nix`: + ~~~.sh + nix build # or 'nix-build' + nix-env -i ./result + ~~~ + # Editor Integration #### Sublime text diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..5c0ccfe --- /dev/null +++ b/default.nix @@ -0,0 +1,13 @@ +{ pkgs ? import (fetchGit (import ./pkgs.nix)) {} +, compiler ? "ghc822" +}: + +pkgs.haskell.packages.${compiler}.developPackage { + root = ./.; + name = "brittany"; + overrides = with pkgs.haskell.lib; self: super: { + }; + source-overrides = { + ghc-exactprint = "0.5.8.0"; + }; +} diff --git a/pkgs.nix b/pkgs.nix new file mode 100644 index 0000000..76cbbb8 --- /dev/null +++ b/pkgs.nix @@ -0,0 +1,5 @@ +{ + url = "https://github.com/nixos/nixpkgs.git"; + ref = "release-18.09"; + rev = "b9fa31cea0e119ecf1867af4944ddc2f7633aacd"; +} -- 2.30.2 From e67a46f2649ee53380f2a7d933588e8587ba0ecd Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Tue, 29 Jan 2019 14:01:29 -0800 Subject: [PATCH 2/2] Refactor nix expressions This way, the default.nix file can be imported to other projects. In order to build brittany, we now need to do `nix build -f release.nix`, which will pull in the version overrides from shell.nix. --- README.md | 2 +- default.nix | 47 ++++++++++++++++++++++++++++++++++++----------- release.nix | 5 +++++ shell.nix | 13 +++++++++++++ 4 files changed, 55 insertions(+), 12 deletions(-) create mode 100644 release.nix create mode 100644 shell.nix diff --git a/README.md b/README.md index da9675b..672de96 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ log the size of the input, but _not_ the full input/output of requests.) - via `nix`: ~~~.sh - nix build # or 'nix-build' + nix build -f release.nix # or 'nix-build -f release.nix' nix-env -i ./result ~~~ diff --git a/default.nix b/default.nix index 5c0ccfe..296987a 100644 --- a/default.nix +++ b/default.nix @@ -1,13 +1,38 @@ -{ pkgs ? import (fetchGit (import ./pkgs.nix)) {} -, compiler ? "ghc822" +{ mkDerivation, aeson, base, butcher, bytestring, cmdargs +, containers, czipwith, data-tree-print, deepseq, directory, extra +, filepath, ghc, ghc-boot-th, ghc-exactprint, ghc-paths, hspec +, monad-memo, mtl, multistate, neat-interpolation, parsec, pretty +, random, safe, semigroups, stdenv, strict, syb, text, transformers +, uniplate, unsafe, yaml }: - -pkgs.haskell.packages.${compiler}.developPackage { - root = ./.; - name = "brittany"; - overrides = with pkgs.haskell.lib; self: super: { - }; - source-overrides = { - ghc-exactprint = "0.5.8.0"; - }; +mkDerivation { + pname = "brittany"; + version = "0.11.0.0"; + src = ./.; + isLibrary = true; + isExecutable = true; + libraryHaskellDepends = [ + aeson base butcher bytestring cmdargs containers czipwith + data-tree-print deepseq directory extra filepath ghc ghc-boot-th + ghc-exactprint ghc-paths monad-memo mtl multistate + neat-interpolation pretty random safe semigroups strict syb text + transformers uniplate unsafe yaml + ]; + executableHaskellDepends = [ + aeson base butcher bytestring cmdargs containers czipwith + data-tree-print deepseq directory extra filepath ghc ghc-boot-th + ghc-exactprint ghc-paths monad-memo mtl multistate + neat-interpolation pretty safe semigroups strict syb text + transformers uniplate unsafe yaml + ]; + testHaskellDepends = [ + aeson base butcher bytestring cmdargs containers czipwith + data-tree-print deepseq directory extra filepath ghc ghc-boot-th + ghc-exactprint ghc-paths hspec monad-memo mtl multistate + neat-interpolation parsec pretty safe semigroups strict syb text + transformers uniplate unsafe yaml + ]; + homepage = "https://github.com/lspitzner/brittany/"; + description = "Haskell source code formatter"; + license = stdenv.lib.licenses.agpl3; } diff --git a/release.nix b/release.nix new file mode 100644 index 0000000..b37b2ce --- /dev/null +++ b/release.nix @@ -0,0 +1,5 @@ +{ pkgs ? import (fetchGit (import ./pkgs.nix)) {} +, compiler ? "ghc822" +}: + +pkgs.haskell.packages.${compiler}.callPackage ./shell.nix {} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..5c0ccfe --- /dev/null +++ b/shell.nix @@ -0,0 +1,13 @@ +{ pkgs ? import (fetchGit (import ./pkgs.nix)) {} +, compiler ? "ghc822" +}: + +pkgs.haskell.packages.${compiler}.developPackage { + root = ./.; + name = "brittany"; + overrides = with pkgs.haskell.lib; self: super: { + }; + source-overrides = { + ghc-exactprint = "0.5.8.0"; + }; +} -- 2.30.2