From cf5e2d510316ae0e2e78486e28b79b1fa30799fa Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 23 May 2022 21:39:01 +0200 Subject: haskellPackages: Add buildFromCabalSdist (faster, tested) --- pkgs/test/haskell/cabalSdist/default.nix | 28 +++++++++++++++++++++++++ pkgs/test/haskell/cabalSdist/local/CHANGELOG.md | 5 +++++ pkgs/test/haskell/cabalSdist/local/app/Main.hs | 4 ++++ pkgs/test/haskell/cabalSdist/local/local.cabal | 13 ++++++++++++ pkgs/test/haskell/default.nix | 1 + 5 files changed, 51 insertions(+) create mode 100644 pkgs/test/haskell/cabalSdist/default.nix create mode 100644 pkgs/test/haskell/cabalSdist/local/CHANGELOG.md create mode 100644 pkgs/test/haskell/cabalSdist/local/app/Main.hs create mode 100644 pkgs/test/haskell/cabalSdist/local/local.cabal (limited to 'pkgs/test') diff --git a/pkgs/test/haskell/cabalSdist/default.nix b/pkgs/test/haskell/cabalSdist/default.nix new file mode 100644 index 00000000000..2ab815f5d4f --- /dev/null +++ b/pkgs/test/haskell/cabalSdist/default.nix @@ -0,0 +1,28 @@ +{ lib, haskellPackages, runCommand }: + +let + localRaw = haskellPackages.callCabal2nix "local" ./local {}; +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/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 { }; -- cgit 1.4.1 From 392fba113292aa10ba8ea9b68710a73ca17cac0e Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Tue, 24 May 2022 13:23:19 +0200 Subject: pkgs.tests.haskell.cabalSdist: Avoid IFD --- pkgs/test/haskell/cabalSdist/default.nix | 2 +- pkgs/test/haskell/cabalSdist/local/generated.nix | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 pkgs/test/haskell/cabalSdist/local/generated.nix (limited to 'pkgs/test') diff --git a/pkgs/test/haskell/cabalSdist/default.nix b/pkgs/test/haskell/cabalSdist/default.nix index 2ab815f5d4f..1031e51e4f1 100644 --- a/pkgs/test/haskell/cabalSdist/default.nix +++ b/pkgs/test/haskell/cabalSdist/default.nix @@ -1,7 +1,7 @@ { lib, haskellPackages, runCommand }: let - localRaw = haskellPackages.callCabal2nix "local" ./local {}; + localRaw = haskellPackages.callPackage ./local/generated.nix {}; in lib.recurseIntoAttrs rec { 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; +} -- cgit 1.4.1