summary refs log tree commit diff
path: root/pkgs/test
diff options
context:
space:
mode:
authorRobert Hensing <roberth@users.noreply.github.com>2022-06-28 10:06:27 +0200
committerGitHub <noreply@github.com>2022-06-28 10:06:27 +0200
commitd64780ea0e22b5f61cd6012a456869c702a72f20 (patch)
tree4b47ae60684a279ee949f84a7d76c640dc54f376 /pkgs/test
parentfc6cea3c6cff75ae7152758995986d7279bc175a (diff)
parent392fba113292aa10ba8ea9b68710a73ca17cac0e (diff)
downloadnixpkgs-d64780ea0e22b5f61cd6012a456869c702a72f20.tar
nixpkgs-d64780ea0e22b5f61cd6012a456869c702a72f20.tar.gz
nixpkgs-d64780ea0e22b5f61cd6012a456869c702a72f20.tar.bz2
nixpkgs-d64780ea0e22b5f61cd6012a456869c702a72f20.tar.lz
nixpkgs-d64780ea0e22b5f61cd6012a456869c702a72f20.tar.xz
nixpkgs-d64780ea0e22b5f61cd6012a456869c702a72f20.tar.zst
nixpkgs-d64780ea0e22b5f61cd6012a456869c702a72f20.zip
Merge pull request #174176 from hercules-ci/buildFromCabalSdist
haskellPackages: Add buildFromCabalSdist (faster, tested)
Diffstat (limited to 'pkgs/test')
-rw-r--r--pkgs/test/haskell/cabalSdist/default.nix28
-rw-r--r--pkgs/test/haskell/cabalSdist/local/CHANGELOG.md5
-rw-r--r--pkgs/test/haskell/cabalSdist/local/app/Main.hs4
-rw-r--r--pkgs/test/haskell/cabalSdist/local/generated.nix12
-rw-r--r--pkgs/test/haskell/cabalSdist/local/local.cabal13
-rw-r--r--pkgs/test/haskell/default.nix1
6 files changed, 63 insertions, 0 deletions
diff --git a/pkgs/test/haskell/cabalSdist/default.nix b/pkgs/test/haskell/cabalSdist/default.nix
new file mode 100644
index 00000000000..1031e51e4f1
--- /dev/null
+++ b/pkgs/test/haskell/cabalSdist/default.nix
@@ -0,0 +1,28 @@
+{ lib, haskellPackages, runCommand }:
+
+let
+  localRaw = haskellPackages.callPackage ./local/generated.nix {};
+in
+lib.recurseIntoAttrs rec {
+
+  helloFromCabalSdist = haskellPackages.buildFromCabalSdist haskellPackages.hello;
+
+  # A more complicated example with a cabal hook.
+  hercules-ci-cnix-store = haskellPackages.buildFromCabalSdist haskellPackages.hercules-ci-cnix-store;
+
+  localFromCabalSdist = haskellPackages.buildFromCabalSdist localRaw;
+
+  assumptionLocalHasDirectReference = runCommand "localHasDirectReference" {
+    drvPath = builtins.unsafeDiscardOutputDependency localRaw.drvPath;
+  } ''
+    grep ${./local} $drvPath >/dev/null
+    touch $out
+  '';
+
+  localHasNoDirectReference = runCommand "localHasNoDirectReference" {
+    drvPath = builtins.unsafeDiscardOutputDependency localFromCabalSdist.drvPath;
+  } ''
+    grep -v ${./local} $drvPath >/dev/null
+    touch $out
+  '';
+}
diff --git a/pkgs/test/haskell/cabalSdist/local/CHANGELOG.md b/pkgs/test/haskell/cabalSdist/local/CHANGELOG.md
new file mode 100644
index 00000000000..53cc3ae43d8
--- /dev/null
+++ b/pkgs/test/haskell/cabalSdist/local/CHANGELOG.md
@@ -0,0 +1,5 @@
+# Revision history for local
+
+## 0.1.0.0 -- YYYY-mm-dd
+
+* First version. Released on an unsuspecting world.
diff --git a/pkgs/test/haskell/cabalSdist/local/app/Main.hs b/pkgs/test/haskell/cabalSdist/local/app/Main.hs
new file mode 100644
index 00000000000..65ae4a05d5d
--- /dev/null
+++ b/pkgs/test/haskell/cabalSdist/local/app/Main.hs
@@ -0,0 +1,4 @@
+module Main where
+
+main :: IO ()
+main = putStrLn "Hello, Haskell!"
diff --git a/pkgs/test/haskell/cabalSdist/local/generated.nix b/pkgs/test/haskell/cabalSdist/local/generated.nix
new file mode 100644
index 00000000000..bfa299962bc
--- /dev/null
+++ b/pkgs/test/haskell/cabalSdist/local/generated.nix
@@ -0,0 +1,12 @@
+# nix run ../../../../..#cabal2nix -- ./.
+{ mkDerivation, base, lib }:
+mkDerivation {
+  pname = "local";
+  version = "0.1.0.0";
+  src = ./.;
+  isLibrary = false;
+  isExecutable = true;
+  executableHaskellDepends = [ base ];
+  description = "Nixpkgs test case";
+  license = lib.licenses.mit;
+}
diff --git a/pkgs/test/haskell/cabalSdist/local/local.cabal b/pkgs/test/haskell/cabalSdist/local/local.cabal
new file mode 100644
index 00000000000..1670aa3af63
--- /dev/null
+++ b/pkgs/test/haskell/cabalSdist/local/local.cabal
@@ -0,0 +1,13 @@
+cabal-version:      2.4
+name:               local
+version:            0.1.0.0
+
+synopsis: Nixpkgs test case
+license:  MIT
+extra-source-files: CHANGELOG.md
+
+executable local
+    main-is:          Main.hs
+    build-depends:    base
+    hs-source-dirs:   app
+    default-language: Haskell2010
diff --git a/pkgs/test/haskell/default.nix b/pkgs/test/haskell/default.nix
index 03e4f346155..337d2811c65 100644
--- a/pkgs/test/haskell/default.nix
+++ b/pkgs/test/haskell/default.nix
@@ -2,6 +2,7 @@
 
 lib.recurseIntoAttrs {
   shellFor = callPackage ./shellFor { };
+  cabalSdist = callPackage ./cabalSdist { };
   documentationTarball = callPackage ./documentationTarball { };
   setBuildTarget = callPackage ./setBuildTarget { };
   writers = callPackage ./writers { };