-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
agda: parameterize agda infrastructure by Agda executable name #452961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0483e40
a896795
cd8deb7
ab75be0
f933041
4c64e80
5882fce
fdf4727
fc65416
3c39038
55ac814
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { runTest }: | ||
| { | ||
| base = runTest ./base.nix; | ||
| override-with-backend = runTest ./override-with-backend.nix; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| {-# OPTIONS --guardedness #-} | ||
| open import IO | ||
| open import Level | ||
|
|
||
| main = run {0ℓ} (putStrLn "Hello World!") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| module Main where | ||
|
|
||
| import Agda.Main ( runAgda ) | ||
|
|
||
| main :: IO () | ||
| main = runAgda [] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| { pkgs, ... }: | ||
| let | ||
| mainProgram = "agda-trivial-backend"; | ||
|
|
||
| hello-world = ./files/HelloWorld.agda; | ||
|
|
||
| agda-trivial-backend = pkgs.stdenvNoCC.mkDerivation { | ||
| name = "trivial-backend"; | ||
| meta = { inherit mainProgram; }; | ||
| version = "${pkgs.haskellPackages.Agda.version}"; | ||
| src = ./files/TrivialBackend.hs; | ||
| buildInputs = [ | ||
| (pkgs.haskellPackages.ghcWithPackages (pkgs: [ pkgs.Agda ])) | ||
| ]; | ||
| dontUnpack = true; | ||
| buildPhase = '' | ||
| ghc $src -o ${mainProgram} | ||
| ''; | ||
| installPhase = '' | ||
| mkdir -p $out/bin | ||
| cp ${mainProgram} $out/bin | ||
| ''; | ||
| }; | ||
| in | ||
| { | ||
| name = "agda-trivial-backend"; | ||
| meta = with pkgs.lib.maintainers; { | ||
| maintainers = [ | ||
| carlostome | ||
| ]; | ||
| }; | ||
|
|
||
| nodes.machine = | ||
| { pkgs, ... }: | ||
| let | ||
| agdaPackages = pkgs.agdaPackages.override (oldAttrs: { | ||
| Agda = agda-trivial-backend; | ||
| }); | ||
| in | ||
| { | ||
| environment.systemPackages = [ | ||
| (agdaPackages.agda.withPackages { | ||
| pkgs = p: [ p.standard-library ]; | ||
| }) | ||
| ]; | ||
| virtualisation.memorySize = 2000; # Agda uses a lot of memory | ||
| }; | ||
|
|
||
| testScript = '' | ||
| # agda and agda-mode are not in path | ||
| machine.fail("agda --version") | ||
| machine.fail("agda-mode") | ||
| # backend is present | ||
| text = machine.succeed("${mainProgram} --help") | ||
| assert "${mainProgram}" in text | ||
| # Hello world | ||
| machine.succeed( | ||
| "cp ${hello-world} HelloWorld.agda" | ||
| ) | ||
| machine.succeed("${mainProgram} -l standard-library -i . -c HelloWorld.agda") | ||
| # Check execution | ||
| text = machine.succeed("./HelloWorld") | ||
| assert "Hello World!" in text, f"HelloWorld does not run properly: output was {text}" | ||
| ''; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,7 +45,7 @@ let | |
| }: | ||
| let | ||
| libraryFile = mkLibraryFile pkgs; | ||
| pname = "agdaWithPackages"; | ||
| pname = "${Agda.meta.mainProgram}WithPackages"; | ||
| version = Agda.version; | ||
| in | ||
| runCommand "${pname}-${version}" | ||
|
|
@@ -68,10 +68,12 @@ let | |
| } | ||
| '' | ||
| mkdir -p $out/bin | ||
| makeWrapper ${lib.getExe Agda} $out/bin/agda \ | ||
| makeWrapper ${lib.getExe Agda} $out/bin/${Agda.meta.mainProgram} \ | ||
| ${lib.optionalString (ghc != null) ''--add-flags "--with-compiler=${ghc}/bin/ghc"''} \ | ||
| --add-flags "--library-file=${libraryFile}" | ||
| ln -s ${lib.getExe' Agda "agda-mode"} $out/bin/agda-mode | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason to remove this now? If not I would prefer to follow upstream's deprecation cycle. The executable currently prints a deprecation message when run.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason is to be compatible with backends that do not have an
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This sounds like the kind of out-of-tree compatibility that would be hard to maintain in nixpkgs since we don't have any non-default backends here. Adding a test derivation in nixpkgs as suggested by @turion could address this.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd still prefer to conditionally link |
||
| if [ -e ${lib.getExe' Agda "agda-mode"} ]; then | ||
| ln -s ${lib.getExe' Agda "agda-mode"} $out/bin/agda-mode | ||
| fi | ||
| ''; | ||
|
|
||
| withPackages = arg: if isAttrs arg then withPackages' arg else withPackages' { pkgs = arg; }; | ||
|
|
@@ -116,7 +118,7 @@ let | |
| else | ||
| '' | ||
| runHook preBuild | ||
| agda --build-library | ||
| ${lib.getExe agdaWithPkgs} --build-library | ||
| runHook postBuild | ||
| ''; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tangent about nested attrsets in this file
I see this is following the pattern of the rest of the imports in this file; in other files, I would have expected
lib.recurseIntoAttrsto make the set of tests here built and eval'd by CI.I don't really understand @roberth's change #191540 that introduced this stanza which deals with that...
nixpkgs/nixos/tests/all-tests.nix
Lines 113 to 125 in f991670