├── .gitignore ├── LICENSE ├── README.md ├── default.nix ├── example-shell.nix ├── example.idr ├── example.nix └── idris_plain ├── default.nix └── wrapper.nix /.gitignore: -------------------------------------------------------------------------------- 1 | example 2 | example.ibc 3 | result 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Brian McKenna 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # idrispkgs 2 | 3 | Nix expressions for building Idris projects, with dependencies. 4 | 5 | ## Examples 6 | 7 | To build the example project: 8 | 9 | ```sh 10 | $ nix-build example.nix 11 | /nix/store/ijih1bxcaqzi8fi0kmj0rd1dk637aa6y-idris-nix-example 12 | ``` 13 | 14 | You can run the example with: 15 | 16 | ```sh 17 | $ /nix/store/ijih1bxcaqzi8fi0kmj0rd1dk637aa6y-idris-nix-example/bin/idris-nix-example 18 | [1, 2, 3, {}] 19 | ``` 20 | 21 | Or you can enter the example shell which will put libraries in the right place: 22 | 23 | ```sh 24 | $ nix-shell example-shell.nix 25 | $$ idris -p config example.idr 26 | ____ __ _ 27 | / _/___/ /____(_)____ 28 | / // __ / ___/ / ___/ Version 0.9.16-git:PRE 29 | _/ // /_/ / / / (__ ) http://www.idris-lang.org/ 30 | /___/\__,_/_/ /_/____/ Type :? for help 31 | 32 | Idris is free software with ABSOLUTELY NO WARRANTY. 33 | For details type :warranty. 34 | Type checking ./example.idr 35 | *example> 36 | ``` 37 | -------------------------------------------------------------------------------- /default.nix: -------------------------------------------------------------------------------- 1 | { nixpkgs ? import {} 2 | , idris_plain ? nixpkgs.haskellPackages.callPackage ./idris_plain {} 3 | }: 4 | 5 | with nixpkgs; 6 | 7 | let 8 | libraryDirectory = "${idris_plain.system}-ghc-${idris_plain.ghc.version}/${idris_plain.fname}"; 9 | in 10 | rec { 11 | mkDerivation = { pname, version, buildDepends, src, buildInputs ? [] }: 12 | let wrappedIdris = idrisWithPackages buildDepends; 13 | in stdenv.mkDerivation { 14 | name = "${pname}-${version}"; 15 | inherit src buildInputs; 16 | dontUseCmakeConfigure = true; 17 | LANG = "en_US.UTF-8"; 18 | LOCALE_ARCHIVE = "${glibcLocales}/lib/locale/locale-archive"; 19 | buildPhase = '' 20 | export TARGET="$out" 21 | ${wrappedIdris}/bin/idris --build ${pname}.ipkg 22 | ''; 23 | installPhase = '' 24 | ${wrappedIdris}/bin/idris --install ${pname}.ipkg 25 | ''; 26 | }; 27 | 28 | idrisWithPackages = pkgs: callPackage ./idris_plain/wrapper.nix { 29 | idris_plain = idris_plain; 30 | idrisLibraryPath = symlinkJoin "idris-env" ([ 31 | "${idris_plain}/share/${libraryDirectory}" 32 | ] ++ pkgs); 33 | }; 34 | 35 | lightyear = mkDerivation rec { 36 | pname = "lightyear"; 37 | version = "496c0d8e08213d6f9b6005d41e4bf5a5cf8b0a8e"; 38 | src = fetchFromGitHub { 39 | owner = "jfdm"; 40 | repo = "lightyear"; 41 | rev = version; 42 | sha256 = "0k84i336r9z2a2ikcsrm49k5rwbi57y46si8jvj194rhyjpsxzf1"; 43 | }; 44 | buildDepends = []; 45 | }; 46 | idris-commonmark = mkDerivation rec { 47 | pname = "commonmark"; 48 | version = "31b7bb562a97fe9fefbeb4c7129d050b81b408e2"; 49 | src = fetchgit { 50 | url = "https://github.com/soimort/idris-commonmark.git"; 51 | rev = version; 52 | sha256 = "07caakdjv14gl831586zlpm5ysnajgpr24j94bv7hkcsn9snnk9p"; 53 | }; 54 | buildInputs = [ re2c ]; 55 | buildDepends = [ ]; 56 | }; 57 | idris-config = mkDerivation rec { 58 | pname = "config"; 59 | version = "ce53685e4a5db7618946f81a945f3bd73b7cccee"; 60 | src = fetchFromGitHub { 61 | owner = "jfdm"; 62 | repo = "idris-config"; 63 | rev = version; 64 | sha256 = "00rzp2adh6s6ra5p7vz91afn6ax2hzx84q1d72vi9mj4d5wxy8hj"; 65 | }; 66 | buildDepends = [ lightyear ]; 67 | }; 68 | idris-lens = mkDerivation rec { 69 | pname = "lens"; 70 | version = "3897a3a671b5622c79eea680f1b2261da4c53c22"; 71 | src = fetchFromGitHub { 72 | owner = "idris-hackers"; 73 | repo = "idris-lens"; 74 | rev = version; 75 | sha256 = "13zifzdj1z4yaz8kxcnxrpls86ryh7nwr0rrvd570cqfqgdhnxj7"; 76 | }; 77 | buildDepends = [ ]; 78 | }; 79 | idris-posix = mkDerivation rec { 80 | pname = "posix"; 81 | version = "18e1badad2d084186e0cd418cc3b01cd5a72000b"; 82 | src = fetchFromGitHub { 83 | owner = "idris-hackers"; 84 | repo = "idris-posix"; 85 | rev = version; 86 | sha256 = "0k8lzm767swcm3hp4fgi644bjbb4lx9q2llpf9gjdp7qbdrk2ysf"; 87 | }; 88 | buildDepends = [ ]; 89 | }; 90 | quantities = mkDerivation rec { 91 | pname = "quantities"; 92 | version = "f0e3cbb010843c7c46768953328579c7e62330be"; 93 | src = fetchFromGitHub { 94 | owner = "timjb"; 95 | repo = "quantities"; 96 | rev = version; 97 | sha256 = "1rz259mln5387akcbv5fgss69fiaiihgk9ja4k6s1w8dhsfza6bl"; 98 | }; 99 | buildDepends = [ ]; 100 | }; 101 | } 102 | -------------------------------------------------------------------------------- /example-shell.nix: -------------------------------------------------------------------------------- 1 | with import { }; 2 | with import ./default.nix { }; 3 | 4 | runCommand "dummy" { 5 | buildInputs = [ 6 | (idrisWithPackages [ idris-config ]) 7 | ]; 8 | } "" 9 | -------------------------------------------------------------------------------- /example.idr: -------------------------------------------------------------------------------- 1 | import Config.JSON 2 | 3 | main : IO () 4 | main = case parse parseJSONFile "[1, 2, 3 , {}]" of 5 | Left l => putStrLn l 6 | Right r => print r 7 | -------------------------------------------------------------------------------- /example.nix: -------------------------------------------------------------------------------- 1 | with import { }; 2 | with import ./default.nix { }; 3 | 4 | let myIdris = idrisWithPackages [ idris-config ]; 5 | in 6 | stdenv.mkDerivation { 7 | name = "idris-nix-example"; 8 | src = ./example.idr; 9 | buildCommand = '' 10 | mkdir -p $out/bin 11 | ${myIdris}/bin/idris -p config -o $out/bin/idris-nix-example $src 12 | ''; 13 | } 14 | -------------------------------------------------------------------------------- /idris_plain/default.nix: -------------------------------------------------------------------------------- 1 | { cabal, annotatedWlPprint, ansiTerminal, ansiWlPprint 2 | , base64Bytestring, binary, blazeHtml, blazeMarkup, boehmgc 3 | , cheapskate, deepseq, filepath, fingertree, gmp, happy, haskeline 4 | , lens, libffi, mtl, network, optparseApplicative, parsers, safe 5 | , split, text, time, transformers, trifecta, unorderedContainers 6 | , utf8String, vector, vectorBinaryInstances, xml, zlib 7 | , fetchFromGitHub 8 | }: 9 | 10 | cabal.mkDerivation (self: { 11 | pname = "idris"; 12 | src = fetchFromGitHub { 13 | owner = "puffnfresh"; 14 | repo = "Idris-dev"; 15 | rev = "dd5bd6f6643aac20dd1d872a49e1e02ba2873721"; 16 | sha256 = "1ilbdyyv8xvxdmawlx3jn2wvb44b97lr3ns9czqz1dw5jd23g97m"; 17 | }; 18 | enableSharedExecutables = false; 19 | version = "0.9.17"; 20 | isLibrary = true; 21 | isExecutable = true; 22 | buildDepends = [ 23 | annotatedWlPprint ansiTerminal ansiWlPprint base64Bytestring binary 24 | blazeHtml blazeMarkup cheapskate deepseq filepath fingertree 25 | haskeline lens libffi mtl network optparseApplicative parsers safe 26 | split text time transformers trifecta unorderedContainers 27 | utf8String vector vectorBinaryInstances xml zlib 28 | ]; 29 | buildTools = [ happy ]; 30 | extraLibraries = [ boehmgc gmp ]; 31 | configureFlags = "-fgmp -fffi"; 32 | jailbreak = true; 33 | meta = { 34 | homepage = "http://www.idris-lang.org/"; 35 | description = "Functional Programming Language with Dependent Types"; 36 | license = self.stdenv.lib.licenses.bsd3; 37 | platforms = self.ghc.meta.platforms; 38 | }; 39 | }) 40 | -------------------------------------------------------------------------------- /idris_plain/wrapper.nix: -------------------------------------------------------------------------------- 1 | { stdenv, gmp, makeWrapper, runCommand, idris_plain, boehmgc, idrisLibraryPath }: 2 | 3 | runCommand "idris-wrapper" {} '' 4 | source ${makeWrapper}/nix-support/setup-hook 5 | mkdir -p $out/bin 6 | ln -s ${idris_plain}/bin/idris $out/bin 7 | wrapProgram $out/bin/idris \ 8 | --set IDRIS_LIBRARY_PATH ${idrisLibraryPath} \ 9 | --suffix NIX_CFLAGS_COMPILE : '"-I${gmp}/include -L${gmp}/lib -L${boehmgc}/lib"' \ 10 | --suffix PATH : ${stdenv.cc}/bin \ 11 | --suffix PATH : ${idris_plain}/bin 12 | '' 13 | --------------------------------------------------------------------------------