From 169b24df4179a8ebc96258756e1dfe064da3ef1c Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Sat, 26 Oct 2024 01:35:13 +0200 Subject: [PATCH] haskellPackages.password: use crypton, disable scrypt on non-x86 - crypton is maintained, contrary to cryptonite - since the Hackage scrypt package uses SSE2, we can't build it on non-x86 platforms (non x86_64 even probably). The best option is to disable the Scrypt module. To prevent cabal from pulling in scrypt in spite of that, we need to patch build-depends to respect the flag. --- .../configuration-hackage2nix/main.yaml | 2 -- .../haskell-modules/configuration-nix.nix | 29 +++++++++++++++++++ .../haskell-modules/hackage-packages.nix | 3 -- .../password-3.0.4.0-scrypt-conditional.patch | 21 ++++++++++++++ 4 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 pkgs/development/haskell-modules/patches/password-3.0.4.0-scrypt-conditional.patch diff --git a/pkgs/development/haskell-modules/configuration-hackage2nix/main.yaml b/pkgs/development/haskell-modules/configuration-hackage2nix/main.yaml index 960d784c07df4..c64f66df752c3 100644 --- a/pkgs/development/haskell-modules/configuration-hackage2nix/main.yaml +++ b/pkgs/development/haskell-modules/configuration-hackage2nix/main.yaml @@ -829,8 +829,6 @@ supported-platforms: midi-alsa: [ platforms.linux ] # alsa-core only supported on linux midisurface: [ platforms.linux ] # alsa-core only supported on linux OrderedBits: [ platforms.x86 ] # lacks implementations for non-x86: https://github.com/choener/OrderedBits/blob/401cbbe933b1635aa33e8e9b29a4a570b0a8f044/lib/Data/Bits/Ordered.hs#L316 - password: [ platforms.x86 ] # uses scrypt, which requries x86 - password-instances: [ platforms.x86 ] # uses scrypt, which requries x86 reactivity: [ platforms.windows ] reflex-libtelnet: [ platforms.linux ] # pkgs.libtelnet only supports linux scat: [ platforms.x86 ] # uses scrypt, which requries x86 diff --git a/pkgs/development/haskell-modules/configuration-nix.nix b/pkgs/development/haskell-modules/configuration-nix.nix index df8173ec4f26d..c58cf0af6570f 100644 --- a/pkgs/development/haskell-modules/configuration-nix.nix +++ b/pkgs/development/haskell-modules/configuration-nix.nix @@ -113,6 +113,35 @@ self: super: builtins.intersectAttrs super { '' + drv.preCheck or ""; }) super.agda2lagda; + # - Disable scrypt support since the library used only works on x86 due to SSE2: + # https://github.com/informatikr/scrypt/issues/8 + # - Use crypton as the encryption backend. That override becomes obsolete with + # 3.1.* since cabal2nix picks crypton by default then. + password = + let + scryptSupported = pkgs.stdenv.hostPlatform.isx86; + in + + lib.pipe + (super.password.override ({ + cryptonite = self.crypton; + } // lib.optionalAttrs (!scryptSupported) { + scrypt = null; + })) + ([ + (enableCabalFlag "crypton") + (disableCabalFlag "cryptonite") + # https://github.com/cdepillabout/password/pull/84 + (appendPatch ./patches/password-3.0.4.0-scrypt-conditional.patch) + (overrideCabal (drv: { + # patch doesn't apply otherwise because of revisions + prePatch = drv.prePatch or "" + '' + ${pkgs.buildPackages.dos2unix}/bin/dos2unix *.cabal + ''; + })) + ] ++ lib.optionals (!scryptSupported) [ + (disableCabalFlag "scrypt") + ]); audacity = enableCabalFlag "buildExamples" (overrideCabal (drv: { executableHaskellDepends = [self.optparse-applicative self.soxlib]; diff --git a/pkgs/development/haskell-modules/hackage-packages.nix b/pkgs/development/haskell-modules/hackage-packages.nix index e424c08e3a2ec..1ec297a9ad39e 100644 --- a/pkgs/development/haskell-modules/hackage-packages.nix +++ b/pkgs/development/haskell-modules/hackage-packages.nix @@ -234439,7 +234439,6 @@ self: { ]; description = "Hashing and checking of passwords"; license = lib.licenses.bsd3; - platforms = lib.platforms.x86; maintainers = [ lib.maintainers.cdepillabout ]; }) {}; @@ -234465,7 +234464,6 @@ self: { ]; description = "Hashing and checking of passwords"; license = lib.licenses.bsd3; - platforms = lib.platforms.x86; hydraPlatforms = lib.platforms.none; maintainers = [ lib.maintainers.cdepillabout ]; }) {}; @@ -234491,7 +234489,6 @@ self: { ]; description = "typeclass instances for password package"; license = lib.licenses.bsd3; - platforms = lib.platforms.x86; maintainers = [ lib.maintainers.cdepillabout ]; }) {}; diff --git a/pkgs/development/haskell-modules/patches/password-3.0.4.0-scrypt-conditional.patch b/pkgs/development/haskell-modules/patches/password-3.0.4.0-scrypt-conditional.patch new file mode 100644 index 0000000000000..1e9cc4c65dedb --- /dev/null +++ b/pkgs/development/haskell-modules/patches/password-3.0.4.0-scrypt-conditional.patch @@ -0,0 +1,21 @@ +diff --git a/password/password.cabal b/password/password.cabal +index 506457e..8fa978b 100644 +--- a/password.cabal ++++ b/password.cabal +@@ -186,6 +186,8 @@ test-suite password-tasty + other-modules: + Scrypt + Data.Password.Scrypt ++ build-depends: ++ scrypt + ghc-options: + -threaded -O2 -rtsopts -with-rtsopts=-N + build-depends: +@@ -195,7 +197,6 @@ test-suite password-tasty + , bytestring + , memory + , quickcheck-instances +- , scrypt + , tasty + , tasty-hunit + , tasty-quickcheck