diff --git a/build.nix b/build.nix index 41247f9ca5..3e9c679cc1 100644 --- a/build.nix +++ b/build.nix @@ -33,7 +33,7 @@ in rec { # are not pure). maintainer-scripts = pkgs.dontRecurseIntoAttrs { update-hackage = import ./scripts/update-hackage.nix { - inherit (pkgs) stdenv writeScript coreutils glibc git + inherit (pkgs) stdenv lib writeScript coreutils glibc git openssh nix-prefetch-git gawk bash curl findutils; # Update scripts use the internal nix-tools and cabal-install (compiled with a fixed GHC version) nix-tools = haskell.internal-nix-tools; @@ -41,7 +41,7 @@ in rec { inherit (haskell) update-index-state-hashes; }; update-stackage = haskell.callPackage ./scripts/update-stackage.nix { - inherit (pkgs) stdenv writeScript coreutils glibc git + inherit (pkgs) stdenv lib writeScript coreutils glibc git openssh nix-prefetch-git gawk bash curl findutils; # Update scripts use the internal nix-tools and cabal-install (compiled with a fixed GHC version) nix-tools = haskell.internal-nix-tools; diff --git a/builder/comp-builder.nix b/builder/comp-builder.nix index 70087903e2..31a3c57c02 100644 --- a/builder/comp-builder.nix +++ b/builder/comp-builder.nix @@ -296,7 +296,7 @@ let homepage = package.homepage or ""; description = package.synopsis or ""; license = haskellLib.cabalToNixpkgsLicense package.license; - platforms = if platforms == null then stdenv.lib.platforms.all else platforms; + platforms = if platforms == null then lib.platforms.all else platforms; }; propagatedBuildInputs = diff --git a/builder/setup-builder.nix b/builder/setup-builder.nix index a4429b1191..f2298a1684 100644 --- a/builder/setup-builder.nix +++ b/builder/setup-builder.nix @@ -56,7 +56,7 @@ let homepage = package.homepage or ""; description = package.synopsis or ""; license = haskellLib.cabalToNixpkgsLicense package.license; - platforms = if component.platforms == null then stdenv.lib.platforms.all else component.platforms; + platforms = if component.platforms == null then lib.platforms.all else component.platforms; }; phases = ["unpackPhase" "patchPhase" "buildPhase" "installPhase"]; diff --git a/compiler/bootstrap/cabal-install.nix b/compiler/bootstrap/cabal-install.nix index 57e0f991dd..0791b5d035 100644 --- a/compiler/bootstrap/cabal-install.nix +++ b/compiler/bootstrap/cabal-install.nix @@ -1,4 +1,4 @@ -{ fetchurl, hackage, stdenv, ghc, zlib, src, version }: +{ fetchurl, hackage, stdenv, lib, ghc, zlib, src, version }: let dependencies = [ { name = "deepseq"; version = "1.4.3.0"; } { name = "binary"; version = "0.8.5.1"; } @@ -42,7 +42,7 @@ in stdenv.mkDerivation ({ }; meta = { - platforms = stdenv.lib.platforms.all; + platforms = lib.platforms.all; }; nativeBuildInputs = [ ghc zlib ]; diff --git a/compiler/ghc/configured-src.nix b/compiler/ghc/configured-src.nix index b30ae246d7..8995b8ac6f 100644 --- a/compiler/ghc/configured-src.nix +++ b/compiler/ghc/configured-src.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchurl +{ stdenv, lib, fetchurl , ghc-version, ghc-version-date, ghc-patches, src-spec , targetPrefix , targetPlatform, hostPlatform @@ -25,7 +25,7 @@ stdenv.mkDerivation (rec { nativeBuildInputs = [ perl autoconf automake m4 python3 sphinx ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour - ] ++ stdenv.lib.optional (patches != []) autoreconfHook; + ] ++ lib.optional (patches != []) autoreconfHook; # For building runtime libs depsBuildTarget = toolsForTarget; @@ -33,10 +33,10 @@ stdenv.mkDerivation (rec { buildInputs = [ perl bash ] ++ (libDeps hostPlatform); propagatedBuildInputs = [ targetPackages.stdenv.cc ] - ++ stdenv.lib.optional useLLVM llvmPackages.llvm; + ++ lib.optional useLLVM llvmPackages.llvm; - depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform); - depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform); + depsTargetTarget = map lib.getDev (libDeps targetPlatform); + depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform); postPatch = "patchShebangs ."; @@ -54,7 +54,7 @@ stdenv.mkDerivation (rec { export CC="${targetCC}/bin/${targetCC.targetPrefix}cc" export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx" # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177 - export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString targetPlatform.isAarch32 ".gold"}" + export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString targetPlatform.isAarch32 ".gold"}" export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as" export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar" export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm" @@ -64,13 +64,13 @@ stdenv.mkDerivation (rec { echo -n "${buildMK}" > mk/build.mk sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure - '' + stdenv.lib.optionalString (!stdenv.isDarwin) '' + '' + lib.optionalString (!stdenv.isDarwin) '' export NIX_LDFLAGS+=" -rpath $out/lib/${targetPrefix}ghc-${version}" - '' + stdenv.lib.optionalString stdenv.isDarwin '' + '' + lib.optionalString stdenv.isDarwin '' export NIX_LDFLAGS+=" -no_dtrace_dof" - '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt '' + '' + lib.optionalString targetPlatform.useAndroidPrebuilt '' sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets - '' + stdenv.lib.optionalString targetPlatform.isMusl '' + '' + lib.optionalString targetPlatform.isMusl '' echo "patching llvm-targets for musl targets..." echo "Cloning these existing '*-linux-gnu*' targets:" grep linux-gnu llvm-targets | sed 's/^/ /' @@ -86,10 +86,10 @@ stdenv.mkDerivation (rec { --replace '*-android*|*-gnueabi*)' \ '*-android*|*-gnueabi*|*-musleabi*)' done - '' + stdenv.lib.optionalString (src-spec.version != ghc-version) '' + '' + lib.optionalString (src-spec.version != ghc-version) '' substituteInPlace configure --replace 'RELEASE=YES' 'RELEASE=NO' echo '${ghc-version}' > VERSION - '' + stdenv.lib.optionalString (ghc-version-date != null) '' + '' + lib.optionalString (ghc-version-date != null) '' substituteInPlace configure --replace 'RELEASE=YES' 'RELEASE=NO' echo '${ghc-version-date}' > VERSION_DATE ''; @@ -99,16 +99,16 @@ stdenv.mkDerivation (rec { configureFlags = [ "--datadir=$doc/share/doc/ghc" "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" - ] ++ stdenv.lib.optionals (targetLibffi != null) ["--with-system-libffi" "--with-ffi-includes=${targetLibffi.dev}/include" "--with-ffi-libraries=${targetLibffi.out}/lib" - ] ++ stdenv.lib.optional (!enableIntegerSimple) [ + ] ++ lib.optionals (targetLibffi != null) ["--with-system-libffi" "--with-ffi-includes=${targetLibffi.dev}/include" "--with-ffi-libraries=${targetLibffi.out}/lib" + ] ++ lib.optional (!enableIntegerSimple) [ "--with-gmp-includes=${targetGmp.dev}/include" "--with-gmp-libraries=${targetGmp.out}/lib" - ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [ + ] ++ lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [ "--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib" - ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [ + ] ++ lib.optionals (targetPlatform != hostPlatform) [ "--enable-bootstrap-with-devel-snapshot" - ] ++ stdenv.lib.optionals (disableLargeAddressSpace) [ + ] ++ lib.optionals (disableLargeAddressSpace) [ "--disable-large-address-space" - ] ++ stdenv.lib.optionals (targetPlatform.isAarch32) [ + ] ++ lib.optionals (targetPlatform.isAarch32) [ "CFLAGS=-fuse-ld=gold" "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold" "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" @@ -116,7 +116,7 @@ stdenv.mkDerivation (rec { outputs = [ "out" ]; phases = [ "unpackPhase" "patchPhase" ] - ++ stdenv.lib.optional (ghc-patches != []) "autoreconfPhase" + ++ lib.optional (ghc-patches != []) "autoreconfPhase" ++ [ "configurePhase" "installPhase" ]; installPhase = "cp -r . $out"; }) diff --git a/compiler/ghc/default.nix b/compiler/ghc/default.nix index 4aa53a0a3c..f8e0d55245 100644 --- a/compiler/ghc/default.nix +++ b/compiler/ghc/default.nix @@ -3,7 +3,7 @@ # haskell.nix ships its own version of the ghc expression as it needs more # control over the expression to isolate it against varying and # allow us to customize it to the way haskell.nix works. -{ stdenv, haskell-nix, targetPackages +{ stdenv, lib, haskell-nix, targetPackages # build-tools , bootPkgs @@ -26,7 +26,7 @@ , # If enabled, GHC will be built with the GPL-free but slower integer-simple # library instead of the faster but GPLed integer-gmp library. - enableIntegerSimple ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp + enableIntegerSimple ? !(lib.any (lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp , # If enabled, use -fPIC when compiling static libs. enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform && !stdenv.targetPlatform.isAarch32 @@ -42,7 +42,7 @@ , # What flavour to build. An empty string indicates no # specific flavour and falls back to ghc default values. - ghcFlavour ? stdenv.lib.optionalString haskell-nix.haskellLib.isCrossTarget ( + ghcFlavour ? lib.optionalString haskell-nix.haskellLib.isCrossTarget ( if useLLVM then "perf-cross" else "perf-cross-ncg" @@ -82,7 +82,7 @@ let targetGmp = targetPackages.gmp or gmp; # TODO(@Ericson2314) Make unconditional - targetPrefix = stdenv.lib.optionalString + targetPrefix = lib.optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-"; @@ -93,52 +93,52 @@ let endif DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"} - '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' + '' + lib.optionalString (targetPlatform != hostPlatform) '' CrossCompilePrefix = ${targetPrefix} - '' + stdenv.lib.optionalString isCrossTarget '' + '' + lib.optionalString isCrossTarget '' Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"} HADDOCK_DOCS = NO BUILD_SPHINX_HTML = NO BUILD_SPHINX_PDF = NO - '' + stdenv.lib.optionalString enableRelocatedStaticLibs '' + '' + lib.optionalString enableRelocatedStaticLibs '' GhcLibHcOpts += -fPIC GhcRtsHcOpts += -fPIC - '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt '' + '' + lib.optionalString targetPlatform.useAndroidPrebuilt '' EXTRA_CC_OPTS += -std=gnu99 - '' + stdenv.lib.optionalString (!enableTerminfo) '' + '' + lib.optionalString (!enableTerminfo) '' WITH_TERMINFO=NO '' # musl doesn't have a system-linker. Only on x86, and on x86 we need it, as # our elf linker for x86_64 is broken. - + stdenv.lib.optionalString (targetPlatform.isMusl && !targetPlatform.isx86) '' + + lib.optionalString (targetPlatform.isMusl && !targetPlatform.isx86) '' compiler_CONFIGURE_OPTS += --flags=-dynamic-system-linker '' # While split sections are now enabled by default in ghc 8.8 for windows, # the seem to lead to `too many sections` errors when building base for # profiling. - + stdenv.lib.optionalString targetPlatform.isWindows '' + + lib.optionalString targetPlatform.isWindows '' SplitSections = NO - '' + stdenv.lib.optionalString (!enableLibraryProfiling) '' + '' + lib.optionalString (!enableLibraryProfiling) '' BUILD_PROF_LIBS = NO ''; # Splicer will pull out correct variations - libDeps = platform: stdenv.lib.optional enableTerminfo [ ncurses ] + libDeps = platform: lib.optional enableTerminfo [ ncurses ] ++ [targetLibffi] - ++ stdenv.lib.optional (!enableIntegerSimple) gmp - ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv - ++ stdenv.lib.optional (platform.isLinux && !platform.isAarch32) numactl; + ++ lib.optional (!enableIntegerSimple) gmp + ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv + ++ lib.optional (platform.isLinux && !platform.isAarch32) numactl; toolsForTarget = if hostPlatform == buildPlatform then - [ targetPackages.stdenv.cc ] ++ stdenv.lib.optional useLLVM llvmPackages.llvm + [ targetPackages.stdenv.cc ] ++ lib.optional useLLVM llvmPackages.llvm else assert targetPlatform == hostPlatform; # build != host == target - [ stdenv.cc ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm; + [ stdenv.cc ] ++ lib.optional useLLVM buildLlvmPackages.llvm; targetCC = builtins.head toolsForTarget; configured-src = import ./configured-src.nix { - inherit stdenv fetchurl + inherit stdenv lib fetchurl ghc-version ghc-version-date ghc-patches src-spec targetPrefix targetPlatform hostPlatform @@ -212,7 +212,7 @@ stdenv.mkDerivation (rec { nativeBuildInputs = [ perl autoconf automake m4 python3 sphinx ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour - ] ++ stdenv.lib.optional (patches != []) autoreconfHook; + ] ++ lib.optional (patches != []) autoreconfHook; # For building runtime libs depsBuildTarget = toolsForTarget; @@ -220,14 +220,14 @@ stdenv.mkDerivation (rec { buildInputs = [ perl bash ] ++ (libDeps hostPlatform); propagatedBuildInputs = [ targetPackages.stdenv.cc ] - ++ stdenv.lib.optional useLLVM llvmPackages.llvm; + ++ lib.optional useLLVM llvmPackages.llvm; - depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform); - depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform); + depsTargetTarget = map lib.getDev (libDeps targetPlatform); + depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform); # required, because otherwise all symbols from HSffi.o are stripped, and # that in turn causes GHCi to abort - stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols"; + stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols"; # See #63511 - the only unstripped file is the debug rts which isn't meant to # be stripped. @@ -236,8 +236,8 @@ stdenv.mkDerivation (rec { checkTarget = "test"; hardeningDisable = [ "format" ] - ++ stdenv.lib.optional stdenv.targetPlatform.isAarch32 "pic" - ++ stdenv.lib.optional stdenv.targetPlatform.isMusl "pie"; + ++ lib.optional stdenv.targetPlatform.isAarch32 "pic" + ++ lib.optional stdenv.targetPlatform.isMusl "pie"; postInstall = '' # Install the bash completion file. @@ -250,7 +250,7 @@ stdenv.mkDerivation (rec { # The ghcprog fixup is for musl (where runhaskell script just needs to point to the correct # ghc program to work). sed -i \ - -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' \ + -e '2i export PATH="$PATH:${lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' \ -e 's/ghcprog="ghc-/ghcprog="${targetPrefix}ghc-/' \ $i done @@ -324,7 +324,7 @@ stdenv.mkDerivation (rec { inherit (ghc.meta) license platforms; }; -} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt { +} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt { dontStrip = true; dontPatchELF = true; noAuditTmpdir = true; diff --git a/compiler/old-ghc-nix/default.nix b/compiler/old-ghc-nix/default.nix deleted file mode 100644 index 7d8a396550..0000000000 --- a/compiler/old-ghc-nix/default.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ pkgs ? import {} }: -let - fetch = jsonFile: - with builtins; - let spec = fromJSON (readFile jsonFile); - in pkgs.fetchgit { - name = "old-ghc-nix"; - inherit (spec) sha256 url rev; - }; -in import (fetch ./old-ghc-nix.json) { inherit pkgs; } diff --git a/compiler/old-ghc-nix/old-ghc-nix.json b/compiler/old-ghc-nix/old-ghc-nix.json deleted file mode 100644 index ac31221f58..0000000000 --- a/compiler/old-ghc-nix/old-ghc-nix.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "url": "https://github.com/angerman/old-ghc-nix", - "rev": "2a41a09127f6dc7a6384823d1acd51ba257f95bd", - "date": "2020-06-03T12:50:09+08:00", - "sha256": "1cp6aksb6ldgjb5zyqikyjrjij79n9z7wd86migph0wp19vmszkf", - "fetchSubmodules": false -} diff --git a/docs/tutorials/cross-compilation.md b/docs/tutorials/cross-compilation.md index b26cdaccd5..51063e6adf 100644 --- a/docs/tutorials/cross-compilation.md +++ b/docs/tutorials/cross-compilation.md @@ -90,7 +90,7 @@ executables you must add package overrides to: ```nix { packages.bench.components.exes.bench.configureFlags = - stdenv.lib.optionals stdenv.hostPlatform.isMusl [ + lib.optionals stdenv.hostPlatform.isMusl [ "--disable-executable-dynamic" "--disable-shared" "--ghc-option=-optl=-pthread" diff --git a/nix/sources.json b/nix/sources.json index 365f2698d3..5714b92985 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -119,6 +119,7 @@ }, "nixpkgs-unstable": { "branch": "nixpkgs-unstable", + "builtin": false, "description": "Nix Packages collection", "homepage": "", "owner": "NixOS", @@ -128,5 +129,18 @@ "type": "tarball", "url": "https://github.com/NixOS/nixpkgs/archive/410bbd828cdc6156aecd5bc91772ad3a6b1099c7.tar.gz", "url_template": "https://github.com///archive/.tar.gz" + }, + "old-ghc-nix": { + "branch": "master", + "builtin": false, + "description": "Old and New GHC", + "homepage": null, + "owner": "angerman", + "repo": "old-ghc-nix", + "rev": "131ce9ae27d7b7afdd1d3ce8c3a74483e60b91bb", + "sha256": "0n62qr7hrqmy6h80736ji47ln759sk845g43f9cprpmcs9m4wl9i", + "type": "tarball", + "url": "https://github.com/angerman/old-ghc-nix/archive/131ce9ae27d7b7afdd1d3ce8c3a74483e60b91bb.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" } } diff --git a/nix/sources.nix b/nix/sources.nix index c59e1a1618..1938409ddd 100644 --- a/nix/sources.nix +++ b/nix/sources.nix @@ -6,52 +6,63 @@ let # The fetchers. fetch_ fetches specs of 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: spec: - if spec.builtin or true then - builtins_fetchTarball { inherit (spec) url sha256; } - else - pkgs.fetchzip { inherit (spec) url sha256; }; + fetch_file = pkgs: name: spec: + let + name' = sanitizeName name + "-src"; + in + if spec.builtin or true then + builtins_fetchurl { inherit (spec) url sha256; name = name'; } + else + pkgs.fetchurl { inherit (spec) url sha256; name = name'; }; - fetch_git = pkgs: spec: - pkgs.fetchgit { url = spec.repo; inherit (spec) rev deepClone sha256; }; + fetch_tarball = pkgs: name: spec: + let + name' = sanitizeName 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_builtin-tarball = spec: - builtins.trace - '' - WARNING: - The niv type "builtin-tarball" will soon be deprecated. You should - instead use `builtin = true`. + fetch_git = name: spec: + let + ref = + if spec ? ref then spec.ref else + if spec ? branch then "refs/heads/${spec.branch}" else + if spec ? tag then "refs/tags/${spec.tag}" else + abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!"; + in + builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; }; - $ niv modify -a type=tarball -a builtin=true - '' - builtins_fetchTarball { inherit (spec) url sha256; }; + fetch_local = spec: spec.path; - fetch_builtin-url = spec: - builtins.trace - '' - WARNING: - The niv type "builtin-url" will soon be deprecated. You should - instead use `builtin = true`. + 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''; - $ niv modify -a type=file -a builtin=true - '' - (builtins_fetchurl { inherit (spec) url sha256; }); + 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 # + # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695 + sanitizeName = name: + ( + concatMapStrings (s: if builtins.isList s then "-" else s) + ( + builtins.split "[^[:alnum:]+._?=-]+" + ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name) + ) + ); + # The set of packages used when specs are fetched using non-builtins. - mkPkgs = sources: + mkPkgs = sources: system: let sourcesNixpkgs = - import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) {}; + import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; }; hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; hasThisAsNixpkgsPath = == ./.; in @@ -71,14 +82,27 @@ let 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 spec - else if spec.type == "git" then fetch_git pkgs spec - else if spec.type == "builtin-tarball" then fetch_builtin-tarball spec - else if spec.type == "builtin-url" then fetch_builtin-url spec + else if spec.type == "file" then fetch_file pkgs name spec + else if spec.type == "tarball" then fetch_tarball pkgs name spec + else if spec.type == "git" then fetch_git name 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 + # this turns the string into an actual Nix path (for both absolute and + # relative paths) + if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}"; + # Ports of functions for older nix versions # a Nix version of mapAttrs if the built-in doesn't exist @@ -87,23 +111,37 @@ let 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)); + concatMapStrings = f: list: concatStrings (map f list); + concatStrings = builtins.concatStringsSep ""; + + # https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331 + optionalAttrs = cond: as: if cond then as else {}; + # fetchTarball version that is compatible between all the versions of Nix - builtins_fetchTarball = { url, sha256 }@attrs: + builtins_fetchTarball = { url, name ? null, sha256 }@attrs: let inherit (builtins) lessThan nixVersion fetchTarball; in if lessThan nixVersion "1.12" then - fetchTarball { inherit url; } + fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) else fetchTarball attrs; # fetchurl version that is compatible between all the versions of Nix - builtins_fetchurl = { url, sha256 }@attrs: + builtins_fetchurl = { url, name ? null, sha256 }@attrs: let inherit (builtins) lessThan nixVersion fetchurl; in if lessThan nixVersion "1.12" then - fetchurl { inherit url; } + fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) else fetchurl attrs; @@ -115,14 +153,15 @@ let then abort "The values in sources.json should not have an 'outPath' attribute" else - spec // { outPath = fetch config.pkgs name spec; } + spec // { outPath = replace name (fetch config.pkgs name spec); } ) config.sources; # The "config" used by the fetchers mkConfig = - { sourcesFile ? ./sources.json - , sources ? builtins.fromJSON (builtins.readFile sourcesFile) - , pkgs ? mkPkgs sources + { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null + , sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile) + , system ? builtins.currentSystem + , pkgs ? mkPkgs sources system }: rec { # The sources, i.e. the attribute set of spec name to spec inherit sources; @@ -130,5 +169,6 @@ let # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers inherit pkgs; }; + in mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); } diff --git a/overlays/armv6l-linux.nix b/overlays/armv6l-linux.nix index 80e4ad8639..324961f209 100644 --- a/overlays/armv6l-linux.nix +++ b/overlays/armv6l-linux.nix @@ -34,16 +34,16 @@ final: prev: in { packages = { # clock 0.7.2 needs to be patched to support cross compilation. - clock.patches = pkgs.stdenv.lib.optionals pkgs.stdenv.hostPlatform.isAarch32 [ ({ version, revision }: (if version == "0.7.2" then ./patches/clock-0.7.2.patch else null)) ]; + clock.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isAarch32 [ ({ version, revision }: (if version == "0.7.2" then ./patches/clock-0.7.2.patch else null)) ]; # nix calls this package crypto - # cryptonite-openssl.patches = pkgs.stdenv.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ({ version, revision }: if version == "0.7" then ./patches/cryptonite-openssl-0.7.patch else null) ]; + # cryptonite-openssl.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ({ version, revision }: if version == "0.7" then ./patches/cryptonite-openssl-0.7.patch else null) ]; - # http-client.patches = pkgs.stdenv.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ({ version, revision }: if version == "0.5.14" then ./patches/http-client-0.5.14.patch else null) ]; + # http-client.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ({ version, revision }: if version == "0.5.14" then ./patches/http-client-0.5.14.patch else null) ]; - # conduit.patches = pkgs.stdenv.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ({ version, revision }: if builtins.compareVersions version "1.3.1.1" < 0 then ./patches/conduit-1.3.0.2.patch else null) ]; - # streaming-commons.patches = pkgs.stdenv.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ./patches/streaming-commons-0.2.0.0.patch ]; - # x509-system.patches = pkgs.stdenv.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ./patches/x509-system-1.6.6.patch ]; - # file-embed-lzma.patches = pkgs.stdenv.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ./patches/file-embed-lzma-0.patch ]; + # conduit.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ({ version, revision }: if builtins.compareVersions version "1.3.1.1" < 0 then ./patches/conduit-1.3.0.2.patch else null) ]; + # streaming-commons.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ./patches/streaming-commons-0.2.0.0.patch ]; + # x509-system.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ./patches/x509-system-1.6.6.patch ]; + # file-embed-lzma.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ./patches/file-embed-lzma-0.patch ]; # Set all of these to [], as these form the # dependency graph of the libiserv, iserv-proxy, and iserv-remote diff --git a/overlays/bootstrap.nix b/overlays/bootstrap.nix index 67f2762579..c77937f87b 100644 --- a/overlays/bootstrap.nix +++ b/overlays/bootstrap.nix @@ -735,7 +735,7 @@ in { isHaskellNixBootCompiler = true; } ) - (import ../compiler/old-ghc-nix { pkgs = final; }); + (import sources.old-ghc-nix { pkgs = final; }); packages = { # now that we have nix-tools and hpack, we can just diff --git a/overlays/emscripten/binaryen.nix b/overlays/emscripten/binaryen.nix index 3a03f633ff..14d5f14f9a 100644 --- a/overlays/emscripten/binaryen.nix +++ b/overlays/emscripten/binaryen.nix @@ -1,4 +1,4 @@ -{ stdenv, cmake, python3, fetchFromGitHub, emscriptenRev ? null, substituteAll }: +{ stdenv, lib, cmake, python3, fetchFromGitHub, emscriptenRev ? null, substituteAll }: let defaultVersion = "93"; @@ -29,14 +29,14 @@ stdenv.mkDerivation rec { inherit rev; }; - patches = stdenv.lib.optional (emscriptenRev != null) (substituteAll { + patches = lib.optional (emscriptenRev != null) (substituteAll { src = ./0001-Get-rid-of-git-dependency.patch; emscriptenv = "1.39.1"; }); nativeBuildInputs = [ cmake python3 ]; - meta = with stdenv.lib; { + meta = with lib; { homepage = "https://github.com/WebAssembly/binaryen"; description = "Compiler infrastructure and toolchain library for WebAssembly, in C++"; platforms = platforms.all; diff --git a/overlays/emscripten/default.nix b/overlays/emscripten/default.nix index e9c0aa874d..5a69306aad 100644 --- a/overlays/emscripten/default.nix +++ b/overlays/emscripten/default.nix @@ -1,4 +1,4 @@ -{ emscriptenVersion, stdenv, fetchFromGitHub, emscriptenfastcomp, python, nodejs, closurecompiler +{ emscriptenVersion, stdenv, lib, fetchFromGitHub, emscriptenfastcomp, python, nodejs, closurecompiler , jre, binaryen, enableWasm ? true , cmake, emscriptenBackend ? emscriptenfastcomp }: @@ -45,7 +45,7 @@ stdenv.mkDerivation { echo "SPIDERMONKEY_ENGINE = []" >> $out/${appdir}/config echo "EMCC_FAST_COMPILER = 0" >> $out/${appdir}/config '' - + stdenv.lib.optionalString enableWasm '' + + lib.optionalString enableWasm '' echo "BINARYEN_ROOT = '${binaryenVersioned}'" >> $out/share/emscripten/config '' + @@ -61,7 +61,7 @@ stdenv.mkDerivation { echo "--------------- /running test -----------------" ''; - meta = with stdenv.lib; { + meta = with lib; { homepage = "https://github.com/emscripten-core/emscripten"; description = "An LLVM-to-JavaScript Compiler"; platforms = platforms.all; diff --git a/overlays/emscripten/fastcomp/default.nix b/overlays/emscripten/fastcomp/default.nix index 57496d2886..0e5286910a 100644 --- a/overlays/emscripten/fastcomp/default.nix +++ b/overlays/emscripten/fastcomp/default.nix @@ -1,4 +1,4 @@ -{ newScope, stdenv, binutils, wrapCCWith, symlinkJoin }: +{ newScope, stdenv, lib, binutils, wrapCCWith, symlinkJoin }: let callPackage = newScope (self // {inherit stdenv;}); @@ -15,7 +15,7 @@ let ''; }; emscriptenfastcomp = symlinkJoin { - name = "emscriptenfastcomp-${stdenv.lib.getVersion self.emscriptenfastcomp-unwrapped}"; + name = "emscriptenfastcomp-${lib.getVersion self.emscriptenfastcomp-unwrapped}"; paths = [ self.emscriptenfastcomp-wrapped self.emscriptenfastcomp-unwrapped ]; preferLocalBuild = false; allowSubstitutes = true; diff --git a/overlays/emscripten/fastcomp/emscripten-fastcomp.nix b/overlays/emscripten/fastcomp/emscripten-fastcomp.nix index 520a34afe5..c94d8ef097 100644 --- a/overlays/emscripten/fastcomp/emscripten-fastcomp.nix +++ b/overlays/emscripten/fastcomp/emscripten-fastcomp.nix @@ -1,4 +1,4 @@ -{ emscriptenVersion, stdenv, fetchFromGitHub, cmake, python, gtest, ... }: +{ emscriptenVersion, stdenv, lib, fetchFromGitHub, cmake, python, gtest, ... }: let rev = emscriptenVersion; @@ -34,7 +34,7 @@ stdenv.mkDerivation rec { #"-DLLVM_CONFIG=${llvm}/bin/llvm-config" "-DLLVM_BUILD_TESTS=ON" "-DCLANG_INCLUDE_TESTS=ON" - ] ++ (stdenv.lib.optional stdenv.isLinux + ] ++ (lib.optional stdenv.isLinux # necessary for clang to find crtend.o "-DGCC_INSTALL_PREFIX=${gcc}" ); @@ -45,11 +45,11 @@ stdenv.mkDerivation rec { inherit gcc; }; - meta = with stdenv.lib; { + meta = with lib; { homepage = "https://github.com/emscripten-core/emscripten-fastcomp"; description = "Emscripten LLVM"; platforms = platforms.all; maintainers = with maintainers; [ qknight matthewbauer ]; - license = stdenv.lib.licenses.ncsa; + license = lib.licenses.ncsa; }; } diff --git a/overlays/emscripten/upstream/default.nix b/overlays/emscripten/upstream/default.nix index 1ac9c51ddd..cad5d15c9a 100644 --- a/overlays/emscripten/upstream/default.nix +++ b/overlays/emscripten/upstream/default.nix @@ -1,4 +1,4 @@ -{ newScope, stdenv, binutils, wrapCCWith, symlinkJoin }: +{ newScope, stdenv, lib, binutils, wrapCCWith, symlinkJoin }: let callPackage = newScope (self // {inherit stdenv;}); @@ -15,7 +15,7 @@ let ''; }; emscriptenupstream = symlinkJoin { - name = "emscriptenupstream-${stdenv.lib.getVersion self.emscriptenupstream-unwrapped}"; + name = "emscriptenupstream-${lib.getVersion self.emscriptenupstream-unwrapped}"; paths = [ self.emscriptenupstream-wrapped self.emscriptenupstream-unwrapped ]; preferLocalBuild = false; allowSubstitutes = true; diff --git a/overlays/emscripten/upstream/emscripten-upstream.nix b/overlays/emscripten/upstream/emscripten-upstream.nix index 1a2ed152c4..6afc0a3a81 100644 --- a/overlays/emscripten/upstream/emscripten-upstream.nix +++ b/overlays/emscripten/upstream/emscripten-upstream.nix @@ -1,4 +1,4 @@ -{ emscriptenVersion, stdenv, fetchFromGitHub, cmake, python, gtest, ... }: +{ emscriptenVersion, stdenv, lib, fetchFromGitHub, cmake, python, gtest, ... }: let gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc; @@ -39,7 +39,7 @@ stdenv.mkDerivation rec { #"-DLLVM_CONFIG=${llvm}/bin/llvm-config" "-DLLVM_BUILD_TESTS=ON" "-DCLANG_INCLUDE_TESTS=OFF" - ] ++ (stdenv.lib.optional stdenv.isLinux + ] ++ (lib.optional stdenv.isLinux # necessary for clang to find crtend.o "-DGCC_INSTALL_PREFIX=${gcc}" ); @@ -50,11 +50,11 @@ stdenv.mkDerivation rec { inherit gcc; }; - meta = with stdenv.lib; { + meta = with lib; { homepage = "http://github.com/llvm/llvm-project"; description = "LLVM"; platforms = platforms.all; maintainers = with maintainers; [ ]; - license = stdenv.lib.licenses.ncsa; + license = lib.licenses.ncsa; }; } diff --git a/overlays/haskell.nix b/overlays/haskell.nix index 39b33a309e..8520136e25 100644 --- a/overlays/haskell.nix +++ b/overlays/haskell.nix @@ -266,7 +266,7 @@ final: prev: { update-index-state-hashes = import ../scripts/update-index-state-hashes.nix { inherit (final.haskell-nix) indexStateHashesPath; - inherit (final) coreutils nix writeShellScriptBin stdenv curl; + inherit (final) coreutils nix writeShellScriptBin stdenv lib curl; # Update scripts use the internal nix-tools and cabal-install (compiled with a fixed GHC version) nix-tools = final.haskell-nix.internal-nix-tools; }; diff --git a/overlays/windows.nix b/overlays/windows.nix index de2e3176e0..7f04933726 100644 --- a/overlays/windows.nix +++ b/overlays/windows.nix @@ -17,11 +17,11 @@ final: prev: # }); mfpr = prev.mfpr.overrideAttrs (drv: { - configureFlags = (drv.configureFlags or []) ++ prev.stdenv.lib.optional prev.stdenv.hostPlatform.isWindows "--enable-static --disable-shared" ; + configureFlags = (drv.configureFlags or []) ++ prev.lib.optional prev.stdenv.hostPlatform.isWindows "--enable-static --disable-shared" ; }); libmpc = prev.libmpc.overrideAttrs (drv: { - configureFlags = (drv.configureFlags or []) ++ prev.stdenv.lib.optional prev.stdenv.hostPlatform.isWindows "--enable-static --disable-shared" ; + configureFlags = (drv.configureFlags or []) ++ prev.lib.optional prev.stdenv.hostPlatform.isWindows "--enable-static --disable-shared" ; }); binutils-unwrapped = prev.binutils-unwrapped.overrideAttrs (attrs: { @@ -72,7 +72,7 @@ final: prev: # figuring out which libraries we need for the build (walking the # dependencies) and then placing them somewhere where wine+remote-iserv # will find them. - remote-iserv.postInstall = pkgs.stdenv.lib.optionalString pkgs.stdenv.hostPlatform.isWindows ( + remote-iserv.postInstall = pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isWindows ( let extra-libs = [ pkgs.openssl.bin pkgs.libffi pkgs.gmp pkgs.libsodium ]; in '' for p in ${lib.concatStringsSep " "extra-libs}; do find "$p" -iname '*.dll' -exec cp {} $out/bin/ \; @@ -91,20 +91,20 @@ final: prev: # else null)) ]; # clock 0.7.2 needs to be patched to support cross compilation. - clock.patches = pkgs.stdenv.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ({ version, revision }: (if version == "0.7.2" then ./patches/clock-0.7.2.patch else null)) ]; + clock.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ({ version, revision }: (if version == "0.7.2" then ./patches/clock-0.7.2.patch else null)) ]; # nix calls this package crypto - cryptonite-openssl.patches = pkgs.stdenv.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ({ version, revision }: if version == "0.7" then ./patches/cryptonite-openssl-0.7.patch else null) ]; + cryptonite-openssl.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ({ version, revision }: if version == "0.7" then ./patches/cryptonite-openssl-0.7.patch else null) ]; # this patch seems to be rather flaky and highly dependent on # the network library. I think we might need to respin that in # a better way that doesn't just delete some code, but makes # the bounds checks stricter. - # http-client.patches = pkgs.stdenv.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ({ version, revision }: if version == "0.5.14" then ./patches/http-client-0.5.14.patch else null) ]; + # http-client.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ({ version, revision }: if version == "0.5.14" then ./patches/http-client-0.5.14.patch else null) ]; - conduit.patches = pkgs.stdenv.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ({ version, revision }: if builtins.compareVersions version "1.3.1.1" < 0 then ./patches/conduit-1.3.0.2.patch else null) ]; - streaming-commons.patches = pkgs.stdenv.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ./patches/streaming-commons-0.2.0.0.patch ]; - x509-system.patches = pkgs.stdenv.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ./patches/x509-system-1.6.6.patch ]; - file-embed-lzma.patches = pkgs.stdenv.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ./patches/file-embed-lzma-0.patch ]; + conduit.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ({ version, revision }: if builtins.compareVersions version "1.3.1.1" < 0 then ./patches/conduit-1.3.0.2.patch else null) ]; + streaming-commons.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ./patches/streaming-commons-0.2.0.0.patch ]; + x509-system.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ./patches/x509-system-1.6.6.patch ]; + file-embed-lzma.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ./patches/file-embed-lzma-0.patch ]; # Set all of these to [], as these form the # dependency graph of the libiserv, iserv-proxy, and iserv-remote diff --git a/scripts/check-closure-size.nix b/scripts/check-closure-size.nix index 7bdae0647e..d0eeab110e 100644 --- a/scripts/check-closure-size.nix +++ b/scripts/check-closure-size.nix @@ -1,9 +1,9 @@ -{ stdenv, writeScript, coreutils, gawk, nix +{ stdenv, lib, writeScript, coreutils, gawk, nix , nix-tools , limitMB ? 525 }: -with stdenv.lib; +with lib; writeScript "check-closure-size.sh" '' #!${stdenv.shell} diff --git a/scripts/check-hydra.nix b/scripts/check-hydra.nix index 2ef9a1118d..5d43ba7de9 100644 --- a/scripts/check-hydra.nix +++ b/scripts/check-hydra.nix @@ -1,6 +1,6 @@ -{ stdenv, writeScript, coreutils, time, gnutar, gzip, hydra-migration, jq }: +{ stdenv, lib, writeScript, coreutils, time, gnutar, gzip, hydra-migration, jq }: -with stdenv.lib; +with lib; writeScript "check-hydra.sh" '' #!${stdenv.shell} diff --git a/scripts/check-materialization-concurrency/check.nix b/scripts/check-materialization-concurrency/check.nix index ea0680f4c4..08edd3a5b3 100644 --- a/scripts/check-materialization-concurrency/check.nix +++ b/scripts/check-materialization-concurrency/check.nix @@ -1,6 +1,6 @@ -{ stdenv, writeScript }: +{ stdenv, lib, writeScript }: -with stdenv.lib; +with lib; writeScript "check-materialization-concurrency.sh" '' #!${stdenv.shell} diff --git a/scripts/check-path-support.nix b/scripts/check-path-support.nix index 58b1c85793..c38833d850 100644 --- a/scripts/check-path-support.nix +++ b/scripts/check-path-support.nix @@ -1,6 +1,6 @@ -{ stdenv, writeScript, coreutils, gnutar, gzip, nix }: +{ stdenv, lib, writeScript, coreutils, gnutar, gzip, nix }: -with stdenv.lib; +with lib; writeScript "check-path-supprot.sh" '' #!${stdenv.shell} diff --git a/scripts/update-docs.nix b/scripts/update-docs.nix index 05cb66e15a..81eeecec73 100644 --- a/scripts/update-docs.nix +++ b/scripts/update-docs.nix @@ -1,7 +1,7 @@ -{ stdenv, writeScript, coreutils, glibc, git, openssh, gnused, mkdocs +{ stdenv, lib, writeScript, coreutils, glibc, git, openssh, gnused, mkdocs , generatedOptions }: -with stdenv.lib; +with lib; let repo = "git@github.com:input-output-hk/haskell.nix.git"; diff --git a/scripts/update-external.nix b/scripts/update-external.nix index 3537154432..c47d10e8a1 100644 --- a/scripts/update-external.nix +++ b/scripts/update-external.nix @@ -1,10 +1,10 @@ -{ stdenv, writeScript, glibc, coreutils, git, openssh +{ stdenv, lib, writeScript, glibc, coreutils, git, openssh , nix-tools, cabal-install, nix-prefetch-git , bash, curl, findutils, gawk }: { name, script }: -with stdenv.lib; +with lib; let repoHTTPS = "https://github.com/input-output-hk/${name}.nix"; diff --git a/scripts/update-hackage.nix b/scripts/update-hackage.nix index 166ad17241..78c6d8911c 100644 --- a/scripts/update-hackage.nix +++ b/scripts/update-hackage.nix @@ -1,4 +1,4 @@ -{ stdenv, writeScript, coreutils, glibc, git, openssh +{ stdenv, lib, writeScript, coreutils, glibc, git, openssh , nix-tools, cabal-install, nix-prefetch-git , gawk, bash, curl, findutils , update-index-state-hashes }@args: diff --git a/scripts/update-index-state-hashes.nix b/scripts/update-index-state-hashes.nix index e26780f607..80c6b215e3 100644 --- a/scripts/update-index-state-hashes.nix +++ b/scripts/update-index-state-hashes.nix @@ -1,6 +1,6 @@ -{ indexStateHashesPath, nix-tools, coreutils, nix, writeShellScriptBin, stdenv, curl }: +{ indexStateHashesPath, nix-tools, coreutils, nix, writeShellScriptBin, stdenv, lib, curl }: with builtins; -with stdenv.lib; +with lib; writeShellScriptBin "update-index-state-hashes" '' export PATH="${makeBinPath [ coreutils nix-tools nix curl ]}" diff --git a/scripts/update-pins.nix b/scripts/update-pins.nix index 7665b351f8..382a81c49e 100644 --- a/scripts/update-pins.nix +++ b/scripts/update-pins.nix @@ -1,6 +1,6 @@ -{ stdenv, writeScript, coreutils, glibc, git, openssh }@args: +{ stdenv, lib, writeScript, coreutils, glibc, git, openssh }@args: -with stdenv.lib; +with lib; let repo = "git@github.com:input-output-hk/haskell.nix.git"; diff --git a/scripts/update-stackage.nix b/scripts/update-stackage.nix index d643727538..0cfa998995 100644 --- a/scripts/update-stackage.nix +++ b/scripts/update-stackage.nix @@ -1,4 +1,4 @@ -{ stdenv, writeScript, coreutils, glibc, git, openssh +{ stdenv, lib, writeScript, coreutils, glibc, git, openssh , nix-tools, cabal-install, nix-prefetch-git , gawk, bash, curl, findutils }@args: diff --git a/test/buildable/default.nix b/test/buildable/default.nix index e622fe0af2..c9c664bc3d 100644 --- a/test/buildable/default.nix +++ b/test/buildable/default.nix @@ -1,6 +1,6 @@ -{ stdenv, cabalProject', haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name }: +{ stdenv, lib, cabalProject', haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name }: -with stdenv.lib; +with lib; let project = cabalProject' { diff --git a/test/builder-haddock/default.nix b/test/builder-haddock/default.nix index 7b56f28a77..7ab535ae73 100644 --- a/test/builder-haddock/default.nix +++ b/test/builder-haddock/default.nix @@ -1,6 +1,6 @@ -{ mkCabalProjectPkgSet, stdenv, testSrc }: +{ mkCabalProjectPkgSet, stdenv, lib, testSrc }: -with stdenv.lib; +with lib; let pkgSet = mkCabalProjectPkgSet { diff --git a/test/cabal-22/default.nix b/test/cabal-22/default.nix index 008b2a1db5..a98e88ad8c 100644 --- a/test/cabal-22/default.nix +++ b/test/cabal-22/default.nix @@ -1,6 +1,6 @@ -{ stdenv, mkCabalProjectPkgSet, cabalProject', haskellLib, util, recurseIntoAttrs, testSrc, compiler-nix-name }: +{ stdenv, lib, mkCabalProjectPkgSet, cabalProject', haskellLib, util, recurseIntoAttrs, testSrc, compiler-nix-name }: -with stdenv.lib; +with lib; let project = cabalProject' { diff --git a/test/cabal-hpack/default.nix b/test/cabal-hpack/default.nix index a2aaa6ec36..fe981c3070 100644 --- a/test/cabal-hpack/default.nix +++ b/test/cabal-hpack/default.nix @@ -1,7 +1,7 @@ # Test a package set -{ stdenv, util, mkCabalProjectPkgSet, project', haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name }: +{ stdenv, lib, util, mkCabalProjectPkgSet, project', haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name }: -with stdenv.lib; +with lib; let modules = [ diff --git a/test/cabal-simple-prof/default.nix b/test/cabal-simple-prof/default.nix index 05b12c8907..03b1980773 100644 --- a/test/cabal-simple-prof/default.nix +++ b/test/cabal-simple-prof/default.nix @@ -1,7 +1,7 @@ # Test a package set -{ stdenv, util, cabalProject', haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name }: +{ stdenv, lib, util, cabalProject', haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name }: -with stdenv.lib; +with lib; let modules = [ diff --git a/test/cabal-simple/default.nix b/test/cabal-simple/default.nix index c00880b580..70d1d6886c 100644 --- a/test/cabal-simple/default.nix +++ b/test/cabal-simple/default.nix @@ -1,7 +1,7 @@ # Test a package set -{ stdenv, util, mkCabalProjectPkgSet, project', haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name }: +{ stdenv, lib, util, mkCabalProjectPkgSet, project', haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name }: -with stdenv.lib; +with lib; let modules = [ diff --git a/test/cabal-source-repo-comments/default.nix b/test/cabal-source-repo-comments/default.nix index d3f6bc48c0..776a5e1634 100644 --- a/test/cabal-source-repo-comments/default.nix +++ b/test/cabal-source-repo-comments/default.nix @@ -1,6 +1,6 @@ -{ stdenv, cabalProject', recurseIntoAttrs, haskellLib, testSrc, compiler-nix-name }: +{ stdenv, lib, cabalProject', recurseIntoAttrs, haskellLib, testSrc, compiler-nix-name }: -with stdenv.lib; +with lib; let project = cabalProject' { diff --git a/test/cabal-source-repo/default.nix b/test/cabal-source-repo/default.nix index 41f0324f47..bdcec5a272 100644 --- a/test/cabal-source-repo/default.nix +++ b/test/cabal-source-repo/default.nix @@ -1,6 +1,6 @@ -{ stdenv, cabalProject', recurseIntoAttrs, haskellLib, testSrc, compiler-nix-name }: +{ stdenv, lib, cabalProject', recurseIntoAttrs, haskellLib, testSrc, compiler-nix-name }: -with stdenv.lib; +with lib; let project = cabalProject' { diff --git a/test/cabal-sublib/default.nix b/test/cabal-sublib/default.nix index 89f2dbdaef..5c3458b53b 100644 --- a/test/cabal-sublib/default.nix +++ b/test/cabal-sublib/default.nix @@ -1,7 +1,7 @@ # Test a package set -{ stdenv, util, cabalProject', haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name }: +{ stdenv, lib, util, cabalProject', haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name }: -with stdenv.lib; +with lib; let modules = [ diff --git a/test/call-cabal-project-to-nix/default.nix b/test/call-cabal-project-to-nix/default.nix index 96c6813e43..0a436a483c 100644 --- a/test/call-cabal-project-to-nix/default.nix +++ b/test/call-cabal-project-to-nix/default.nix @@ -1,6 +1,6 @@ -{ stdenv, mkCabalProjectPkgSet, callCabalProjectToNix, importAndFilterProject, recurseIntoAttrs, haskellLib, testSrc, compiler-nix-name }: +{ stdenv, lib, mkCabalProjectPkgSet, callCabalProjectToNix, importAndFilterProject, recurseIntoAttrs, haskellLib, testSrc, compiler-nix-name }: -with stdenv.lib; +with lib; let # This test could use cabalProject', but it does so that it diff --git a/test/call-stack-to-nix/default.nix b/test/call-stack-to-nix/default.nix index c6667797c3..1b87fb69a2 100644 --- a/test/call-stack-to-nix/default.nix +++ b/test/call-stack-to-nix/default.nix @@ -1,6 +1,6 @@ -{ stdenv, mkStackPkgSet, callStackToNix, importAndFilterProject, recurseIntoAttrs, haskellLib, testSrc }: +{ stdenv, lib, mkStackPkgSet, callStackToNix, importAndFilterProject, recurseIntoAttrs, haskellLib, testSrc }: -with stdenv.lib; +with lib; let callProjectResults = callStackToNix { diff --git a/test/compiler-nix-name/default.nix b/test/compiler-nix-name/default.nix index adf776bd35..69b52144ff 100644 --- a/test/compiler-nix-name/default.nix +++ b/test/compiler-nix-name/default.nix @@ -1,6 +1,6 @@ -{ stdenv, haskell-nix, recurseIntoAttrs, testSrc }: +{ stdenv, lib, haskell-nix, recurseIntoAttrs, testSrc }: -with stdenv.lib; +with lib; let project = haskell-nix.cabalProject' { diff --git a/test/coverage-golden/default.nix b/test/coverage-golden/default.nix index 70adfb5a85..cbdc97d043 100644 --- a/test/coverage-golden/default.nix +++ b/test/coverage-golden/default.nix @@ -1,6 +1,6 @@ -{ stdenv, fetchFromGitHub, recurseIntoAttrs, runCommand, testSrc, compiler-nix-name, buildPackages, sources }: +{ stdenv, lib, fetchFromGitHub, recurseIntoAttrs, runCommand, testSrc, compiler-nix-name, buildPackages, sources }: -with stdenv.lib; +with lib; let # Using buildPackages.buildPackages here because buildPackages.git diff --git a/test/coverage-no-libs/default.nix b/test/coverage-no-libs/default.nix index 8f07fb0da3..21579685b4 100644 --- a/test/coverage-no-libs/default.nix +++ b/test/coverage-no-libs/default.nix @@ -1,6 +1,6 @@ -{ stdenv, cabal-install, cabalProject', stackProject', recurseIntoAttrs, runCommand, testSrc, compiler-nix-name }: +{ stdenv, lib, cabal-install, cabalProject', stackProject', recurseIntoAttrs, runCommand, testSrc, compiler-nix-name }: -with stdenv.lib; +with lib; let projectArgs = { diff --git a/test/coverage/default.nix b/test/coverage/default.nix index 65382f73de..615f723705 100644 --- a/test/coverage/default.nix +++ b/test/coverage/default.nix @@ -1,6 +1,6 @@ -{ stdenv, cabal-install, cabalProject', stackProject', recurseIntoAttrs, runCommand, testSrc, compiler-nix-name }: +{ stdenv, lib, cabal-install, cabalProject', stackProject', recurseIntoAttrs, runCommand, testSrc, compiler-nix-name }: -with stdenv.lib; +with lib; let projectArgs = { diff --git a/test/exe-only/default.nix b/test/exe-only/default.nix index 293b3d98ca..1887662b4c 100644 --- a/test/exe-only/default.nix +++ b/test/exe-only/default.nix @@ -1,7 +1,7 @@ # Test a package set -{ stdenv, util, haskell-nix, recurseIntoAttrs, haskellLib, testSrc, compiler-nix-name }: +{ stdenv, lib, util, haskell-nix, recurseIntoAttrs, haskellLib, testSrc, compiler-nix-name }: -with stdenv.lib; +with lib; let project = haskell-nix.cabalProject' { diff --git a/test/extra-hackage/default.nix b/test/extra-hackage/default.nix index 522905dfae..40d8c40734 100644 --- a/test/extra-hackage/default.nix +++ b/test/extra-hackage/default.nix @@ -1,6 +1,6 @@ -{ stdenv, cabalProject', haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name }: +{ stdenv, lib, cabalProject', haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name }: -with stdenv.lib; +with lib; let diff --git a/test/fully-static/default.nix b/test/fully-static/default.nix index 4d56bf2de2..15deaa4536 100644 --- a/test/fully-static/default.nix +++ b/test/fully-static/default.nix @@ -1,11 +1,11 @@ { stackProject' -, stdenv, gmp6, openssl, zlib, libffi +, stdenv, lib, gmp6, openssl, zlib, libffi , buildPackages , recurseIntoAttrs , testSrc }: -with stdenv.lib; +with lib; let # Grab the compiler name from stack-to-nix output. diff --git a/test/ghc-options/cabal.nix b/test/ghc-options/cabal.nix index dec691d942..f39e9106fa 100644 --- a/test/ghc-options/cabal.nix +++ b/test/ghc-options/cabal.nix @@ -1,6 +1,6 @@ -{ stdenv, cabalProject', recurseIntoAttrs, haskellLib, testSrc, compiler-nix-name }: +{ stdenv, lib, cabalProject', recurseIntoAttrs, haskellLib, testSrc, compiler-nix-name }: -with stdenv.lib; +with lib; let project = cabalProject' { diff --git a/test/ghc-options/stack.nix b/test/ghc-options/stack.nix index a451c2e481..65fb1ec0e4 100644 --- a/test/ghc-options/stack.nix +++ b/test/ghc-options/stack.nix @@ -1,6 +1,6 @@ -{ stdenv, stackProject', recurseIntoAttrs, haskellLib, testSrc }: +{ stdenv, lib, stackProject', recurseIntoAttrs, haskellLib, testSrc }: -with stdenv.lib; +with lib; let project = stackProject' { diff --git a/test/githash/default.nix b/test/githash/default.nix index 90dcfa7421..6a674efc19 100644 --- a/test/githash/default.nix +++ b/test/githash/default.nix @@ -1,6 +1,6 @@ -{ stdenv, haskell-nix, recurseIntoAttrs, testSrc, compiler-nix-name, runCommand, gitMinimal, buildPackages }: +{ stdenv, lib, haskell-nix, recurseIntoAttrs, testSrc, compiler-nix-name, runCommand, gitMinimal, buildPackages }: -with stdenv.lib; +with lib; let src = testSrc "githash"; diff --git a/test/index-state/default.nix b/test/index-state/default.nix index 24962554ab..8e05755abb 100644 --- a/test/index-state/default.nix +++ b/test/index-state/default.nix @@ -1,7 +1,7 @@ # Test a package set -{ stdenv, testSrc, tool, compiler-nix-name }: +{ stdenv, lib, testSrc, tool, compiler-nix-name }: -with stdenv.lib; +with lib; let # The hackage-security 0.6.0.1 was uploaded at 2020-04-06T20:54:35Z diff --git a/test/project-flags/cabal.nix b/test/project-flags/cabal.nix index 46bed36ea1..72f991d055 100644 --- a/test/project-flags/cabal.nix +++ b/test/project-flags/cabal.nix @@ -1,6 +1,6 @@ -{ stdenv, cabalProject', recurseIntoAttrs, haskellLib, testSrc, compiler-nix-name }: +{ stdenv, lib, cabalProject', recurseIntoAttrs, haskellLib, testSrc, compiler-nix-name }: -with stdenv.lib; +with lib; let project = cabalProject' { diff --git a/test/project-flags/stack.nix b/test/project-flags/stack.nix index a6c619ff50..2e76a2a351 100644 --- a/test/project-flags/stack.nix +++ b/test/project-flags/stack.nix @@ -1,6 +1,6 @@ -{ stdenv, stackProject', recurseIntoAttrs, haskellLib, testSrc }: +{ stdenv, lib, stackProject', recurseIntoAttrs, haskellLib, testSrc }: -with stdenv.lib; +with lib; let project = stackProject' { diff --git a/test/setup-deps/default.nix b/test/setup-deps/default.nix index 29e80951b0..7f3c8c313a 100644 --- a/test/setup-deps/default.nix +++ b/test/setup-deps/default.nix @@ -1,7 +1,7 @@ { pkgs, compiler-nix-name }: with pkgs; -with stdenv.lib; +with lib; let project = haskell-nix.cabalProject' { diff --git a/test/shell-for-setup-deps/default.nix b/test/shell-for-setup-deps/default.nix index 191e7222dc..ece3e7a502 100644 --- a/test/shell-for-setup-deps/default.nix +++ b/test/shell-for-setup-deps/default.nix @@ -1,6 +1,6 @@ -{ stdenv, cabal-install, cabalProject', recurseIntoAttrs, runCommand, testSrc, compiler-nix-name }: +{ stdenv, lib, cabal-install, cabalProject', recurseIntoAttrs, runCommand, testSrc, compiler-nix-name }: -with stdenv.lib; +with lib; let project = cabalProject' { diff --git a/test/shell-for/default.nix b/test/shell-for/default.nix index de4a5d139c..ff27356cc9 100644 --- a/test/shell-for/default.nix +++ b/test/shell-for/default.nix @@ -1,6 +1,6 @@ -{ stdenv, cabal-install, mkCabalProjectPkgSet, recurseIntoAttrs, runCommand, testSrc }: +{ stdenv, lib, cabal-install, mkCabalProjectPkgSet, recurseIntoAttrs, runCommand, testSrc }: -with stdenv.lib; +with lib; let pkgSet = mkCabalProjectPkgSet { diff --git a/test/snapshots/default.nix b/test/snapshots/default.nix index 2247cbf802..56b897d5c8 100644 --- a/test/snapshots/default.nix +++ b/test/snapshots/default.nix @@ -1,6 +1,6 @@ -{ stdenv, haskellPackages, snapshots, recurseIntoAttrs, runCommand, testSrc }: +{ stdenv, lib, haskellPackages, snapshots, recurseIntoAttrs, runCommand, testSrc }: -with stdenv.lib; +with lib; let env = snapshots."lts-14.13".ghcWithHoogle diff --git a/test/stack-simple/default.nix b/test/stack-simple/default.nix index fc2256da66..33d4d38249 100644 --- a/test/stack-simple/default.nix +++ b/test/stack-simple/default.nix @@ -1,6 +1,6 @@ -{ stdenv, pkgs, mkStackPkgSet, haskellLib, testSrc }: +{ stdenv, lib, pkgs, mkStackPkgSet, haskellLib, testSrc }: -with stdenv.lib; +with lib; let # ./pkgs.nix and ./stack-simple.nix are generated by running diff --git a/test/sublib-docs/default.nix b/test/sublib-docs/default.nix index 38bbd69a09..bebb768a3f 100644 --- a/test/sublib-docs/default.nix +++ b/test/sublib-docs/default.nix @@ -1,7 +1,7 @@ # Test a package set -{ stdenv, util, cabalProject', haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name }: +{ stdenv, lib, util, cabalProject', haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name }: -with stdenv.lib; +with lib; let project = cabalProject' { diff --git a/test/with-packages/default.nix b/test/with-packages/default.nix index 640a04af1a..cd15d2756d 100644 --- a/test/with-packages/default.nix +++ b/test/with-packages/default.nix @@ -1,6 +1,6 @@ -{ stdenv, util, mkPkgSet, recurseIntoAttrs, testSrc }: +{ stdenv, lib, util, mkPkgSet, recurseIntoAttrs, testSrc }: -with stdenv.lib; +with lib; with util; let