-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make the nix development compatible with flake-less nix
- Loading branch information
1 parent
84c0c36
commit 69a47fd
Showing
7 changed files
with
132 additions
and
111 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,31 @@ | ||
{ | ||
description = "Agda2hs"; | ||
|
||
inputs.nixpkgs.url = github:NixOS/nixpkgs; | ||
inputs.flake-utils.url = github:numtide/flake-utils; | ||
inputs.nixpkgs.url = "github:NixOS/nixpkgs"; | ||
inputs.flake-utils.url = "github:numtide/flake-utils"; | ||
|
||
outputs = {self, nixpkgs, flake-utils}: | ||
flake-utils.lib.eachDefaultSystem (system: | ||
outputs = | ||
{ | ||
self, | ||
nixpkgs, | ||
flake-utils, | ||
}: | ||
flake-utils.lib.eachDefaultSystem ( | ||
system: | ||
let | ||
pkgs = import nixpkgs {inherit system;}; | ||
|
||
agda2hs-lib = pkgs.agdaPackages.mkDerivation | ||
{ pname = "agda2hs"; | ||
meta = {}; | ||
version = "1.3"; | ||
preBuild = '' | ||
echo "{-# OPTIONS --sized-types #-}" > Everything.agda | ||
echo "module Everything where" >> Everything.agda | ||
find lib -name '*.agda' | sed -e 's/lib\///;s/\//./g;s/\.agda$//;s/^/import /' >> Everything.agda | ||
''; | ||
src = ./.; | ||
}; | ||
# options provides a way to jailbreak for packages that use agda2hs | ||
agda2hs-pkg = options: | ||
pkgs.haskellPackages.haskellSrc2nix { | ||
name = "agda2hs"; | ||
src = ./.; | ||
extraCabal2nixOptions = options; #"--jailbreak" | ||
}; | ||
agda2hs-hs = pkgs.haskellPackages.callPackage (agda2hs-pkg "") {}; | ||
agda2hs-expr = import ./agda2hs.nix; | ||
agda2hs = pkgs.callPackage agda2hs-expr { | ||
inherit self; | ||
agda2hs = agda2hs-hs; | ||
inherit (pkgs.haskellPackages) ghcWithPackages; | ||
}; | ||
in { | ||
packages = { | ||
inherit agda2hs-lib; | ||
inherit (agda2hs) agda2hs; | ||
default = agda2hs.agda2hs; | ||
}; | ||
lib = { | ||
inherit (agda2hs) withPackages; | ||
inherit agda2hs-pkg agda2hs-hs agda2hs-expr; | ||
pkgs = import nixpkgs { inherit system; }; | ||
packages = import ./nix/default.nix { inherit pkgs; }; | ||
lib = import ./nix/lib.nix { inherit pkgs; }; | ||
in | ||
{ | ||
packages = packages // { | ||
default = packages.agda2hs; | ||
}; | ||
devShells.default = pkgs.haskellPackages.shellFor { | ||
packages = p: [agda2hs-hs]; | ||
buildInputs = with pkgs.haskellPackages; [ | ||
cabal-install | ||
cabal2nix | ||
haskell-language-server | ||
pkgs.agda | ||
]; | ||
inherit lib; | ||
devShells.default = import ./nix/shell.nix { | ||
inherit pkgs; | ||
inherit (lib) agda2hs-hs; | ||
}; | ||
}); | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
{ | ||
stdenv, | ||
lib, | ||
self, | ||
agda2hs, | ||
runCommandNoCC, | ||
makeWrapper, | ||
writeText, | ||
mkShell, | ||
ghcWithPackages, | ||
}: | ||
with lib.strings; | ||
let | ||
withPackages' = | ||
{ | ||
pkgs, | ||
ghc ? ghcWithPackages (p: with p; [ ieee754 ]), | ||
}: | ||
let | ||
pkgs' = if builtins.isList pkgs then pkgs else pkgs self; | ||
library-file = writeText "libraries" '' | ||
${(concatMapStringsSep "\n" (p: "${p}/${p.libraryFile}") pkgs')} | ||
''; | ||
pname = "agda2hsWithPackages"; | ||
version = agda2hs.version; | ||
in | ||
runCommandNoCC "${pname}-${version}" | ||
{ | ||
inherit pname version; | ||
nativeBuildInputs = [ makeWrapper ]; | ||
passthru.unwrapped = agda2hs; | ||
} | ||
'' | ||
mkdir -p $out/bin | ||
makeWrapper ${agda2hs}/bin/agda2hs $out/bin/agda2hs \ | ||
--add-flags "--with-compiler=${ghc}/bin/ghc" \ | ||
--add-flags "--library-file=${library-file}" \ | ||
--add-flags "--local-interfaces" | ||
''; # 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; }; | ||
in | ||
{ | ||
inherit withPackages; | ||
agda2hs = withPackages [ ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
pkgs ? import <nixpkgs> { }, | ||
... | ||
}: | ||
let | ||
lib = import ./lib.nix { inherit pkgs; }; | ||
version = "1.3"; | ||
agdalib = pkgs.agdaPackages.mkDerivation { | ||
pname = "agda2hs"; | ||
meta = { }; | ||
version = version; | ||
preBuild = '' | ||
echo "{-# OPTIONS --sized-types #-}" > Everything.agda | ||
echo "module Everything where" >> Everything.agda | ||
find lib -name '*.agda' | sed -e 's/lib\///;s/\//./g;s/\.agda$//;s/^/import /' >> Everything.agda | ||
''; | ||
src = ../.; | ||
}; | ||
in | ||
{ | ||
inherit (lib) agda2hs; | ||
agda2hs-lib = agdalib; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
pkgs ? import <nixpkgs> { }, | ||
... | ||
}: | ||
let | ||
hsrc = | ||
options: | ||
pkgs.haskellPackages.haskellSrc2nix { | ||
name = "agda2hs"; | ||
src = ../.; | ||
extraCabal2nixOptions = options; # "--jailbreak" | ||
}; | ||
hpkg = pkgs.haskellPackages.callPackage (hsrc "") { }; | ||
expr = import ./agda2hs.nix; | ||
agda2hs = pkgs.lib.makeScope pkgs.newScope ( | ||
self: | ||
pkgs.callPackage expr { | ||
agda2hs = hpkg; | ||
inherit self; | ||
inherit (pkgs.haskellPackages) ghcWithPackages; | ||
} | ||
); | ||
in | ||
{ | ||
agda2hs-pkg = hsrc; | ||
agda2hs-hs = hpkg; | ||
agda2hs-expr = expr; | ||
inherit (agda2hs) agda2hs withPackages; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ pkgs, agda2hs-hs }: | ||
pkgs.haskellPackages.shellFor { | ||
packages = p: [ agda2hs-hs ]; | ||
buildInputs = with pkgs.haskellPackages; [ | ||
cabal-install | ||
cabal2nix | ||
haskell-language-server | ||
pkgs.agda | ||
]; | ||
} |