Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update-versions: update librdkafka to latest + niv update + ghc 8107 #191

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ghc: ["8.10.4", "8.8.4", "8.6.5"]
ghc: ["8.10.7", "8.10.4", "8.8.4", "8.6.5"]
os: [ubuntu-latest]

steps:
Expand Down Expand Up @@ -164,4 +164,3 @@ jobs:
body: Undocumented
draft: true
prerelease: false

7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# Icon must ends with two \r.
Icon


# Thumbnails
._*

Expand Down Expand Up @@ -71,3 +70,9 @@ TAGS
### Haddock
src/highlight.js
src/style.css

### VS Code
.vscode/

### Intellij IDEA
.idea/
6 changes: 2 additions & 4 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{ compiler ? "ghc843" }:
{ compiler ? "ghc8107" }:

with rec {
pkgs = (import ./nix/nixpkgs.nix {
inherit compiler;
});
pkgs = (import ./nix/nixpkgs.nix { inherit compiler; });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added nixfmt in shell.nix to format all the nix files.

drv = pkgs.haskellPackages.hw-kafka-client;
};

Expand Down
43 changes: 23 additions & 20 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
zookeeper:
image: confluentinc/cp-zookeeper
hostname: zookeeper
ports:
- 2182:2181
environment:
SERVICE_NAME: zookeeper
ZOOKEEPER_CLIENT_PORT: 2181
version: '3.8'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make this docker-compose compliant

services:

kafka:
image: confluentinc/cp-kafka:latest
hostname: localhost
ports:
- 9092:9092
links:
- zookeeper:zookeeper
environment:
KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
KAFKA_ADVERTISED_LISTENERS: "PLAINTEXT://$KAFKA_TEST_BROKER:9092"
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_CREATE_TOPICS:
zookeeper:
image: confluentinc/cp-zookeeper:latest
hostname: zookeeper
ports:
- 2182:2181
environment:
SERVICE_NAME: zookeeper
ZOOKEEPER_CLIENT_PORT: 2181

kafka:
image: confluentinc/cp-kafka:latest
hostname: localhost
ports:
- 9092:9092
links:
- zookeeper:zookeeper
environment:
KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
KAFKA_ADVERTISED_LISTENERS: "PLAINTEXT://$KAFKA_TEST_BROKER:9092"
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_CREATE_TOPICS:
2 changes: 1 addition & 1 deletion hw-kafka-client.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ author: Alexey Raga <alexey.raga@gmail.com>
maintainer: Alexey Raga <alexey.raga@gmail.com>
license: MIT
license-file: LICENSE
tested-with: GHC == 8.10.2, GHC == 8.8.3, GHC == 8.6.5, GHC == 8.4.4
tested-with: GHC == 8.10.7, GHC == 8.10.2, GHC == 8.8.3, GHC == 8.6.5, GHC == 8.4.4
build-type: Simple
extra-source-files: README.md

Expand Down
53 changes: 43 additions & 10 deletions nix/nixpkgs.nix
Original file line number Diff line number Diff line change
@@ -1,20 +1,53 @@
{ compiler ? "ghc843" }:
{ compiler ? "ghc8107" }:

with rec {
sources = import ./sources.nix;
nivOverlay = _: pkgs:
{ niv = (import sources.niv {}).niv; # use the sources :)
};
nivOverlay = _: pkgs: {
niv = (import sources.niv { }).niv; # use the sources :)
};
};

import sources.nixpkgs {
config = {
packageOverrides = super: let self = super.pkgs; in {
haskellPackages = super.haskell.packages.${compiler}.override {
overrides = import ./overrides.nix { pkgs = self; };
packageOverrides = super:
let self = super.pkgs;
in {
haskellPackages = super.haskell.packages.${compiler}.override {
overrides = import ./overrides.nix { pkgs = self; };
};
};

};
};
overlays = [nivOverlay];
# Following lines are useful for:
# Known issues:
# - Support for OpenSSL 1.0.2 ended with 2019.

# You can install it anyway by allowing this package, using the
# following methods:

# a) To temporarily allow all insecure packages, you can use an environment
# variable for a single invocation of the nix tools:

# $ export NIXPKGS_ALLOW_INSECURE=1

# b) for `nixos-rebuild` you can add ‘openssl-1.0.2u’ to
# `nixpkgs.config.permittedInsecurePackages` in the configuration.nix,
# like so:

# {
# nixpkgs.config.permittedInsecurePackages = [
# "openssl-1.0.2u"
# ];
# }

# c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
# ‘openssl-1.0.2u’ to `permittedInsecurePackages` in
# ~/.config/nixpkgs/config.nix, like so:

# {
# permittedInsecurePackages = [
# "openssl-1.0.2u"
# ];
# }
config.permittedInsecurePackages = [ "openssl-1.0.2u" ];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the line required by nettools I guess I should add a comment, what do you think?

overlays = [ nivOverlay ];
}
14 changes: 7 additions & 7 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
"homepage": "https://github.com/nmattia/niv",
"owner": "nmattia",
"repo": "niv",
"rev": "65a61b147f307d24bfd0a5cd56ce7d7b7cc61d2e",
"sha256": "17mirpsx5wyw262fpsd6n6m47jcgw8k2bwcp1iwdnrlzy4dhcgqh",
"rev": "5830a4dd348d77e39a0f3c4c762ff2663b602d4c",
"sha256": "1d3lsrqvci4qz2hwjrcnd8h5vfkg8aypq3sjd4g3izbc8frwz5sm",
"type": "tarball",
"url": "https://github.com/nmattia/niv/archive/65a61b147f307d24bfd0a5cd56ce7d7b7cc61d2e.tar.gz",
"url": "https://github.com/nmattia/niv/archive/5830a4dd348d77e39a0f3c4c762ff2663b602d4c.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
"branch": "nixos-21.05",
"branch": "nixpkgs-unstable",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my point of view, I prefer to go on unstable to get latest dependencies and don't wait for months before being able to get the latest release.
I can switch back to nixos if you want.

"description": "Nix Packages collection",
"homepage": "",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ce7a1190a0fa4ba3465b5f5471b08567060ca14c",
"sha256": "1zr1s9gp0h5g4arlba1bpb9yqfaaby5195ydm6a2psaxhm748li9",
"rev": "77fda7f672726e1a95c8cd200f27bccfc86c870b",
"sha256": "07qj1d45pkqsmkahbhh7hilwwbvg8vlz1wg497hzjrlx1a57v4y5",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/ce7a1190a0fa4ba3465b5f5471b08567060ca14c.tar.gz",
"url": "https://github.com/NixOS/nixpkgs/archive/77fda7f672726e1a95c8cd200f27bccfc86c870b.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}
66 changes: 46 additions & 20 deletions nix/sources.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,33 @@ let
# The fetchers. fetch_<type> fetches specs of type <type>.
#

fetch_file = pkgs: spec:
if spec.builtin or true then
builtins_fetchurl { inherit (spec) url sha256; }
else
pkgs.fetchurl { inherit (spec) url sha256; };
fetch_file = pkgs: name: spec:
let
name' = sanitizeName name + "-src";
in
if spec.builtin or true then
builtins_fetchurl { inherit (spec) url sha256; name = name'; }
else
pkgs.fetchurl { inherit (spec) url sha256; name = name'; };

fetch_tarball = pkgs: name: spec:
let
ok = str: ! builtins.isNull (builtins.match "[a-zA-Z0-9+-._?=]" str);
# sanitize the name, though nix will still fail if name starts with period
name' = stringAsChars (x: if ! ok x then "-" else x) "${name}-src";
name' = sanitizeName name + "-src";
in
if spec.builtin or true then
builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
else
pkgs.fetchzip { name = name'; inherit (spec) url sha256; };

fetch_git = spec:
builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; };
fetch_git = name: spec:
let
ref =
if spec ? ref then spec.ref else
if spec ? branch then "refs/heads/${spec.branch}" else
if spec ? tag then "refs/tags/${spec.tag}" else
abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
in
builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; };

fetch_local = spec: spec.path;

Expand All @@ -40,11 +48,21 @@ let
# Various helpers
#

# https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695
sanitizeName = name:
(
concatMapStrings (s: if builtins.isList s then "-" else s)
(
builtins.split "[^[:alnum:]+._?=-]+"
((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name)
)
);

# The set of packages used when specs are fetched using non-builtins.
mkPkgs = sources:
mkPkgs = sources: system:
let
sourcesNixpkgs =
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) {};
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; };
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
in
Expand All @@ -64,9 +82,9 @@ let

if ! builtins.hasAttr "type" spec then
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
else if spec.type == "file" then fetch_file pkgs spec
else if spec.type == "file" then fetch_file pkgs name spec
else if spec.type == "tarball" then fetch_tarball pkgs name spec
else if spec.type == "git" then fetch_git spec
else if spec.type == "git" then fetch_git name spec
else if spec.type == "local" then fetch_local spec
else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
else if spec.type == "builtin-url" then fetch_builtin-url name
Expand All @@ -80,7 +98,10 @@ let
saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
in
if ersatz == "" then drv else ersatz;
if ersatz == "" then drv else
# this turns the string into an actual Nix path (for both absolute and
# relative paths)
if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}";

# Ports of functions for older nix versions

Expand All @@ -98,25 +119,29 @@ let

# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
concatMapStrings = f: list: concatStrings (map f list);
concatStrings = builtins.concatStringsSep "";

# https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
optionalAttrs = cond: as: if cond then as else {};

# fetchTarball version that is compatible between all the versions of Nix
builtins_fetchTarball = { url, name, sha256 }@attrs:
builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
let
inherit (builtins) lessThan nixVersion fetchTarball;
in
if lessThan nixVersion "1.12" then
fetchTarball { inherit name url; }
fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
else
fetchTarball attrs;

# fetchurl version that is compatible between all the versions of Nix
builtins_fetchurl = { url, sha256 }@attrs:
builtins_fetchurl = { url, name ? null, sha256 }@attrs:
let
inherit (builtins) lessThan nixVersion fetchurl;
in
if lessThan nixVersion "1.12" then
fetchurl { inherit url; }
fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
else
fetchurl attrs;

Expand All @@ -135,7 +160,8 @@ let
mkConfig =
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
, sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
, pkgs ? mkPkgs sources
, system ? builtins.currentSystem
, pkgs ? mkPkgs sources system
}: rec {
# The sources, i.e. the attribute set of spec name to spec
inherit sources;
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-librdkafka
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

RDKAFKA_VER="1a722553638bba85dbda5050455f7b9a5ef302de"
RDKAFKA_VER="063a9ae7a65cebdf1cc128da9815c05f91a2a996"

PRJ=$PWD
DST="$PRJ/.librdkafka"
Expand Down
3 changes: 3 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ pkgs.mkShell {
nettools
niv
gmp
docker-compose
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you provide a docker-compose.yaml it is good to also provider docker-compose binary.

nixfmt
colima
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a way to use docker on MacOS without having to install Docker Desktop which is not free anymore in some cases.

];

shellHook = ''
Expand Down