Skip to content

Commit 791f5ff

Browse files
liesnikovjespercockx
authored andcommitted
nix: Switch to haskell-updates branch
Temporary fix: don't pull in hls since it's broken upstream Update ./nix/agda2hs.nix to match upstream, don't rely on Everything file anymore
1 parent edcfe6b commit 791f5ff

File tree

5 files changed

+62
-45
lines changed

5 files changed

+62
-45
lines changed

flake.lock

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
description = "Agda2hs";
33

4-
inputs.nixpkgs.url = "github:NixOS/nixpkgs";
4+
inputs.nixpkgs.url = "github:NixOS/nixpkgs/haskell-updates";
55
inputs.flake-utils.url = "github:numtide/flake-utils";
66

77
outputs =

nix/agda2hs.nix

Lines changed: 55 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,68 @@
11
# This file should be very close to a copy of nixpkgs/pkgs/build-support/agda/default.nix
2-
# The present file appears to be an amalgaman of
3-
# https://github.com/NixOS/nixpkgs/blob/bbe6402ecacfc3a0e2c65e3527c2cbe148b98ff8/pkgs/build-support/agda/default.nix
4-
# https://github.com/NixOS/nixpkgs/blob/583eef75e722741878b186f5bdf5a826d638f868/pkgs/build-support/agda/default.nix
2+
# The present file is based on https://github.com/NixOS/nixpkgs/blob/1d2cfef5e965ca6933a8aa696eadfa556d90fab3/pkgs/build-support/agda/default.nix
3+
# FIXME: this file is haskell-updates, double-check that nothing changes once it gets merged in unstable
54
# but it would be nice to expose this in upstream so that we don't have to duplicate the file
65
{
76
stdenv,
87
lib,
98
self,
109
agda2hs,
11-
runCommandNoCC,
10+
runCommand,
1211
makeWrapper,
1312
writeText,
1413
ghcWithPackages,
1514
}:
16-
17-
with lib.strings;
1815
let
19-
withPackages' = {
20-
pkgs,
21-
ghc ? ghcWithPackages (p: with p; [ ieee754 ])
22-
}: let
23-
pkgs' = if builtins.isList pkgs then pkgs else pkgs self;
24-
library-file = writeText "libraries" ''
16+
inherit (lib)
17+
elem
18+
filter
19+
filterAttrs
20+
isList
21+
isAttrs
22+
platforms
23+
;
24+
25+
inherit (lib.strings)
26+
concatMapStringsSep
27+
optionalString
28+
;
29+
30+
mkLibraryFile =
31+
pkgs:
32+
let
33+
pkgs' = if isList pkgs then pkgs else pkgs self;
34+
in
35+
writeText "libraries" ''
2536
${(concatMapStringsSep "\n" (p: "${p}/${p.libraryFile}") pkgs')}
2637
'';
27-
pname = "agda2hsWithPackages";
28-
version = agda2hs.version;
29-
in runCommandNoCC "${pname}-${version}" {
30-
inherit pname version;
31-
nativeBuildInputs = [ makeWrapper ];
32-
passthru.unwrapped = agda2hs;
33-
} ''
34-
mkdir -p $out/bin
35-
makeWrapper ${agda2hs}/bin/agda2hs $out/bin/agda2hs \
36-
--add-flags "--with-compiler=${ghc}/bin/ghc" \
37-
--add-flags "--library-file=${library-file}"
38-
'';
39-
withPackages = arg: if builtins.isAttrs arg then withPackages' arg else withPackages' { pkgs = arg; };
38+
39+
withPackages' =
40+
{
41+
pkgs,
42+
ghc ? ghcWithPackages (p: with p; [ ieee754 ]),
43+
}:
44+
let
45+
library-file = mkLibraryFile pkgs;
46+
pname = "agda2hsWithPackages";
47+
version = agda2hs.version;
48+
in
49+
runCommand "${pname}-${version}"
50+
{
51+
inherit pname version;
52+
nativeBuildInputs = [ makeWrapper ];
53+
passthru = {
54+
unwrapped = agda2hs;
55+
inherit withPackages;
56+
};
57+
}
58+
''
59+
mkdir -p $out/bin
60+
makeWrapper ${agda2hs}/bin/agda2hs $out/bin/agda2hs \
61+
${lib.optionalString (ghc != null) ''--add-flags "--with-compiler=${ghc}/bin/ghc"''} \
62+
--add-flags "--library-file=${library-file}"
63+
'';
64+
65+
withPackages = arg: if isAttrs arg then withPackages' arg else withPackages' { pkgs = arg; };
4066

4167
extensions = [
4268
"agda"
@@ -55,8 +81,6 @@ let
5581
pname,
5682
meta,
5783
buildInputs ? [ ],
58-
everythingFile ? "./Everything.agda",
59-
includePaths ? [ ],
6084
libraryName ? pname,
6185
libraryFile ? "${libraryName}.agda-lib",
6286
buildPhase ? null,
@@ -65,26 +89,22 @@ let
6589
...
6690
}:
6791
let
68-
agdaWithArgs = withPackages (filter (p: p ? isAgdaDerivation) buildInputs);
69-
includePathArgs = concatMapStrings (path: "-i" + path + " ") (
70-
includePaths ++ [ (dirOf everythingFile) ]
71-
);
92+
agdaWithPkgs = withPackages (filter (p: p ? isAgdaDerivation) buildInputs);
7293
in
7394
{
7495
inherit libraryName libraryFile;
7596

7697
isAgdaDerivation = true;
7798

78-
buildInputs = buildInputs ++ [ agdaWithArgs ];
99+
buildInputs = buildInputs ++ [ agdaWithPkgs ];
79100

80101
buildPhase =
81102
if buildPhase != null then
82103
buildPhase
83104
else
84105
''
85106
runHook preBuild
86-
agda2hs ${includePathArgs} ${everythingFile}
87-
rm ${everythingFile} ${everythingFile}i
107+
agda2hs --build-library
88108
runHook postBuild
89109
'';
90110

@@ -112,6 +132,6 @@ let
112132
in {
113133
mkDerivation = args: stdenv.mkDerivation (args // defaults args);
114134

115-
inherit withPackages;
135+
inherit mkLibraryFile withPackages withPackages';
116136
agda2hs = withPackages [];
117137
}

nix/default.nix

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ let
1010
pname = "base";
1111
meta = { };
1212
version = "4.18";
13-
preBuild = ''
14-
echo "{-# OPTIONS --sized-types #-}" > Everything.agda
15-
echo "module Everything where" >> Everything.agda
16-
find . -name '*.agda' ! -name 'Everything.agda' | sed -e 's/.\///;s/\//./g;s/\.agda$//;s/^/import /' >> Everything.agda
17-
'';
1813
src = ../lib/base;
1914
};
2015

nix/shell.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ pkgs.haskellPackages.shellFor {
1717
nativeBuildInputs = with pkgs.haskellPackages; [
1818
# related to haskell
1919
cabal-install
20-
haskell-language-server
20+
# FIXME: broken in haskell-updates, uncomment when upstream fixes it
21+
# haskell-language-server
2122
# general goodies
2223
pkgs.agda
2324
pkgs.nixfmt-rfc-style

0 commit comments

Comments
 (0)