Skip to content

Commit

Permalink
Update to nixpkgs 17.09 (awakesecurity#50)
Browse files Browse the repository at this point in the history
* Deterministically pin to a 17.09 nixpkgs

* Remove out-of-date cabal2nix output

* `proto3-wire` → `d492fa3`

* Fix shebangs for test scripts

* Remove test scripts patchfile

We no longer need to patch in this manner, as we will ensure that the correct
GHC is on the nix-shell $PATH.

* Don't barf on unset PYTHONPATH

* Relax `aeson` bound

* Simplify and cleanup toplevel nix

* rm `nixpkgs.json`

* Workaround High Sierra linking issue by restructuring ...

the `nix-shell` GHC vs. that used by `testHaskellDepends`.
  • Loading branch information
intractable authored Jan 21, 2018
1 parent 853b4ac commit 94a8791
Show file tree
Hide file tree
Showing 18 changed files with 105 additions and 284 deletions.
1 change: 1 addition & 0 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mkDerivation {
src = ./.;
isLibrary = true;
isExecutable = true;
enableSeparateDataOutput = true;
libraryHaskellDepends = [
aeson aeson-pretty attoparsec base base64-bytestring bytestring
cereal containers deepseq foldl haskell-src lens mtl
Expand Down
20 changes: 0 additions & 20 deletions nix/aeson-pretty.nix

This file was deleted.

32 changes: 0 additions & 32 deletions nix/aeson.nix

This file was deleted.

10 changes: 0 additions & 10 deletions nix/cabal-doctest.nix

This file was deleted.

23 changes: 0 additions & 23 deletions nix/insert-ordered-containers.nix

This file was deleted.

15 changes: 0 additions & 15 deletions nix/neat-interpolation.nix

This file was deleted.

15 changes: 0 additions & 15 deletions nix/optparse-applicative.nix

This file was deleted.

14 changes: 0 additions & 14 deletions nix/optparse-generic.nix

This file was deleted.

6 changes: 3 additions & 3 deletions nix/proto3-wire.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ mkDerivation {
pname = "proto3-wire";
version = "1.0.0";
src = fetchgit {
url = "https://github.com/awakenetworks/proto3-wire";
sha256 = "14n0d16an782ayipirm5v2mvp58jgf65xvffqzp08p50sksil3gi";
rev = "a938330bf794cf3fa05591d03906915df98d157c";
url = "https://github.com/awakenetworks/proto3-wire.git";
sha256 = "0nlar9zwy7k47nm395h11ivmhhfhip5bhyazwa2gnffn5lhsyv3i";
rev = "d492fa3034724b46f23fb2c73780c9dd7ecb4d04";
};
libraryHaskellDepends = [
base bytestring cereal containers deepseq hashable QuickCheck safe
Expand Down
20 changes: 0 additions & 20 deletions nix/turtle.nix

This file was deleted.

12 changes: 12 additions & 0 deletions nixpkgs/17_09.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Given a Git revision hash `<rev>`, you get the new SHA256 by running:
#
# ```bash
# $ nix-prefetch-url "https://github.com/NixOS/nixpkgs/archive/<rev>.tar.gz"
# ```
#
# The SHA256 will be printed as the last line of stdout.

import ./fetch-nixpkgs.nix {
rev = "74286ec9e76be7cd00c4247b9acb430c4bd9f1ce";
sha256 = "0njb3qd2wxj7gil8y61lwh7zacmvr6zklv67w5zmvifi1fvalvdg";
}
2 changes: 1 addition & 1 deletion fetch-nixpkgs.nix → nixpkgs/fetch-nixpkgs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ifThenElse {
};

builtin-paths = import <nix/config.nix>;

script = builtins.toFile "nixpkgs-unpacker" ''
"$coreutils/mkdir" "$out"
cd "$out"
Expand Down
4 changes: 2 additions & 2 deletions proto3-suite.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ library
other-modules: Proto3.Suite.DotProto.Internal
Proto3.Suite.DotProto.Generate.Swagger
Proto3.Suite.JSONPB.Class
build-depends: aeson == 1.1.1.0,
build-depends: aeson >= 1.1.1.0 && < 1.2,
aeson-pretty,
attoparsec >= 0.13.0.1,
base >=4.8 && <5.0,
Expand Down Expand Up @@ -66,7 +66,7 @@ test-suite tests
default-language: Haskell2010
build-depends: base >=4.8 && <5.0,
QuickCheck >=2.8 && <2.10,
aeson == 1.1.1.0,
aeson >= 1.1.1.0 && < 1.2,
attoparsec >= 0.13.0.1,
base >=4.8 && <5.0,
base64-bytestring >= 1.0.0.1 && < 1.1,
Expand Down
151 changes: 71 additions & 80 deletions release.nix
Original file line number Diff line number Diff line change
@@ -1,99 +1,90 @@
# To develop with this repository, open a Nix shell with:
# To develop iteratively within this repository, open a Nix shell via:
#
# $ nix-shell -A proto3-suite.env release.nix
#
# ... then run `cabal` commands as you would normally do:
# ... and then use `cabal` to build and test:
#
# [nix-shell]$ cabal configure --with-gcc=clang --enable-tests
# [nix-shell]$ cabal configure --enable-tests
# [nix-shell]$ cabal build
# [nix-shell]$ cabal test

let
config = {
packageOverrides = pkgs:
let
python_protobuf3_0 =
(pkgs.pythonPackages.protobufBuild pkgs.protobuf3_0).override {
doCheck = false;
};
in
{ haskellPackages = pkgs.haskellPackages.override {
overrides = haskellPackagesNew: haskellPackagesOld: rec {

aeson =
pkgs.haskell.lib.dontCheck (haskellPackagesNew.callPackage ./nix/aeson.nix { });

aeson-pretty =
haskellPackagesNew.callPackage ./nix/aeson-pretty.nix { };

cabal-doctest =
haskellPackagesNew.callPackage ./nix/cabal-doctest.nix { };

insert-ordered-containers =
haskellPackagesNew.callPackage ./nix/insert-ordered-containers.nix { };

neat-interpolation =
haskellPackagesNew.callPackage ./nix/neat-interpolation.nix { };

optparse-applicative =
haskellPackagesNew.callPackage ./nix/optparse-applicative.nix { } ;

optparse-generic =
haskellPackagesNew.callPackage ./nix/optparse-generic.nix { } ;

proto3-suite-no-tests =
pkgs.haskell.lib.dontCheck
(haskellPackagesNew.callPackage ./default.nix { });

proto3-suite =
pkgs.haskell.lib.overrideCabal
(haskellPackagesNew.callPackage ./default.nix { })
(oldAttrs: {
patches = [ tests/tests.patch ];

postPatch = ''
substituteInPlace tests/encode.sh --replace @ghc@ ${pkgs.ghc} --replace @bash@ ${pkgs.bash}
substituteInPlace tests/decode.sh --replace @ghc@ ${pkgs.ghc} --replace @bash@ ${pkgs.bash}
'';

testHaskellDepends = oldAttrs.testHaskellDepends ++ [
pkgs.ghc
proto3-suite-no-tests
pkgs.protobuf3_0
pkgs.python
python_protobuf3_0
];
}
);

proto3-wire =
haskellPackagesNew.callPackage ./nix/proto3-wire.nix { };

scientific =
pkgs.haskell.lib.dontCheck haskellPackagesOld.scientific;

swagger2 =
pkgs.haskell.lib.dontHaddock (haskellPackagesNew.callPackage ./nix/swagger2.nix { });

turtle =
haskellPackagesNew.callPackage ./nix/turtle.nix { } ;

};
};
};
nixpkgs = import ./nixpkgs/17_09.nix;

config = {
allowUnfree = true;
};

nixpkgs = import ./fetch-nixpkgs.nix {
rev = "7ae9da426924537755ce9164fd5b5f81ce16a1c3";
sha256 = "1zg1j2fsfj6qhh724nc8fnn3ig3rm6nd29zzhjrbjkszkjspc9pl";
packageOverrides = pkgs: {
haskellPackages = pkgs.haskellPackages.override {
overrides = self: super: rec {

# The test suite for proto3-suite requires:
#
# - a GHC with `proto3-suite` installed, since our code generation
# tests compile and run generated code; since this custom GHC is
# also used inside the nix-shell environment for iterative
# development, we ensure that it is available on $PATH and that
# all test suite deps are available to it
#
# - a Python interpreter with a protobuf package installed, which we
# use as a reference implementation; we also put expose this on
# the `nix-shell` $PATH
#
# Finally, we make `cabal` available in the `nix-shell`, intentionally
# occluding any globally-installed versions of the tool.

proto3-suite =
pkgs.haskell.lib.overrideCabal
(self.callPackage ./default.nix { })
(drv:
let
python = pkgs.python.withPackages (pkgs: [ pkgs.protobuf3_0 ]);
in
{
shellHook = (drv.shellHook or "") +
(let
ghc = self.ghcWithPackages (pkgs:
drv.testHaskellDepends ++ [ pkgs.proto3-suite-boot ]
);
in ''
export PATH=${self.cabal-install}/bin:${ghc}/bin:${python}/bin''${PATH:+:}$PATH
'');

testHaskellDepends = drv.testHaskellDepends ++ [
pkgs.ghc
proto3-suite-boot
python
];
}
);

# A proto3-suite sans tests, for bootstrapping
proto3-suite-boot =
pkgs.haskell.lib.overrideCabal
(self.callPackage ./default.nix { })
(_: {
configureFlags = [ "--disable-optimization" ];
doCheck = false;
doHaddock = false;
});

proto3-wire =
self.callPackage ./nix/proto3-wire.nix { };

swagger2 =
pkgs.haskell.lib.dontCheck
(pkgs.haskell.lib.dontHaddock
(self.callPackage ./nix/swagger2.nix { }));
};
};
};
};
in

let
linuxPkgs = import nixpkgs { inherit config; system = "x86_64-linux" ; };
darwinPkgs = import nixpkgs { inherit config; system = "x86_64-darwin"; };
pkgs = import nixpkgs { inherit config; };

in
{ proto3-suite-linux = linuxPkgs.haskellPackages.proto3-suite;
proto3-suite-darwin = darwinPkgs.haskellPackages.proto3-suite;
Expand Down
Loading

0 comments on commit 94a8791

Please sign in to comment.