From 2241787153e1473efe73d497b7ce44d3b7d6c9ab Mon Sep 17 00:00:00 2001 From: Kangjing Huang Date: Thu, 18 Jul 2024 23:31:21 -0400 Subject: [PATCH 01/17] Add nix packaging files --- flake.nix | 41 +++++++++++++++++++++++++++++++++++++++++ nix/hix.nix | 19 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 flake.nix create mode 100644 nix/hix.nix diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..b53de5db --- /dev/null +++ b/flake.nix @@ -0,0 +1,41 @@ +{ + inputs.haskellNix.url = "github:input-output-hk/haskell.nix"; + inputs.nixpkgs.follows = "haskellNix/nixpkgs-unstable"; + inputs.flake-utils.url = "github:numtide/flake-utils"; + outputs = { self, nixpkgs, flake-utils, haskellNix }: + let + supportedSystems = [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-linux" + "aarch64-darwin" + ]; + in + flake-utils.lib.eachSystem supportedSystems (system: + let + overlays = [ haskellNix.overlay + (final: _prev: { + bnfc = + final.haskell-nix.hix.project { + src = ./.; + # uncomment with your current system for `nix flake show` to work: + #evalSystem = "x86_64-linux"; + }; + }) + ]; + pkgs = import nixpkgs { inherit system overlays; inherit (haskellNix) config; }; + flake = pkgs.bnfc.flake {}; + in flake // { + legacyPackages = pkgs; + }); + + # --- Flake Local Nix Configuration ---------------------------- + nixConfig = { + # This sets the flake to use the IOG nix cache. + # Nix should ask for permission before using it, + # but remove it here if you do not want it to. + extra-substituters = ["https://cache.iog.io"]; + extra-trusted-public-keys = ["hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="]; + allow-import-from-derivation = "true"; + }; +} diff --git a/nix/hix.nix b/nix/hix.nix new file mode 100644 index 00000000..95cc2746 --- /dev/null +++ b/nix/hix.nix @@ -0,0 +1,19 @@ +{pkgs, ...}: { + # name = "project-name"; + compiler-nix-name = "ghc982"; # Version of GHC to use + + # Cross compilation support: + # crossPlatforms = p: pkgs.lib.optionals pkgs.stdenv.hostPlatform.isx86_64 ([ + # p.mingwW64 + # p.ghcjs + # ] ++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux [ + # p.musl64 + # ]); + + # Tools to include in the development shell + shell.tools = { + cabal = "latest"; + hlint = "latest"; + haskell-language-server = "lastest"; + }; +} From 8f5ae10d03e01335a8e91e9da83a292a284ac450 Mon Sep 17 00:00:00 2001 From: Kangjing Huang Date: Thu, 18 Jul 2024 23:41:21 -0400 Subject: [PATCH 02/17] Flake-based nix packaging --- flake.lock | 707 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 13 +- 2 files changed, 717 insertions(+), 3 deletions(-) create mode 100644 flake.lock diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..9fb2a39b --- /dev/null +++ b/flake.lock @@ -0,0 +1,707 @@ +{ + "nodes": { + "HTTP": { + "flake": false, + "locked": { + "lastModified": 1451647621, + "narHash": "sha256-oHIyw3x0iKBexEo49YeUDV1k74ZtyYKGR2gNJXXRxts=", + "owner": "phadej", + "repo": "HTTP", + "rev": "9bc0996d412fef1787449d841277ef663ad9a915", + "type": "github" + }, + "original": { + "owner": "phadej", + "repo": "HTTP", + "type": "github" + } + }, + "cabal-32": { + "flake": false, + "locked": { + "lastModified": 1603716527, + "narHash": "sha256-X0TFfdD4KZpwl0Zr6x+PLxUt/VyKQfX7ylXHdmZIL+w=", + "owner": "haskell", + "repo": "cabal", + "rev": "48bf10787e27364730dd37a42b603cee8d6af7ee", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "3.2", + "repo": "cabal", + "type": "github" + } + }, + "cabal-34": { + "flake": false, + "locked": { + "lastModified": 1645834128, + "narHash": "sha256-wG3d+dOt14z8+ydz4SL7pwGfe7SiimxcD/LOuPCV6xM=", + "owner": "haskell", + "repo": "cabal", + "rev": "5ff598c67f53f7c4f48e31d722ba37172230c462", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "3.4", + "repo": "cabal", + "type": "github" + } + }, + "cabal-36": { + "flake": false, + "locked": { + "lastModified": 1669081697, + "narHash": "sha256-I5or+V7LZvMxfbYgZATU4awzkicBwwok4mVoje+sGmU=", + "owner": "haskell", + "repo": "cabal", + "rev": "8fd619e33d34924a94e691c5fea2c42f0fc7f144", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "3.6", + "repo": "cabal", + "type": "github" + } + }, + "cardano-shell": { + "flake": false, + "locked": { + "lastModified": 1608537748, + "narHash": "sha256-PulY1GfiMgKVnBci3ex4ptk2UNYMXqGjJOxcPy2KYT4=", + "owner": "input-output-hk", + "repo": "cardano-shell", + "rev": "9392c75087cb9a3d453998f4230930dea3a95725", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "cardano-shell", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1672831974, + "narHash": "sha256-z9k3MfslLjWQfnjBtEtJZdq3H7kyi2kQtUThfTgdRk0=", + "owner": "input-output-hk", + "repo": "flake-compat", + "rev": "45f2638735f8cdc40fe302742b79f248d23eb368", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "ref": "hkm/gitlab-fix", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "ghc-8.6.5-iohk": { + "flake": false, + "locked": { + "lastModified": 1600920045, + "narHash": "sha256-DO6kxJz248djebZLpSzTGD6s8WRpNI9BTwUeOf5RwY8=", + "owner": "input-output-hk", + "repo": "ghc", + "rev": "95713a6ecce4551240da7c96b6176f980af75cae", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "ref": "release/8.6.5-iohk", + "repo": "ghc", + "type": "github" + } + }, + "hackage": { + "flake": false, + "locked": { + "lastModified": 1721263615, + "narHash": "sha256-J/VaA4xWMpp43HptVP2tpfLwIYCg+OrBova4Uh5R8C8=", + "owner": "input-output-hk", + "repo": "hackage.nix", + "rev": "beaee455c56dee413b33f89f6ebd0520ff435295", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "hackage.nix", + "type": "github" + } + }, + "haskellNix": { + "inputs": { + "HTTP": "HTTP", + "cabal-32": "cabal-32", + "cabal-34": "cabal-34", + "cabal-36": "cabal-36", + "cardano-shell": "cardano-shell", + "flake-compat": "flake-compat", + "ghc-8.6.5-iohk": "ghc-8.6.5-iohk", + "hackage": "hackage", + "hls-1.10": "hls-1.10", + "hls-2.0": "hls-2.0", + "hls-2.2": "hls-2.2", + "hls-2.3": "hls-2.3", + "hls-2.4": "hls-2.4", + "hls-2.5": "hls-2.5", + "hls-2.6": "hls-2.6", + "hls-2.7": "hls-2.7", + "hls-2.8": "hls-2.8", + "hls-2.9": "hls-2.9", + "hpc-coveralls": "hpc-coveralls", + "hydra": "hydra", + "iserv-proxy": "iserv-proxy", + "nixpkgs": [ + "haskellNix", + "nixpkgs-unstable" + ], + "nixpkgs-2003": "nixpkgs-2003", + "nixpkgs-2105": "nixpkgs-2105", + "nixpkgs-2111": "nixpkgs-2111", + "nixpkgs-2205": "nixpkgs-2205", + "nixpkgs-2211": "nixpkgs-2211", + "nixpkgs-2305": "nixpkgs-2305", + "nixpkgs-2311": "nixpkgs-2311", + "nixpkgs-2405": "nixpkgs-2405", + "nixpkgs-unstable": "nixpkgs-unstable", + "old-ghc-nix": "old-ghc-nix", + "stackage": "stackage" + }, + "locked": { + "lastModified": 1721263838, + "narHash": "sha256-ZFcyUXcxU9k5tkv/t5deuQ8PRY0Q0/uk8MLHUb2eXEs=", + "owner": "input-output-hk", + "repo": "haskell.nix", + "rev": "7bcd019c70e1929d733ed0bf5349c747ce0ee66a", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "haskell.nix", + "type": "github" + } + }, + "hls-1.10": { + "flake": false, + "locked": { + "lastModified": 1680000865, + "narHash": "sha256-rc7iiUAcrHxwRM/s0ErEsSPxOR3u8t7DvFeWlMycWgo=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "b08691db779f7a35ff322b71e72a12f6e3376fd9", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "1.10.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.0": { + "flake": false, + "locked": { + "lastModified": 1687698105, + "narHash": "sha256-OHXlgRzs/kuJH8q7Sxh507H+0Rb8b7VOiPAjcY9sM1k=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "783905f211ac63edf982dd1889c671653327e441", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.0.0.1", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.2": { + "flake": false, + "locked": { + "lastModified": 1693064058, + "narHash": "sha256-8DGIyz5GjuCFmohY6Fa79hHA/p1iIqubfJUTGQElbNk=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "b30f4b6cf5822f3112c35d14a0cba51f3fe23b85", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.2.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.3": { + "flake": false, + "locked": { + "lastModified": 1695910642, + "narHash": "sha256-tR58doOs3DncFehHwCLczJgntyG/zlsSd7DgDgMPOkI=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "458ccdb55c9ea22cd5d13ec3051aaefb295321be", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.3.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.4": { + "flake": false, + "locked": { + "lastModified": 1699862708, + "narHash": "sha256-YHXSkdz53zd0fYGIYOgLt6HrA0eaRJi9mXVqDgmvrjk=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "54507ef7e85fa8e9d0eb9a669832a3287ffccd57", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.4.0.1", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.5": { + "flake": false, + "locked": { + "lastModified": 1701080174, + "narHash": "sha256-fyiR9TaHGJIIR0UmcCb73Xv9TJq3ht2ioxQ2mT7kVdc=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "27f8c3d3892e38edaef5bea3870161815c4d014c", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.5.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.6": { + "flake": false, + "locked": { + "lastModified": 1705325287, + "narHash": "sha256-+P87oLdlPyMw8Mgoul7HMWdEvWP/fNlo8jyNtwME8E8=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "6e0b342fa0327e628610f2711f8c3e4eaaa08b1e", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.6.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.7": { + "flake": false, + "locked": { + "lastModified": 1708965829, + "narHash": "sha256-LfJ+TBcBFq/XKoiNI7pc4VoHg4WmuzsFxYJ3Fu+Jf+M=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "50322b0a4aefb27adc5ec42f5055aaa8f8e38001", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.7.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.8": { + "flake": false, + "locked": { + "lastModified": 1715153580, + "narHash": "sha256-Vi/iUt2pWyUJlo9VrYgTcbRviWE0cFO6rmGi9rmALw0=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "dd1be1beb16700de59e0d6801957290bcf956a0a", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.8.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.9": { + "flake": false, + "locked": { + "lastModified": 1718469202, + "narHash": "sha256-THXSz+iwB1yQQsr/PY151+2GvtoJnTIB2pIQ4OzfjD4=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "40891bccb235ebacce020b598b083eab9dda80f1", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.9.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hpc-coveralls": { + "flake": false, + "locked": { + "lastModified": 1607498076, + "narHash": "sha256-8uqsEtivphgZWYeUo5RDUhp6bO9j2vaaProQxHBltQk=", + "owner": "sevanspowell", + "repo": "hpc-coveralls", + "rev": "14df0f7d229f4cd2e79f8eabb1a740097fdfa430", + "type": "github" + }, + "original": { + "owner": "sevanspowell", + "repo": "hpc-coveralls", + "type": "github" + } + }, + "hydra": { + "inputs": { + "nix": "nix", + "nixpkgs": [ + "haskellNix", + "hydra", + "nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1671755331, + "narHash": "sha256-hXsgJj0Cy0ZiCiYdW2OdBz5WmFyOMKuw4zyxKpgUKm4=", + "owner": "NixOS", + "repo": "hydra", + "rev": "f48f00ee6d5727ae3e488cbf9ce157460853fea8", + "type": "github" + }, + "original": { + "id": "hydra", + "type": "indirect" + } + }, + "iserv-proxy": { + "flake": false, + "locked": { + "lastModified": 1717479972, + "narHash": "sha256-7vE3RQycHI1YT9LHJ1/fUaeln2vIpYm6Mmn8FTpYeVo=", + "owner": "stable-haskell", + "repo": "iserv-proxy", + "rev": "2ed34002247213fc435d0062350b91bab920626e", + "type": "github" + }, + "original": { + "owner": "stable-haskell", + "ref": "iserv-syms", + "repo": "iserv-proxy", + "type": "github" + } + }, + "lowdown-src": { + "flake": false, + "locked": { + "lastModified": 1633514407, + "narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=", + "owner": "kristapsdz", + "repo": "lowdown", + "rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8", + "type": "github" + }, + "original": { + "owner": "kristapsdz", + "repo": "lowdown", + "type": "github" + } + }, + "nix": { + "inputs": { + "lowdown-src": "lowdown-src", + "nixpkgs": "nixpkgs", + "nixpkgs-regression": "nixpkgs-regression" + }, + "locked": { + "lastModified": 1661606874, + "narHash": "sha256-9+rpYzI+SmxJn+EbYxjGv68Ucp22bdFUSy/4LkHkkDQ=", + "owner": "NixOS", + "repo": "nix", + "rev": "11e45768b34fdafdcf019ddbd337afa16127ff0f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "2.11.0", + "repo": "nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1657693803, + "narHash": "sha256-G++2CJ9u0E7NNTAi9n5G8TdDmGJXcIjkJ3NF8cetQB8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "365e1b3a859281cf11b94f87231adeabbdd878a2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-22.05-small", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2003": { + "locked": { + "lastModified": 1620055814, + "narHash": "sha256-8LEHoYSJiL901bTMVatq+rf8y7QtWuZhwwpKE2fyaRY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1db42b7fe3878f3f5f7a4f2dc210772fd080e205", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-20.03-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2105": { + "locked": { + "lastModified": 1659914493, + "narHash": "sha256-lkA5X3VNMKirvA+SUzvEhfA7XquWLci+CGi505YFAIs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "022caabb5f2265ad4006c1fa5b1ebe69fb0c3faf", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-21.05-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2111": { + "locked": { + "lastModified": 1659446231, + "narHash": "sha256-hekabNdTdgR/iLsgce5TGWmfIDZ86qjPhxDg/8TlzhE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "eabc38219184cc3e04a974fe31857d8e0eac098d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-21.11-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2205": { + "locked": { + "lastModified": 1685573264, + "narHash": "sha256-Zffu01pONhs/pqH07cjlF10NnMDLok8ix5Uk4rhOnZQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "380be19fbd2d9079f677978361792cb25e8a3635", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-22.05-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2211": { + "locked": { + "lastModified": 1688392541, + "narHash": "sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-22.11-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2305": { + "locked": { + "lastModified": 1705033721, + "narHash": "sha256-K5eJHmL1/kev6WuqyqqbS1cdNnSidIZ3jeqJ7GbrYnQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a1982c92d8980a0114372973cbdfe0a307f1bdea", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-23.05-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2311": { + "locked": { + "lastModified": 1719957072, + "narHash": "sha256-gvFhEf5nszouwLAkT9nWsDzocUTqLWHuL++dvNjMp9I=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "7144d6241f02d171d25fba3edeaf15e0f2592105", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-23.11-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2405": { + "locked": { + "lastModified": 1720122915, + "narHash": "sha256-Nby8WWxj0elBu1xuRaUcRjPi/rU3xVbkAt2kj4QwX2U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "835cf2d3f37989c5db6585a28de967a667a75fb1", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-24.05-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-regression": { + "locked": { + "lastModified": 1643052045, + "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1720181791, + "narHash": "sha256-i4vJL12/AdyuQuviMMd1Hk2tsGt02hDNhA0Zj1m16N8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4284c2b73c8bce4b46a6adf23e16d9e2ec8da4bb", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "old-ghc-nix": { + "flake": false, + "locked": { + "lastModified": 1631092763, + "narHash": "sha256-sIKgO+z7tj4lw3u6oBZxqIhDrzSkvpHtv0Kki+lh9Fg=", + "owner": "angerman", + "repo": "old-ghc-nix", + "rev": "af48a7a7353e418119b6dfe3cd1463a657f342b8", + "type": "github" + }, + "original": { + "owner": "angerman", + "ref": "master", + "repo": "old-ghc-nix", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "haskellNix": "haskellNix", + "nixpkgs": [ + "haskellNix", + "nixpkgs-unstable" + ] + } + }, + "stackage": { + "flake": false, + "locked": { + "lastModified": 1721262189, + "narHash": "sha256-FhQK+UGKGBJCyLo8NBhU65QKm5loHS/APUKno/9jO/U=", + "owner": "input-output-hk", + "repo": "stackage.nix", + "rev": "a55d366b4ab71687ce60d428a775a4ecc824a658", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "stackage.nix", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix index b53de5db..05c1f67c 100644 --- a/flake.nix +++ b/flake.nix @@ -5,6 +5,7 @@ outputs = { self, nixpkgs, flake-utils, haskellNix }: let supportedSystems = [ + # Note: Only Linux on x6_64 is tested to work for now "x86_64-linux" "x86_64-darwin" "aarch64-linux" @@ -15,18 +16,24 @@ let overlays = [ haskellNix.overlay (final: _prev: { - bnfc = + bnfc-project = final.haskell-nix.hix.project { src = ./.; # uncomment with your current system for `nix flake show` to work: - #evalSystem = "x86_64-linux"; + evalSystem = "x86_64-linux"; }; }) ]; pkgs = import nixpkgs { inherit system overlays; inherit (haskellNix) config; }; - flake = pkgs.bnfc.flake {}; + flake = pkgs.bnfc-project.flake {}; in flake // { legacyPackages = pkgs; + apps.default = flake.apps."BNFC:exe:bnfc"; + packages = rec { + bnfc = flake.packages."BNFC:exe:bnfc"; + default = bnfc; + libBNFC = flake.packages."BNFC:lib:BNFC"; + }; }); # --- Flake Local Nix Configuration ---------------------------- From 15505bcde2991b9568217a7b0c71ef81d254f11e Mon Sep 17 00:00:00 2001 From: Kangjing Huang Date: Thu, 18 Jul 2024 23:45:19 -0400 Subject: [PATCH 03/17] Add non-flake compatibility layer for nix --- default.nix | 10 ++++++++++ flake.lock | 17 ++++++++++++++++- flake.nix | 3 ++- shell.nix | 10 ++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 default.nix create mode 100644 shell.nix diff --git a/default.nix b/default.nix new file mode 100644 index 00000000..71330e43 --- /dev/null +++ b/default.nix @@ -0,0 +1,10 @@ +(import + ( + let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in + fetchTarball { + url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } + ) + { src = ./.; } +).defaultNix \ No newline at end of file diff --git a/flake.lock b/flake.lock index 9fb2a39b..a40c83a2 100644 --- a/flake.lock +++ b/flake.lock @@ -84,6 +84,20 @@ } }, "flake-compat": { + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "revCount": 57, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" + } + }, + "flake-compat_2": { "flake": false, "locked": { "lastModified": 1672831974, @@ -158,7 +172,7 @@ "cabal-34": "cabal-34", "cabal-36": "cabal-36", "cardano-shell": "cardano-shell", - "flake-compat": "flake-compat", + "flake-compat": "flake-compat_2", "ghc-8.6.5-iohk": "ghc-8.6.5-iohk", "hackage": "hackage", "hls-1.10": "hls-1.10", @@ -662,6 +676,7 @@ }, "root": { "inputs": { + "flake-compat": "flake-compat", "flake-utils": "flake-utils", "haskellNix": "haskellNix", "nixpkgs": [ diff --git a/flake.nix b/flake.nix index 05c1f67c..b7c97cb1 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,8 @@ inputs.haskellNix.url = "github:input-output-hk/haskell.nix"; inputs.nixpkgs.follows = "haskellNix/nixpkgs-unstable"; inputs.flake-utils.url = "github:numtide/flake-utils"; - outputs = { self, nixpkgs, flake-utils, haskellNix }: + inputs.flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"; + outputs = { self, nixpkgs, flake-utils, haskellNix, ... }: let supportedSystems = [ # Note: Only Linux on x6_64 is tested to work for now diff --git a/shell.nix b/shell.nix new file mode 100644 index 00000000..64fbdb42 --- /dev/null +++ b/shell.nix @@ -0,0 +1,10 @@ +(import + ( + let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in + fetchTarball { + url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } + ) + { src = ./.; } +).shellNix \ No newline at end of file From 45a860114ac05367226ed40187a52f654acb4c7c Mon Sep 17 00:00:00 2001 From: Kangjing Huang Date: Fri, 19 Jul 2024 00:02:05 -0400 Subject: [PATCH 04/17] Try to put stack.yaml with a sub-dir --- flake.nix | 11 +++++++++-- nix/hix.nix | 19 ------------------- nix/stack.yaml | 11 +++++++++++ 3 files changed, 20 insertions(+), 21 deletions(-) delete mode 100644 nix/hix.nix create mode 100644 nix/stack.yaml diff --git a/flake.nix b/flake.nix index b7c97cb1..22a2417c 100644 --- a/flake.nix +++ b/flake.nix @@ -18,10 +18,17 @@ overlays = [ haskellNix.overlay (final: _prev: { bnfc-project = - final.haskell-nix.hix.project { - src = ./.; + final.haskell-nix.project' { + src = ./nix; + compiler-nix-name = "ghc982"; # Version of GHC to use # uncomment with your current system for `nix flake show` to work: evalSystem = "x86_64-linux"; + # Tools to include in the development shell + shell.tools = { + cabal = "latest"; + hlint = "latest"; + haskell-language-server = "lastest"; + }; }; }) ]; diff --git a/nix/hix.nix b/nix/hix.nix deleted file mode 100644 index 95cc2746..00000000 --- a/nix/hix.nix +++ /dev/null @@ -1,19 +0,0 @@ -{pkgs, ...}: { - # name = "project-name"; - compiler-nix-name = "ghc982"; # Version of GHC to use - - # Cross compilation support: - # crossPlatforms = p: pkgs.lib.optionals pkgs.stdenv.hostPlatform.isx86_64 ([ - # p.mingwW64 - # p.ghcjs - # ] ++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux [ - # p.musl64 - # ]); - - # Tools to include in the development shell - shell.tools = { - cabal = "latest"; - hlint = "latest"; - haskell-language-server = "lastest"; - }; -} diff --git a/nix/stack.yaml b/nix/stack.yaml new file mode 100644 index 00000000..b31cc9dc --- /dev/null +++ b/nix/stack.yaml @@ -0,0 +1,11 @@ +resolver: nightly-2024-05-30 +compiler: ghc-9.8.2 +compiler-check: newer-minor + +packages: +- ../source +- ../testing + +# extra-deps: +# - aeson-2.2.1.0 +# - th-abstraction-0.6.0.0 From 34ada9bf84260ddff1629e43778a46d49cf177e7 Mon Sep 17 00:00:00 2001 From: Kangjing Huang Date: Fri, 19 Jul 2024 00:02:48 -0400 Subject: [PATCH 05/17] Revert "Try to put stack.yaml with a sub-dir" Does not work, attempting other workarounds. This reverts commit 45a860114ac05367226ed40187a52f654acb4c7c. --- flake.nix | 11 ++--------- nix/hix.nix | 19 +++++++++++++++++++ nix/stack.yaml | 11 ----------- 3 files changed, 21 insertions(+), 20 deletions(-) create mode 100644 nix/hix.nix delete mode 100644 nix/stack.yaml diff --git a/flake.nix b/flake.nix index 22a2417c..b7c97cb1 100644 --- a/flake.nix +++ b/flake.nix @@ -18,17 +18,10 @@ overlays = [ haskellNix.overlay (final: _prev: { bnfc-project = - final.haskell-nix.project' { - src = ./nix; - compiler-nix-name = "ghc982"; # Version of GHC to use + final.haskell-nix.hix.project { + src = ./.; # uncomment with your current system for `nix flake show` to work: evalSystem = "x86_64-linux"; - # Tools to include in the development shell - shell.tools = { - cabal = "latest"; - hlint = "latest"; - haskell-language-server = "lastest"; - }; }; }) ]; diff --git a/nix/hix.nix b/nix/hix.nix new file mode 100644 index 00000000..95cc2746 --- /dev/null +++ b/nix/hix.nix @@ -0,0 +1,19 @@ +{pkgs, ...}: { + # name = "project-name"; + compiler-nix-name = "ghc982"; # Version of GHC to use + + # Cross compilation support: + # crossPlatforms = p: pkgs.lib.optionals pkgs.stdenv.hostPlatform.isx86_64 ([ + # p.mingwW64 + # p.ghcjs + # ] ++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux [ + # p.musl64 + # ]); + + # Tools to include in the development shell + shell.tools = { + cabal = "latest"; + hlint = "latest"; + haskell-language-server = "lastest"; + }; +} diff --git a/nix/stack.yaml b/nix/stack.yaml deleted file mode 100644 index b31cc9dc..00000000 --- a/nix/stack.yaml +++ /dev/null @@ -1,11 +0,0 @@ -resolver: nightly-2024-05-30 -compiler: ghc-9.8.2 -compiler-check: newer-minor - -packages: -- ../source -- ../testing - -# extra-deps: -# - aeson-2.2.1.0 -# - th-abstraction-0.6.0.0 From 860de52b97568d83238541bd41801d19149e6e1d Mon Sep 17 00:00:00 2001 From: Kangjing Huang Date: Fri, 19 Jul 2024 00:08:52 -0400 Subject: [PATCH 06/17] Use haskell.nix from main flake --- flake.nix | 14 ++++++++++++-- nix/hix.nix | 19 ------------------- 2 files changed, 12 insertions(+), 21 deletions(-) delete mode 100644 nix/hix.nix diff --git a/flake.nix b/flake.nix index b7c97cb1..8d3568f9 100644 --- a/flake.nix +++ b/flake.nix @@ -18,10 +18,20 @@ overlays = [ haskellNix.overlay (final: _prev: { bnfc-project = - final.haskell-nix.hix.project { + final.haskell-nix.project' { src = ./.; - # uncomment with your current system for `nix flake show` to work: + # name = "project-name"; + compiler-nix-name = "ghc982"; # Version of GHC to use + # Use the corresponding stack configuration as well + stackYaml = "stack-9.8.yaml"; + # put your current system for `nix flake show` to work: evalSystem = "x86_64-linux"; + # Tools to include in the development shell + shell.tools = { + cabal = "latest"; + hlint = "latest"; + haskell-language-server = "lastest"; + }; }; }) ]; diff --git a/nix/hix.nix b/nix/hix.nix deleted file mode 100644 index 95cc2746..00000000 --- a/nix/hix.nix +++ /dev/null @@ -1,19 +0,0 @@ -{pkgs, ...}: { - # name = "project-name"; - compiler-nix-name = "ghc982"; # Version of GHC to use - - # Cross compilation support: - # crossPlatforms = p: pkgs.lib.optionals pkgs.stdenv.hostPlatform.isx86_64 ([ - # p.mingwW64 - # p.ghcjs - # ] ++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux [ - # p.musl64 - # ]); - - # Tools to include in the development shell - shell.tools = { - cabal = "latest"; - hlint = "latest"; - haskell-language-server = "lastest"; - }; -} From 06da65c533fbef24d6e898a9d6120109249ec1ca Mon Sep 17 00:00:00 2001 From: Kangjing Huang Date: Fri, 19 Jul 2024 00:10:28 -0400 Subject: [PATCH 07/17] Use correct project type --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 8d3568f9..1964d362 100644 --- a/flake.nix +++ b/flake.nix @@ -18,7 +18,7 @@ overlays = [ haskellNix.overlay (final: _prev: { bnfc-project = - final.haskell-nix.project' { + final.haskell-nix.stackProject' { src = ./.; # name = "project-name"; compiler-nix-name = "ghc982"; # Version of GHC to use From 4356d6747fd26ae512496e9110bee7cf5647be13 Mon Sep 17 00:00:00 2001 From: Kangjing Huang Date: Fri, 19 Jul 2024 02:04:56 -0400 Subject: [PATCH 08/17] Support of different ghc versions in nix packaging --- flake.nix | 55 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/flake.nix b/flake.nix index 1964d362..c9b7013c 100644 --- a/flake.nix +++ b/flake.nix @@ -15,15 +15,29 @@ in flake-utils.lib.eachSystem supportedSystems (system: let + lib = nixpkgs.lib; + supportedGHCStackFile = { + # Haskell.nix does not support GHC versions older than 8.10 + # Note: only GHC 9.8.2 is tested to work for now + ghc8107 = "stack-8.10.yaml"; + ghc902 = "stack-9.0.yaml"; + ghc928 = "stack-9.2.yaml"; + ghc948 = "stack-9.4.yaml"; + ghc965 = "stack-9.6.yaml"; + ghc982 = "stack-9.8.yaml"; + }; + defaultVersion = "ghc982"; + overlays = [ haskellNix.overlay - (final: _prev: { - bnfc-project = - final.haskell-nix.stackProject' { + (final: _prev: lib.attrsets.mapAttrs' ( + name: value: { + name = "bnfc-project-${name}"; + value = final.haskell-nix.stackProject' { src = ./.; # name = "project-name"; - compiler-nix-name = "ghc982"; # Version of GHC to use + compiler-nix-name = name; # Version of GHC to use # Use the corresponding stack configuration as well - stackYaml = "stack-9.8.yaml"; + stackYaml = value; # put your current system for `nix flake show` to work: evalSystem = "x86_64-linux"; # Tools to include in the development shell @@ -33,18 +47,41 @@ haskell-language-server = "lastest"; }; }; - }) + }) supportedGHCStackFile + ) ]; pkgs = import nixpkgs { inherit system overlays; inherit (haskellNix) config; }; - flake = pkgs.bnfc-project.flake {}; + allVersions = builtins.mapAttrs ( + name: _value: pkgs."bnfc-project-${name}".flake {} + ) supportedGHCStackFile; + + flake = allVersions.${defaultVersion}; in flake // { legacyPackages = pkgs; - apps.default = flake.apps."BNFC:exe:bnfc"; + apps = { + default = flake.apps."BNFC:exe:bnfc"; + } // (lib.attrsets.mapAttrs' ( + name: _value: { + name = "bnfc-${name}"; + value = allVersions.${defaultVersion}.apps."BNFC:exe:bnfc"; + } + ) supportedGHCStackFile); packages = rec { bnfc = flake.packages."BNFC:exe:bnfc"; default = bnfc; libBNFC = flake.packages."BNFC:lib:BNFC"; - }; + } // (lib.attrsets.mapAttrs' ( + name: _value: { + name = "bnfc-${name}"; + value = allVersions.${defaultVersion}.packages."BNFC:exe:bnfc"; + } + ) supportedGHCStackFile) + // (lib.attrsets.mapAttrs' ( + name: _value: { + name = "bnfc-${name}"; + value = allVersions.${defaultVersion}.packages."BNFC:lib:BNFC"; + } + ) supportedGHCStackFile); }); # --- Flake Local Nix Configuration ---------------------------- From 1de7b1177ca73d7b4e8543cf406d0762173f3d5b Mon Sep 17 00:00:00 2001 From: Kangjing Huang Date: Fri, 19 Jul 2024 02:17:54 -0400 Subject: [PATCH 09/17] Add multiple devShells and fix typo --- flake.nix | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index c9b7013c..0630e733 100644 --- a/flake.nix +++ b/flake.nix @@ -63,7 +63,7 @@ } // (lib.attrsets.mapAttrs' ( name: _value: { name = "bnfc-${name}"; - value = allVersions.${defaultVersion}.apps."BNFC:exe:bnfc"; + value = allVersions.${name}.apps."BNFC:exe:bnfc"; } ) supportedGHCStackFile); packages = rec { @@ -73,13 +73,21 @@ } // (lib.attrsets.mapAttrs' ( name: _value: { name = "bnfc-${name}"; - value = allVersions.${defaultVersion}.packages."BNFC:exe:bnfc"; + value = allVersions.${name}.packages."BNFC:exe:bnfc"; } ) supportedGHCStackFile) // (lib.attrsets.mapAttrs' ( name: _value: { name = "bnfc-${name}"; - value = allVersions.${defaultVersion}.packages."BNFC:lib:BNFC"; + value = allVersions.${name}.packages."BNFC:lib:BNFC"; + } + ) supportedGHCStackFile); + devShells = { + default = flake.devShells.default; + } // (lib.attrsets.mapAttrs' ( + name: _value: { + name = "bnfc-${name}"; + value = allVersions.${name}.devShells.default; } ) supportedGHCStackFile); }); From aa8d88ff753eabeca5b531172a2169e2901efca4 Mon Sep 17 00:00:00 2001 From: Kangjing Huang Date: Fri, 19 Jul 2024 02:23:06 -0400 Subject: [PATCH 10/17] Fix another typo --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 0630e733..45501ebd 100644 --- a/flake.nix +++ b/flake.nix @@ -78,7 +78,7 @@ ) supportedGHCStackFile) // (lib.attrsets.mapAttrs' ( name: _value: { - name = "bnfc-${name}"; + name = "libBNFC-${name}"; value = allVersions.${name}.packages."BNFC:lib:BNFC"; } ) supportedGHCStackFile); From ce3e4d5ec3f41f263f88292fdaabfe12e0a61a87 Mon Sep 17 00:00:00 2001 From: Kangjing Huang Date: Fri, 19 Jul 2024 04:51:17 -0400 Subject: [PATCH 11/17] Another typo --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 45501ebd..3420eaf5 100644 --- a/flake.nix +++ b/flake.nix @@ -44,7 +44,7 @@ shell.tools = { cabal = "latest"; hlint = "latest"; - haskell-language-server = "lastest"; + haskell-language-server = "latest"; }; }; }) supportedGHCStackFile From 3e8fd9237ebc6fa3788dafdc7af9117fffd7317a Mon Sep 17 00:00:00 2001 From: Kangjing Huang Date: Fri, 19 Jul 2024 20:11:47 -0400 Subject: [PATCH 12/17] Add workflow for testing nix integration --- .github/workflows/nix.yml | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/nix.yml diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml new file mode 100644 index 00000000..6d7ea967 --- /dev/null +++ b/.github/workflows/nix.yml @@ -0,0 +1,41 @@ +name: "Test Nix Integration" +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + nix: + strategy: + fail-fast: true + matrix: + os: + - ubuntu-latest + - macos-latest + name: Nix on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@V27 + with: + extra_nix_config: | + trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= cache.ngi0.nixos.org-1:KqH5CBLNSyX184S9BKZJo1LxrxJ9ltnY2uAs5c/f1MA= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= + substituters = https://cache.nixos.org https://cache.ngi0.nixos.org/ https://cache.iog.io/ + nix_path: nixpkgs=channel:nixos-unstable + + - name: "Test Nix flakes build" + run: nix build + + - name: "Test Nix flakes development shell" + run: nix develop --check + + - name: "Test Nix flake-compact build" + run: nix-build + + - name: "Test Nix flake-compact development shell" + run: nix-shell --run echo + + - continue-on-error: false + run: nix flake check \ No newline at end of file From d82cb4e1710a9ed2490689018b6f0d26e126d7c6 Mon Sep 17 00:00:00 2001 From: Kangjing Huang Date: Fri, 19 Jul 2024 20:24:53 -0400 Subject: [PATCH 13/17] Remove evalSystem --- flake.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/flake.nix b/flake.nix index 3420eaf5..b85d9161 100644 --- a/flake.nix +++ b/flake.nix @@ -38,8 +38,6 @@ compiler-nix-name = name; # Version of GHC to use # Use the corresponding stack configuration as well stackYaml = value; - # put your current system for `nix flake show` to work: - evalSystem = "x86_64-linux"; # Tools to include in the development shell shell.tools = { cabal = "latest"; From 00c7539c2e77448cd52795f3ab0d9ac965347ffb Mon Sep 17 00:00:00 2001 From: Kangjing Huang Date: Fri, 19 Jul 2024 20:50:35 -0400 Subject: [PATCH 14/17] Disable devshell testing in workflows, takes too long --- .github/workflows/nix.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 6d7ea967..f9adf101 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -28,14 +28,16 @@ jobs: - name: "Test Nix flakes build" run: nix build - - name: "Test Nix flakes development shell" - run: nix develop --check + # Development shells will require building of hls and take a lot of time + # Let's not do that in the actions for now + # - name: "Test Nix flakes development shell" + # run: nix develop --check - name: "Test Nix flake-compact build" run: nix-build - - name: "Test Nix flake-compact development shell" - run: nix-shell --run echo + # - name: "Test Nix flake-compact development shell" + # run: nix-shell --run echo - continue-on-error: false run: nix flake check \ No newline at end of file From 69d323a93edc09df850a05dc90070b2608ca21c9 Mon Sep 17 00:00:00 2001 From: Kangjing Huang Date: Fri, 19 Jul 2024 20:56:03 -0400 Subject: [PATCH 15/17] Add missing option for nix flake commands to work --- .github/workflows/nix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index f9adf101..4b4e5909 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -40,4 +40,4 @@ jobs: # run: nix-shell --run echo - continue-on-error: false - run: nix flake check \ No newline at end of file + run: nix flake check --allow-import-from-derivation \ No newline at end of file From 1bae839d9aa610bcf265a8444b2b877e581ff893 Mon Sep 17 00:00:00 2001 From: Kangjing Huang Date: Sat, 20 Jul 2024 04:27:23 -0400 Subject: [PATCH 16/17] Fix nix flake check --- flake.nix | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/flake.nix b/flake.nix index b85d9161..ba3d60dd 100644 --- a/flake.nix +++ b/flake.nix @@ -6,12 +6,14 @@ outputs = { self, nixpkgs, flake-utils, haskellNix, ... }: let supportedSystems = [ - # Note: Only Linux on x6_64 is tested to work for now "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + # For `nix flake show` and `nix flake check` + # Requires --impure, on pure evaluation we default to x86_64-linux + currentPlatform = builtins.currentSystem or "x86_64-linux"; in flake-utils.lib.eachSystem supportedSystems (system: let @@ -30,20 +32,35 @@ overlays = [ haskellNix.overlay (final: _prev: lib.attrsets.mapAttrs' ( - name: value: { - name = "bnfc-project-${name}"; + ghcVersion: value: { + name = "bnfc-project-${ghcVersion}"; value = final.haskell-nix.stackProject' { src = ./.; - # name = "project-name"; - compiler-nix-name = name; # Version of GHC to use + name = "bnfc-project-${ghcVersion}"; + compiler-nix-name = ghcVersion; # Version of GHC to use # Use the corresponding stack configuration as well stackYaml = value; + # For `nix flake show` to work: + evalSystem = currentPlatform; # Tools to include in the development shell shell.tools = { cabal = "latest"; - hlint = "latest"; - haskell-language-server = "latest"; + hlint = { + ghc8107 = "3.4"; + ghc902 = "3.5"; + ghc928 = "3.6.1"; + ghc948 = "3.8"; + ghc965 = "3.8"; + ghc982 = "3.8"; + }.${ghcVersion}; + haskell-language-server = if ghcVersion == "ghc8107" then "2.2.0.0" + else if ghcVersion == "ghc902" then "2.4.0.0" + else "latest"; }; + modules = [{ + # Disable check for doctests + packages.BNFC.components.tests.doctests.doCheck = false; + }]; }; }) supportedGHCStackFile ) @@ -53,7 +70,14 @@ name: _value: pkgs."bnfc-project-${name}".flake {} ) supportedGHCStackFile; - flake = allVersions.${defaultVersion}; + allFlake = allVersions.${defaultVersion}; + # `nix flake check` currently does not support custom check logics, and will check hydrajobs + # defined for all platforms, which can cause check failures (see issue NixOS/nix#6453) + # For `nix flake check` to work, filter out all hydrajobs that are not for the current platform + # Note that on non x86_64-linux platforms --impure is required to pick up the correct platform names + flake = if system == currentPlatform + then allFlake + else builtins.removeAttrs allFlake ["hydraJobs"]; in flake // { legacyPackages = pkgs; apps = { From 6566927234fee801373fcf97cf7614b032ab97b6 Mon Sep 17 00:00:00 2001 From: Kangjing Huang Date: Sat, 20 Jul 2024 04:47:12 -0400 Subject: [PATCH 17/17] Try to fix OS X workflow --- .github/workflows/nix.yml | 2 +- flake.nix | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 4b4e5909..d02f2795 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -40,4 +40,4 @@ jobs: # run: nix-shell --run echo - continue-on-error: false - run: nix flake check --allow-import-from-derivation \ No newline at end of file + run: nix flake check --allow-import-from-derivation --impure \ No newline at end of file diff --git a/flake.nix b/flake.nix index ba3d60dd..1533df7a 100644 --- a/flake.nix +++ b/flake.nix @@ -11,9 +11,6 @@ "aarch64-linux" "aarch64-darwin" ]; - # For `nix flake show` and `nix flake check` - # Requires --impure, on pure evaluation we default to x86_64-linux - currentPlatform = builtins.currentSystem or "x86_64-linux"; in flake-utils.lib.eachSystem supportedSystems (system: let @@ -40,8 +37,6 @@ compiler-nix-name = ghcVersion; # Version of GHC to use # Use the corresponding stack configuration as well stackYaml = value; - # For `nix flake show` to work: - evalSystem = currentPlatform; # Tools to include in the development shell shell.tools = { cabal = "latest"; @@ -61,7 +56,8 @@ # Disable check for doctests packages.BNFC.components.tests.doctests.doCheck = false; }]; - }; + # For `nix flake show --impure` and `nix flake check --impure` to work + } // ( if (builtins ? currentSystem) then {evalSystem = builtins.currentSystem;} else {}); }) supportedGHCStackFile ) ]; @@ -75,7 +71,7 @@ # defined for all platforms, which can cause check failures (see issue NixOS/nix#6453) # For `nix flake check` to work, filter out all hydrajobs that are not for the current platform # Note that on non x86_64-linux platforms --impure is required to pick up the correct platform names - flake = if system == currentPlatform + flake = if system == (builtins.currentSystem or "x86_64-linux") then allFlake else builtins.removeAttrs allFlake ["hydraJobs"]; in flake // {