Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 23 additions & 49 deletions flake.nix
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;
};
});
}
);
}
3 changes: 3 additions & 0 deletions agda2hs.nix → nix/agda2hs.nix
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# this file should be very close to a copy of nixpkgs/pkgs/build-support/agda/default.nix
# I think I took the version from https://github.com/NixOS/nixpkgs/blob/bbe6402ecacfc3a0e2c65e3527c2cbe148b98ff8/pkgs/build-support/agda/default.nix
# but it would be nice to expose this in upstream so that we don't have to duplicate the file
{stdenv, lib, self, agda2hs, runCommandNoCC, makeWrapper, writeText, mkShell, ghcWithPackages}:
with lib.strings;
let
Expand Down
23 changes: 23 additions & 0 deletions nix/default.nix
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;
}
29 changes: 29 additions & 0 deletions nix/lib.nix
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;
}
10 changes: 10 additions & 0 deletions nix/shell.nix
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
];
}
33 changes: 0 additions & 33 deletions shell.nix

This file was deleted.

Loading