Avoid top-level with ...; in pkgs/build-support/agda/default.nix

This commit is contained in:
Philip Taron 2024-03-12 13:37:34 -07:00 committed by Valentin Gagarin
parent f41fbee73a
commit 8c4a1e8d66

View file

@ -2,14 +2,28 @@
{ stdenv, lib, self, Agda, runCommand, makeWrapper, writeText, ghcWithPackages, nixosTests }: { stdenv, lib, self, Agda, runCommand, makeWrapper, writeText, ghcWithPackages, nixosTests }:
with lib.strings;
let let
inherit (lib)
attrValues
elem
filter
filterAttrs
isAttrs
isList
platforms
;
inherit (lib.strings)
concatMapStrings
concatMapStringsSep
optionalString
;
withPackages' = { withPackages' = {
pkgs, pkgs,
ghc ? ghcWithPackages (p: with p; [ ieee754 ]) ghc ? ghcWithPackages (p: with p; [ ieee754 ])
}: let }: let
pkgs' = if builtins.isList pkgs then pkgs else pkgs self; pkgs' = if isList pkgs then pkgs else pkgs self;
library-file = writeText "libraries" '' library-file = writeText "libraries" ''
${(concatMapStringsSep "\n" (p: "${p}/${p.libraryFile}") pkgs')} ${(concatMapStringsSep "\n" (p: "${p}/${p.libraryFile}") pkgs')}
''; '';
@ -23,7 +37,7 @@ let
inherit withPackages; inherit withPackages;
tests = { tests = {
inherit (nixosTests) agda; inherit (nixosTests) agda;
allPackages = withPackages (lib.filter self.lib.isUnbrokenAgdaPackage (lib.attrValues self)); allPackages = withPackages (filter self.lib.isUnbrokenAgdaPackage (attrValues self));
}; };
}; };
inherit (Agda) meta; inherit (Agda) meta;
@ -36,7 +50,7 @@ let
ln -s ${Agda}/bin/agda-mode $out/bin/agda-mode ln -s ${Agda}/bin/agda-mode $out/bin/agda-mode
''; # Local interfaces has been added for now: See https://github.com/agda/agda/issues/4526 ''; # Local interfaces has been added for now: See https://github.com/agda/agda/issues/4526
withPackages = arg: if builtins.isAttrs arg then withPackages' arg else withPackages' { pkgs = arg; }; withPackages = arg: if isAttrs arg then withPackages' arg else withPackages' { pkgs = arg; };
extensions = [ extensions = [
"agda" "agda"
@ -63,7 +77,7 @@ let
, extraExtensions ? [] , extraExtensions ? []
, ... , ...
}: let }: let
agdaWithArgs = withPackages (builtins.filter (p: p ? isAgdaDerivation) buildInputs); agdaWithArgs = withPackages (filter (p: p ? isAgdaDerivation) buildInputs);
includePathArgs = concatMapStrings (path: "-i" + path + " ") (includePaths ++ [(dirOf everythingFile)]); includePathArgs = concatMapStrings (path: "-i" + path + " ") (includePaths ++ [(dirOf everythingFile)]);
in in
{ {
@ -91,13 +105,13 @@ let
# darwin, it seems that there is no standard such locale; luckily, # darwin, it seems that there is no standard such locale; luckily,
# the referenced issue doesn't seem to surface on darwin. Hence let's # the referenced issue doesn't seem to surface on darwin. Hence let's
# set this only on non-darwin. # set this only on non-darwin.
LC_ALL = lib.optionalString (!stdenv.isDarwin) "C.UTF-8"; LC_ALL = optionalString (!stdenv.isDarwin) "C.UTF-8";
meta = if meta.broken or false then meta // { hydraPlatforms = lib.platforms.none; } else meta; meta = if meta.broken or false then meta // { hydraPlatforms = platforms.none; } else meta;
# Retrieve all packages from the finished package set that have the current package as a dependency and build them # Retrieve all packages from the finished package set that have the current package as a dependency and build them
passthru.tests = with builtins; passthru.tests =
lib.filterAttrs (name: pkg: self.lib.isUnbrokenAgdaPackage pkg && elem pname (map (pkg: pkg.pname) pkg.buildInputs)) self; filterAttrs (name: pkg: self.lib.isUnbrokenAgdaPackage pkg && elem pname (map (pkg: pkg.pname) pkg.buildInputs)) self;
}; };
in in
{ {