mirror of
https://github.com/circuithub/rel8.git
synced 2024-10-27 02:08:37 +03:00
Move to Haskell.nix
This commit is contained in:
parent
1a73d57585
commit
5cdf94558e
1
cabal.project
Normal file
1
cabal.project
Normal file
@ -0,0 +1 @@
|
|||||||
|
packages: .
|
40
default.nix
40
default.nix
@ -1,22 +1,20 @@
|
|||||||
{ mkDerivation, aeson, base, bytestring, case-insensitive, hedgehog
|
let
|
||||||
, lifted-base, monad-control, opaleye, postgresql-simple
|
haskellNix = import (import ./nix/sources.nix)."haskell.nix" {};
|
||||||
, product-profunctors, profunctors, scientific, semigroupoids
|
|
||||||
, stdenv, tasty, tasty-hedgehog, text, time, tmp-postgres, uuid
|
nixpkgsSrc = haskellNix.sources.nixpkgs-2009;
|
||||||
}:
|
|
||||||
mkDerivation {
|
nixpkgsArgs = haskellNix.nixpkgsArgs;
|
||||||
pname = "rel8";
|
|
||||||
version = "0.1.0.0";
|
compiler-nix-name = "ghc8103";
|
||||||
src = ./.;
|
|
||||||
libraryHaskellDepends = [
|
pkgs = import nixpkgsSrc nixpkgsArgs;
|
||||||
aeson base bytestring case-insensitive opaleye postgresql-simple
|
|
||||||
product-profunctors profunctors scientific semigroupoids text time
|
in
|
||||||
uuid
|
pkgs.haskell-nix.project {
|
||||||
];
|
inherit compiler-nix-name;
|
||||||
testHaskellDepends = [
|
|
||||||
base bytestring case-insensitive hedgehog lifted-base monad-control
|
src = pkgs.haskell-nix.haskellLib.cleanGit {
|
||||||
postgresql-simple scientific tasty tasty-hedgehog text time
|
name = "rel8";
|
||||||
tmp-postgres uuid
|
src = ./.;
|
||||||
];
|
};
|
||||||
description = "Hey! Hey! Can u rel8?";
|
|
||||||
license = stdenv.lib.licenses.bsd2;
|
|
||||||
}
|
}
|
||||||
|
7
jobs.nix
7
jobs.nix
@ -1,2 +1,5 @@
|
|||||||
let pkgs = import ./nix/pkgs.nix;
|
let project = import ./.;
|
||||||
in { rel8 = pkgs.haskellPackages.rel8; }
|
in {
|
||||||
|
rel8 = project.hsPkgs.components.library;
|
||||||
|
tests = project.hsPkgs.components.checks.tests;
|
||||||
|
}
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
[
|
|
||||||
(import ./overlays/haskell-packages.nix)
|
|
||||||
]
|
|
@ -1,40 +0,0 @@
|
|||||||
self:
|
|
||||||
super:
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (self) haskell haskellPackages;
|
|
||||||
|
|
||||||
inherit (haskellPackages) callCabal2nix;
|
|
||||||
|
|
||||||
inherit (haskell.lib) addBuildTool appendConfigureFlag packagesFromDirectory;
|
|
||||||
|
|
||||||
inherit (super.lib) composeExtensions;
|
|
||||||
|
|
||||||
pkgs = self;
|
|
||||||
|
|
||||||
WError =
|
|
||||||
drv: appendConfigureFlag drv "--ghc-option=-Werror";
|
|
||||||
|
|
||||||
configurations =
|
|
||||||
self: super: {
|
|
||||||
rel8 = addBuildTool (WError (callCabal2nix "rel8" (builtins.path { path = ../../.; name = "rel8"; }) {})) pkgs.postgresql;
|
|
||||||
};
|
|
||||||
|
|
||||||
in
|
|
||||||
{
|
|
||||||
haskellPackages =
|
|
||||||
super.haskellPackages.override
|
|
||||||
(
|
|
||||||
old:
|
|
||||||
{
|
|
||||||
overrides =
|
|
||||||
composeExtensions
|
|
||||||
(old.overrides or (_: _: {}))
|
|
||||||
(
|
|
||||||
composeExtensions
|
|
||||||
(packagesFromDirectory { directory = ./haskell-packages; })
|
|
||||||
configurations
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
{ mkDerivation, aeson, base, base16-bytestring, bytestring
|
|
||||||
, case-insensitive, containers, contravariant, dotenv, hspec
|
|
||||||
, hspec-discover, multiset, postgresql-simple, pretty
|
|
||||||
, product-profunctors, profunctors, QuickCheck, scientific
|
|
||||||
, semigroups, stdenv, text, time, time-locale-compat, transformers
|
|
||||||
, uuid, void
|
|
||||||
}:
|
|
||||||
mkDerivation {
|
|
||||||
pname = "opaleye";
|
|
||||||
version = "0.7.1.0";
|
|
||||||
sha256 = "c65faccdc01207d94500198b3ec33db7daaa25daae28d47f234b9ad6926f9644";
|
|
||||||
revision = "3";
|
|
||||||
editedCabalFile = "14y8nnng9307wb1mafzdr2fmn37cwyfpw9sby8lf9sj467rvghrq";
|
|
||||||
libraryHaskellDepends = [
|
|
||||||
aeson base base16-bytestring bytestring case-insensitive
|
|
||||||
contravariant postgresql-simple pretty product-profunctors
|
|
||||||
profunctors scientific semigroups text time time-locale-compat
|
|
||||||
transformers uuid void
|
|
||||||
];
|
|
||||||
testHaskellDepends = [
|
|
||||||
aeson base bytestring containers contravariant dotenv hspec
|
|
||||||
hspec-discover multiset postgresql-simple product-profunctors
|
|
||||||
profunctors QuickCheck semigroups text time transformers uuid
|
|
||||||
];
|
|
||||||
testToolDepends = [ hspec-discover ];
|
|
||||||
doCheck = false;
|
|
||||||
homepage = "https://github.com/tomjaguarpaw/haskell-opaleye";
|
|
||||||
description = "An SQL-generating DSL targeting PostgreSQL";
|
|
||||||
license = stdenv.lib.licenses.bsd3;
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
{ mkDerivation, ansi-wl-pprint, async, base, base64-bytestring
|
|
||||||
, bytestring, containers, criterion, cryptohash-sha1, deepseq
|
|
||||||
, directory, generic-monoid, hspec, mtl, network, port-utils
|
|
||||||
, postgres-options, postgresql-simple, process, stdenv, stm
|
|
||||||
, temporary, transformers, unix
|
|
||||||
}:
|
|
||||||
mkDerivation {
|
|
||||||
pname = "tmp-postgres";
|
|
||||||
version = "1.34.1.0";
|
|
||||||
sha256 = "98514428edaf527cc464cb9a30df89c6168c858e039ab1baf8293471196c3ba2";
|
|
||||||
isLibrary = true;
|
|
||||||
isExecutable = true;
|
|
||||||
libraryHaskellDepends = [
|
|
||||||
ansi-wl-pprint async base base64-bytestring bytestring containers
|
|
||||||
cryptohash-sha1 deepseq directory generic-monoid port-utils
|
|
||||||
postgres-options postgresql-simple process stm temporary
|
|
||||||
transformers unix
|
|
||||||
];
|
|
||||||
executableHaskellDepends = [
|
|
||||||
async base directory postgres-options postgresql-simple process
|
|
||||||
temporary
|
|
||||||
];
|
|
||||||
testHaskellDepends = [
|
|
||||||
async base containers directory generic-monoid hspec mtl network
|
|
||||||
port-utils postgres-options postgresql-simple process temporary
|
|
||||||
unix
|
|
||||||
];
|
|
||||||
benchmarkHaskellDepends = [
|
|
||||||
base criterion deepseq postgres-options postgresql-simple temporary
|
|
||||||
];
|
|
||||||
doCheck = false;
|
|
||||||
homepage = "https://github.com/jfischoff/tmp-postgres#readme";
|
|
||||||
description = "Start and stop a temporary postgres";
|
|
||||||
license = stdenv.lib.licenses.bsd3;
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
import (builtins.fetchTarball {
|
|
||||||
name = "nixos-20.03";
|
|
||||||
url = "https://github.com/nixos/nixpkgs/archive/0d0660fde3bb53a3d013b65e5e141eb11d1efb82.tar.gz";
|
|
||||||
sha256 = "13qpa916qq1kqvfj8q4zkmnfnbh2kpx0nxxg04nblai0smz97820";
|
|
||||||
}) {
|
|
||||||
overlays = import ./overlays.nix;
|
|
||||||
}
|
|
38
nix/sources.json
Normal file
38
nix/sources.json
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"haskell.nix": {
|
||||||
|
"branch": "circuithub",
|
||||||
|
"description": "Alternative Haskell Infrastructure for Nixpkgs",
|
||||||
|
"homepage": "https://input-output-hk.github.io/haskell.nix",
|
||||||
|
"owner": "circuithub",
|
||||||
|
"repo": "haskell.nix",
|
||||||
|
"rev": "2902f9b49484a87afb0e1a33b1d88a2c7b8ca0a0",
|
||||||
|
"sha256": "0a01g5b46z5yaf2mnl415hc4lciwiyqhj22qhgwgwd261w4068iy",
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://github.com/circuithub/haskell.nix/archive/2902f9b49484a87afb0e1a33b1d88a2c7b8ca0a0.tar.gz",
|
||||||
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
|
},
|
||||||
|
"niv": {
|
||||||
|
"branch": "master",
|
||||||
|
"description": "Easy dependency management for Nix projects",
|
||||||
|
"homepage": "https://github.com/nmattia/niv",
|
||||||
|
"owner": "nmattia",
|
||||||
|
"repo": "niv",
|
||||||
|
"rev": "ba57d5a29b4e0f2085917010380ef3ddc3cf380f",
|
||||||
|
"sha256": "1kpsvc53x821cmjg1khvp1nz7906gczq8mp83664cr15h94sh8i4",
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://github.com/nmattia/niv/archive/ba57d5a29b4e0f2085917010380ef3ddc3cf380f.tar.gz",
|
||||||
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"branch": "nixos-20.09",
|
||||||
|
"description": "Nix Packages collection",
|
||||||
|
"homepage": null,
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "6e7f25001fe6874f7ae271891f709bbf50a22c45",
|
||||||
|
"sha256": "1x04j4351pqiqbpkq6g308mxcvb5aqnwv8l2vmlxkgvq5phzky7z",
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://github.com/nixos/nixpkgs/archive/6e7f25001fe6874f7ae271891f709bbf50a22c45.tar.gz",
|
||||||
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
|
}
|
||||||
|
}
|
148
nix/sources.nix
Normal file
148
nix/sources.nix
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
# This file has been generated by Niv.
|
||||||
|
|
||||||
|
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_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";
|
||||||
|
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_local = spec: spec.path;
|
||||||
|
|
||||||
|
fetch_builtin-tarball = name: throw
|
||||||
|
''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`.
|
||||||
|
$ niv modify ${name} -a type=tarball -a builtin=true'';
|
||||||
|
|
||||||
|
fetch_builtin-url = name: throw
|
||||||
|
''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`.
|
||||||
|
$ niv modify ${name} -a type=file -a builtin=true'';
|
||||||
|
|
||||||
|
#
|
||||||
|
# Various helpers
|
||||||
|
#
|
||||||
|
|
||||||
|
# The set of packages used when specs are fetched using non-builtins.
|
||||||
|
mkPkgs = sources:
|
||||||
|
let
|
||||||
|
sourcesNixpkgs =
|
||||||
|
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) {};
|
||||||
|
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
|
||||||
|
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
|
||||||
|
in
|
||||||
|
if builtins.hasAttr "nixpkgs" sources
|
||||||
|
then sourcesNixpkgs
|
||||||
|
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
|
||||||
|
import <nixpkgs> {}
|
||||||
|
else
|
||||||
|
abort
|
||||||
|
''
|
||||||
|
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
|
||||||
|
add a package called "nixpkgs" to your sources.json.
|
||||||
|
'';
|
||||||
|
|
||||||
|
# The actual fetching function.
|
||||||
|
fetch = pkgs: name: spec:
|
||||||
|
|
||||||
|
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 == "tarball" then fetch_tarball pkgs name spec
|
||||||
|
else if spec.type == "git" then fetch_git 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
|
||||||
|
else
|
||||||
|
abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
|
||||||
|
|
||||||
|
# If the environment variable NIV_OVERRIDE_${name} is set, then use
|
||||||
|
# the path directly as opposed to the fetched source.
|
||||||
|
replace = name: drv:
|
||||||
|
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;
|
||||||
|
|
||||||
|
# Ports of functions for older nix versions
|
||||||
|
|
||||||
|
# a Nix version of mapAttrs if the built-in doesn't exist
|
||||||
|
mapAttrs = builtins.mapAttrs or (
|
||||||
|
f: set: with builtins;
|
||||||
|
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
|
||||||
|
);
|
||||||
|
|
||||||
|
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
|
||||||
|
range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1);
|
||||||
|
|
||||||
|
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
|
||||||
|
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
|
||||||
|
|
||||||
|
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
|
||||||
|
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
|
||||||
|
concatStrings = builtins.concatStringsSep "";
|
||||||
|
|
||||||
|
# fetchTarball version that is compatible between all the versions of Nix
|
||||||
|
builtins_fetchTarball = { url, name, sha256 }@attrs:
|
||||||
|
let
|
||||||
|
inherit (builtins) lessThan nixVersion fetchTarball;
|
||||||
|
in
|
||||||
|
if lessThan nixVersion "1.12" then
|
||||||
|
fetchTarball { inherit name url; }
|
||||||
|
else
|
||||||
|
fetchTarball attrs;
|
||||||
|
|
||||||
|
# fetchurl version that is compatible between all the versions of Nix
|
||||||
|
builtins_fetchurl = { url, sha256 }@attrs:
|
||||||
|
let
|
||||||
|
inherit (builtins) lessThan nixVersion fetchurl;
|
||||||
|
in
|
||||||
|
if lessThan nixVersion "1.12" then
|
||||||
|
fetchurl { inherit url; }
|
||||||
|
else
|
||||||
|
fetchurl attrs;
|
||||||
|
|
||||||
|
# Create the final "sources" from the config
|
||||||
|
mkSources = config:
|
||||||
|
mapAttrs (
|
||||||
|
name: spec:
|
||||||
|
if builtins.hasAttr "outPath" spec
|
||||||
|
then abort
|
||||||
|
"The values in sources.json should not have an 'outPath' attribute"
|
||||||
|
else
|
||||||
|
spec // { outPath = replace name (fetch config.pkgs name spec); }
|
||||||
|
) config.sources;
|
||||||
|
|
||||||
|
# The "config" used by the fetchers
|
||||||
|
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
|
||||||
|
}: rec {
|
||||||
|
# The sources, i.e. the attribute set of spec name to spec
|
||||||
|
inherit sources;
|
||||||
|
|
||||||
|
# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
|
||||||
|
inherit pkgs;
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }
|
Loading…
Reference in New Issue
Block a user