Skip to content

Commit

Permalink
Separate cabal2nix generated file from overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
mzabani committed Jan 11, 2025
1 parent 3b8221b commit 6a49788
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 56 deletions.
111 changes: 58 additions & 53 deletions pkgs/by-name/co/codd/generated.nix
Original file line number Diff line number Diff line change
@@ -1,37 +1,50 @@
# This was generated with cabal2nix but contains important modifications like jailbreaking haxl
# and disabling tests selectively, among a few other minor things.
# Don't just blindly replace it with something generated by cabal2nix.
{
lib,
haskell,
mkDerivation,
fetchFromGitHub,
haskellPackages,
aeson,
aeson-pretty,
ansi-terminal,
attoparsec,
base,
bytestring,
clock,
containers,
criterion-measurement,
deepseq,
dlist,
filepath,
formatting,
hashable,
haxl,
hspec,
hspec-core,
hspec-expectations,
lib,
mtl,
network-uri,
optparse-applicative,
postgresql-libpq,
postgresql-simple,
QuickCheck,
random,
resourcet,
statistics,
streaming,
text,
time,
transformers,
typed-process,
unliftio,
unliftio-core,
unordered-containers,
vector,
}:

let

# Haxl has relatively tight version requirements and is thus marked as broken.
haxlJailbroken = haskell.lib.markUnbroken (haskell.lib.doJailbreak haskellPackages.haxl);

in
mkDerivation rec {
mkDerivation {
pname = "codd";

version = "0.1.4";

src = fetchFromGitHub {
owner = "mzabani";
repo = "codd";
rev = "refs/tags/v${version}";
hash = "sha256-hFAo0DLhxULeib3OMjfTYBQIBJ5+apWlMDGsK5gUwho=";
};

isLibrary = false;

src = ./.;
isLibrary = true;
isExecutable = true;

libraryHaskellDepends = with haskellPackages; [
libraryHaskellDepends = [
aeson
aeson-pretty
ansi-terminal
Expand All @@ -44,7 +57,7 @@ mkDerivation rec {
filepath
formatting
hashable
haxlJailbroken
haxl
mtl
network-uri
postgresql-libpq
Expand All @@ -59,16 +72,14 @@ mkDerivation rec {
unordered-containers
vector
];

executableHaskellDepends = with haskellPackages; [
executableHaskellDepends = [
base
optparse-applicative
postgresql-simple
text
time
];

testHaskellDepends = with haskellPackages; [
testHaskellDepends = [
aeson
attoparsec
base
Expand All @@ -88,26 +99,20 @@ mkDerivation rec {
typed-process
unliftio
];
testToolDepends = [ haskellPackages.hspec-discover ];
# We only run codd's tests that don't require postgresql nor strace. We need to support unix sockets in codd's test suite
# before enabling postgresql's tests, and SystemResourcesSpecs might fail on macOS because of the need for strace and parsing
# libc calls. Not that we really gain much from running SystemResourcesSpecs here anyway.
testFlags = [
"--skip"
"/DbDependentSpecs/"
"--skip"
"/SystemResourcesSpecs/"
benchmarkHaskellDepends = [
aeson
base
criterion-measurement
deepseq
hspec
hspec-core
hspec-expectations
statistics
streaming
text
vector
];

description = "CLI tool that applies postgres SQL migrations atomically with schema equality checks";

mainProgram = "codd";

homepage = "https://github.com/mzabani/codd";

changelog = "https://github.com/mzabani/codd/releases/tag/v${version}";

homepage = "https://github.com/mzabani/codd#readme";
license = lib.licenses.bsd3;

maintainers = with lib.maintainers; [ mzabani ];
mainProgram = "codd";
}
53 changes: 50 additions & 3 deletions pkgs/by-name/co/codd/package.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,53 @@
{ haskell, haskellPackages }:
{
lib,
fetchFromGitHub,
haskell,
haskellPackages,
}:

##############
# To upgrade codd you typically only need to change the version, revision and SHA hash
# in this very file.
# If codd's dependencies change, however, clone codd at https://github.com/mzabani/codd,
# checkout the desired tag and run `cabal2nix .` to produce and replace the generated.nix
# file. Finally, do change the version in this file.
##############

let
generated = haskellPackages.callPackage ./generated.nix { };
# Haxl has relatively tight version requirements and is thus often marked as broken.
haxlJailbroken = haskell.lib.markUnbroken (haskell.lib.doJailbreak haskellPackages.haxl);

generated = haskellPackages.callPackage ./generated.nix { haxl = haxlJailbroken; };

derivationWithVersion = haskell.lib.compose.overrideCabal (rec {
version = "0.1.4";
src = fetchFromGitHub {
owner = "mzabani";
repo = "codd";
rev = "refs/tags/v${version}";
hash = "sha256-hFAo0DLhxULeib3OMjfTYBQIBJ5+apWlMDGsK5gUwho=";
};

# We only run codd's tests that don't require postgresql nor strace. We need to support unix sockets in codd's test suite
# before enabling postgresql's tests, and SystemResourcesSpecs might fail on macOS because of the need for strace and parsing
# libc calls. Not that we really gain much from running SystemResourcesSpecs here anyway.
testFlags = [
"--skip"
"/DbDependentSpecs/"
"--skip"
"/SystemResourcesSpecs/"
];

isLibrary = false;
testToolDepends = [ haskellPackages.hspec-discover ];

description = "CLI tool that applies postgres SQL migrations atomically with schema equality checks";

homepage = "https://github.com/mzabani/codd";

changelog = "https://github.com/mzabani/codd/releases/tag/v${version}";

maintainers = with lib.maintainers; [ mzabani ];
}) generated;
in
haskell.lib.compose.justStaticExecutables generated
haskell.lib.compose.justStaticExecutables derivationWithVersion

0 comments on commit 6a49788

Please sign in to comment.