From 54dacb7028a0aad89d89a598ba923548862f9c6b Mon Sep 17 00:00:00 2001 From: Daniel Firth <dan.firth@homotopic.tech> Date: Wed, 15 Mar 2023 14:30:17 +0000 Subject: [PATCH] remove shell from source and use horizon-shell instead --- README.md | 96 +++++++++++++++++------------------------------ flake.lock | 8 ++-- flake.nix | 10 ----- horizon.dhall | 32 ++++++++-------- shell/ShellRC.hs | 90 -------------------------------------------- shell/default.nix | 75 ------------------------------------ 6 files changed, 56 insertions(+), 255 deletions(-) delete mode 100644 shell/ShellRC.hs delete mode 100644 shell/default.nix diff --git a/README.md b/README.md index bcf91b4d..b3dd7096 100644 --- a/README.md +++ b/README.md @@ -4,24 +4,41 @@ Horizon is a haskell package set targetting new builds of GHC. -## Getting started +## Package Set Policy -You an can use this package set instead of your haskell packages set in -nixpkgs. To see an example you can use the template supplied with this -repository. +This package set has the following policy. -``` -mkdir myProject -cd myProject -nix flake init -t 'git+https://gitlab.homotopic.tech/horizon/horizon-templates' -``` +* GHC will advance as often as possible +* Nonversioned locations (git, unversioned tarballs) are permitted to allow + GHC to advance. +* The following packages must always build: + * aeson + * beam-postgres + * composite-base + * dhall + * haskell-language-server + * hedgehog + * pandoc + * persistent-postgresql + * polysemy + * servant + * sydtest + * tasty + * xmonad-contrib + * xmonad + * wai-app-static + * warp +* Tags will be of the form `unstable-<yyyy>-<mm>-<dd>-r<N>` where any + unversioned source is used. +* Tags will be of the form `stable-<yyyy>-<mm>-<dd>-r<N>` where all +stable sources are used. ## Updating the package set The package set is generated from the `horizon.dhall` using the following command: ``` -nix run .#horizon-gen-nix +nix run 'git+https://gitlab.horizon-haskell.net/haskell/horizon-gen-nix?ref=refs/tags/0.9.0' ``` This will generate both the packages folder and the package set file. If you @@ -35,12 +52,16 @@ afterwards. ## Programmmatic Updates -The package set will be automatically loaded under the variable `hz`. +To use `horizon-shell`. ``` -import Horizon.Spec.Utils +nix run 'git+https://gitlab.horizon-haskell.net/shells/horizon-shell?ref=refs/tags/0.0.1' +``` + +The package set will be automatically loaded under the variable `hz`. -let f = L.at "lens" L..~ Just (callHackage "lens" "5.1") +``` +let f = L.at "lens" L..~ Just (H.callHackage "lens" "5.1") :t f f :: (L.IxValue t ~ HaskellPackage, L.At t, @@ -53,51 +74,4 @@ H.writeHorizonFile hz' ``` -Then remember to delete `pkgs/lens.nix` and re-run `nix run .#horizon-gen-nix` -as usual.~ -## Package Set Policy - -This package set has the following policy. - -* GHC will advance as often as possible -* Nonversioned locations (git, unversioned tarballs) are permitted to allow - GHC to advance. -* The following packages must always build: - * aeson - * beam-postgres - * composite-base - * dhall - * haskell-language-server - * hedgehog - * pandoc - * persistent-postgresql - * polysemy - * servant - * sydtest - * tasty - * xmonad-contrib - * xmonad - * wai-app-static - * warp -* Tags will be of the form `unstable-<yyyy>-<mm>-<dd>-r<N>` where any - unversioned source is used. -* Tags will be of the form `stable-<yyyy>-<mm>-<dd>-r<N>` where all -stable sources are used. - -## Commit Policy - -* All commits should evaluate with `nix flake show`. -* All commits should pass all checks with `nix flake check`. -* All derivations in `packages` should build. -* Where possible, commits should be atomic, of the form - * foo: init at <version> - * foo: <old-version> -> <new-version> -* If multiple packages need to be maintained in lockstep, - the commit message should contain all changes. - -## ChangeLog Policy - -* ChangeLogs should clearly show source stability changes between versions, - of the form: - * stabilized source: aeson, lens - * destabilized source: pandoc +Then remember to delete `pkgs/lens.nix` and re-run horizon-gen-nix as usual. diff --git a/flake.lock b/flake.lock index e84854a9..622d6f57 100644 --- a/flake.lock +++ b/flake.lock @@ -125,11 +125,11 @@ "horizon-platform": { "flake": false, "locked": { - "lastModified": 1678805130, - "narHash": "sha256-I4q5yTZZJB5vuWfA/T0NaIgAi3kaP5k6OWCc34YWlgc=", + "lastModified": 1678886634, + "narHash": "sha256-PkiDQImBu4i9sOKiOIEDMryBGn3ouBZ/H0+mAyOEbLk=", "ref": "refs/heads/master", - "rev": "b04d3fea8d6127c1aa7d8e8bb0d2812e8b5e1d20", - "revCount": 991, + "rev": "0b3c27cd666315edca0585e82ed6d74f208fff5b", + "revCount": 997, "type": "git", "url": "https://gitlab.horizon-haskell.net/package-sets/horizon-platform" }, diff --git a/flake.nix b/flake.nix index 03278260..c34d9fbb 100644 --- a/flake.nix +++ b/flake.nix @@ -76,19 +76,9 @@ && v.meta.broken == false) legacyPackages; - procex = import ./shell/default.nix { haskellPackages = horizon-platform-prev.legacyPackages.${system}; inherit (pkgs) runCommand writeShellScriptBin; }; in { - apps = { - - procex = { - type = "app"; - program = "${procex}/bin/procex-shell"; - }; - - }; - checks = with lint-utils.linters.${system}; { dhall-format = dhall-format { src = self; }; nixpkgs-fmt = nixpkgs-fmt { src = self; }; diff --git a/horizon.dhall b/horizon.dhall index 1393042d..24b73d18 100644 --- a/horizon.dhall +++ b/horizon.dhall @@ -31,10 +31,10 @@ let packages = , Decimal = H.callHackage "Decimal" "0.5.2" , Diff = H.callHackage "Diff" "0.4.1" , Glob = H.callHackage "Glob" "0.10.2" - , HaskellNet = H.callHackage "HaskellNet" "0.6.0.2" , HTF = H.callHackage "HTF" "0.15.0.0" , HTTP = H.callHackage "HTTP" "4000.4.1" , HUnit = H.callHackage "HUnit" "1.6.2.0" + , HaskellNet = H.callHackage "HaskellNet" "0.6.0.2" , Hclip = H.callHackage "Hclip" "3.0.0.4" , HsOpenSSL = H.callHackage "HsOpenSSL" "0.11.7.2" , HsYAML = H.callHackage "HsYAML" "0.2.1.1" @@ -550,19 +550,21 @@ let packages = , hnix-store-remote = H.callHackage "hnix-store-remote" "0.6.0.0" , hopenssl = H.callHackage "hopenssl" "2.2.4" , horizon-gen-nix = - H.callHorizonGitlab "horizon-gen-nix" "0.9.0" (Some "horizon-gen-nix") + H.callTarball + "https://gitlab.horizon-haskell.net/haskell/horizon-gen-nix/-/archive/0.9.0/horizon-gen-nix-0.9.0.tar.gz" + (Some "horizon-gen-nix/") , horizon-spec = - H.callHorizonGitlab "horizon-spec" "0.11.0" (Some "horizon-spec") + H.callTarball + "https://gitlab.horizon-haskell.net/haskell/horizon-spec/-/archive/0.11.0/horizon-spec-0.11.0.tar.gz" + (Some "horizon-spec/") , horizon-spec-lens = - H.callHorizonGitlab - "horizon-spec-lens" - "0.2.0" - (Some "horizon-spec-lens") + H.callTarball + "https://gitlab.horizon-haskell.net/haskell/horizon-spec-lens/-/archive/0.2.0/horizon-spec-lens-0.2.0.tar.gz" + (Some "horizon-spec-lens/") , horizon-spec-pretty = - H.callHorizonGitlab - "horizon-spec-pretty" - "0.1.0" - (Some "horizon-spec-pretty") + H.callTarball + "https://gitlab.horizon-haskell.net/haskell/horizon-spec-pretty/-/archive/0.1.0/horizon-spec-pretty-0.1.0.tar.gz" + (Some "horizon-spec-pretty/") , hosc = H.callHackage "hosc" "0.19.1" , hostname = H.callHackage "hostname" "1.0" , hourglass = H.callHackage "hourglass" "0.2.12" @@ -692,9 +694,9 @@ let packages = , lazysmallcheck = H.callHackage "lazysmallcheck" "0.6" , lens = H.callHackage "lens" "5.2" , lens-aeson = H.callHackage "lens-aeson" "1.2.1" + , lens-family = H.callHackage "lens-family" "2.1.2" , lens-family-core = H.callHackage "lens-family-core" "2.1.2" , lens-family-th = H.callHackage "lens-family-th" "0.5.2.1" - , lens-family = H.callHackage "lens-family" "2.1.2" , libsodium = H.callHackage "libsodium" "1.0.18.2" , libsystemd-journal = H.callHackage "libsystemd-journal" "1.4.5" , libxml = H.callHackage "libxml" "0.1.1" @@ -761,7 +763,6 @@ let packages = , mockery = H.callHackage "mockery" "0.3.5" , mod = H.callHackage "mod" "0.1.2.2" , modern-uri = H.callHackage "modern-uri" "0.3.6.0" - , monadlist = H.callHackage "monadlist" "0.0.2" , monad-control = H.callHackage "monad-control" "1.0.3.1" , monad-logger = H.callHackage "monad-logger" "0.3.37" , monad-logger-extras = H.callHackage "monad-logger-extras" "0.1.1.1" @@ -772,6 +773,7 @@ let packages = , monad-peel = H.callHackage "monad-peel" "0.2.1.2" , monad-primitive = H.callHackage "monad-primitive" "0.1" , monad-time = H.callHackage "monad-time" "0.4.0.0" + , monadlist = H.callHackage "monadlist" "0.0.2" , monads-tf = H.callHackage "monads-tf" "0.1.0.3" , mono-traversable = H.callHackage "mono-traversable" "1.0.15.3" , monoid-extras = H.callHackage "monoid-extras" "0.6.2" @@ -798,8 +800,8 @@ let packages = , newtype = H.callHackage "newtype" "0.2.2.0" , newtype-generics = H.callHackage "newtype-generics" "0.6.2" , nix-derivation = H.callHackage "nix-derivation" "1.1.2" - , nonempty-vector = H.callHackage "nonempty-vector" "0.2.1.0" , non-negative = H.callHackage "non-negative" "0.1.2" + , nonempty-vector = H.callHackage "nonempty-vector" "0.2.1.0" , nothunks = H.callHackage "nothunks" "0.1.3" , numeric-extras = H.callHackage "numeric-extras" "0.1" , numeric-prelude = H.callHackage "numeric-prelude" "0.4.4" @@ -1062,8 +1064,8 @@ let packages = , socks = H.callHackage "socks" "0.6.1" , some = H.callHackage "some" "1.0.4" , sop-core = H.callHackage "sop-core" "0.5.0.1" - , sorted-list = H.callHackage "sorted-list" "0.2.1.0" , sort = H.callHackage "sort" "1.0.0.0" + , sorted-list = H.callHackage "sorted-list" "0.2.1.0" , souffle-haskell = H.callHackage "souffle-haskell" "3.5.0" , special-values = H.callHackage "special-values" "0.1.0.0" , split = H.callHackage "split" "0.2.3.3" diff --git a/shell/ShellRC.hs b/shell/ShellRC.hs deleted file mode 100644 index d86ff860..00000000 --- a/shell/ShellRC.hs +++ /dev/null @@ -1,90 +0,0 @@ -{-# LANGUAGE AllowAmbiguousTypes #-} -{-# LANGUAGE DerivingStrategies #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE NoMonomorphismRestriction #-} -{-# LANGUAGE OverloadedLists #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE TemplateHaskell #-} -{-# LANGUAGE TypeFamilies #-} -{-# OPTIONS_GHC -Wno-missing-signatures #-} -{-# OPTIONS_GHC -Wno-unused-imports #-} -{-# OPTIONS_GHC -fplugin=Polysemy.Plugin #-} - -module ShellRC where - -import qualified Brick -import Brick.Widgets.Border -import qualified Brick.Widgets.List as Brick -import Brick.Widgets.Table (Table, renderTable, table) -import qualified Brick.Widgets.Table as Brick -import qualified Control.Lens as L -import Control.Monad (forM, void) -import Control.Monad.IO.Class -import Cursor.List.NonEmpty -import qualified Data.Aeson as A -import qualified Data.Aeson.Key as A -import qualified Data.Aeson.KeyMap as A -import qualified Data.Aeson.Lens as L -import qualified Data.ByteString as B -import Data.ByteString.Lazy.UTF8 as BLU -import qualified Data.ByteString.Lazy.UTF8 as BU -import Data.Kind (Type) -import qualified Data.List -import Data.List.NonEmpty (NonEmpty ((:|))) -import qualified Data.Map as Map -import Data.Maybe (fromMaybe) -import Data.Monoid -import Data.Text (Text) -import qualified Data.Text as T -import qualified Data.Text.Encoding as T -import qualified Data.Text.Encoding.Error as T -import qualified Data.Vector as V -import qualified Data.Yaml as Y -import qualified Data.Yaml.Pretty as Y -import qualified Dhall -import Dhall.Core -import qualified Dhall.Map as DMap -import Dhall.Src -import GHC.Exts -import Graphics.Vty.Attributes -import Graphics.Vty.Input.Events -import Horizon.Spec -import qualified Horizon.Spec.Lens as L -import qualified Horizon.Spec.Pretty as H -import Network.HTTP.Simple -import Path -import Polysemy -import Polysemy.State -import Procex.Prelude -import Procex.Shell hiding (promptFunction) -import System.Directory -import System.Environment - -promptFunction :: [String] -> Int -> IO String -promptFunction _modules _line = do - d <- getEnv "PWD" - setCurrentDirectory d - pure $ d <> ": " - -_init :: IO () -_init = do - initInteractive - getEnv "REALHOME" >>= setEnv "HOME" -- Set by the script that launches GHCi - -hackagePkg :: Text -> IO A.Value -hackagePkg x = do - k <- parseRequest $ "http://hackage.haskell.org/package/" <> T.unpack x - getResponseBody <$> httpJSON k - -hackagePkgLatest :: Text -> IO Text -hackagePkgLatest x = Prelude.last . Map.keys . A.toMapText . L.view L._Object <$> hackagePkg x - -runAllFeedback :: IO () -runAllFeedback = do - (x :: Either Y.ParseException A.Value) <- Y.decodeFileEither "feedback.yaml" - t <- getEnv "TERM" - let y = Map.keys . A.toMapText . L.view (L._Right . L._Object . L.ix "loops" . L._Object) $ x - mapM_ (captureLazyNoThrow . mq t "--command" "nix" "run" "github:NorfairKing/feedback" "--" . T.unpack) y - -loadHorizon :: IO HorizonExport -loadHorizon = Dhall.inputFile @HorizonExport Dhall.auto "horizon.dhall" diff --git a/shell/default.nix b/shell/default.nix deleted file mode 100644 index c13393b5..00000000 --- a/shell/default.nix +++ /dev/null @@ -1,75 +0,0 @@ -{ haskellPackages, writeShellScriptBin, runCommand }: - -let - - shellrcSrcPath = ./.; - shellrcModule = "ShellRC"; - - shellrcSrc = shellrcSrcPath; - shellrcModulePath = builtins.replaceStrings [ "." ] [ "/" ] shellrcModule + ".hs"; - - ghc = haskellPackages.ghcWithPackages (p: with p; [ - brick - bytestring - containers - cursor - dhall - http-conduit - horizon-gen-nix - horizon-spec - horizon-spec-lens - horizon-spec-pretty - lens - lens-aeson - path - polysemy-plugin - polysemy - procex - text - vector - yaml - ]); - - args = builtins.concatStringsSep " " [ - "-XDataKinds" - "-XExtendedDefaultRules" - "-XGHC2021" - "-XOverloadedStrings" - "-XOverloadedLabels" - "-Wall" - "-Wno-type-defaults" - ]; - - shellrc = runCommand "shellrc" { } '' - cp ${shellrcSrc} --no-preserve=all -rT $out - ${ghc}/bin/ghc -c -dynamic --make -i"$out" ${args} $out/${shellrcModulePath} - ''; - - init = runCommand "ghci-init" { } '' - cat > $out <<END - :set +m -interactive-print Text.Pretty.Simple.pPrint - - :l ${shellrcModule} - - import Procex.Shell.Labels - - :set prompt-function promptFunction - - _init - - hz <- loadHorizon - END - grep -E '^import .*$' < ${shellrcSrc}/${shellrcModulePath} >> $out - ''; - -in - -(writeShellScriptBin "procex-shell" '' - - home="$HOME/.local/share/ghci-shell" - - mkdir -p "$home" - - exec env GHCRTS="-c" HOME="$home" REALHOME="$HOME" ${ghc}/bin/ghci ${args} -ignore-dot-ghci -i -i${shellrc} -ghci-script ${init} "$@" - -'').overrideAttrs (old: old // { passthru = { shellPath = "/bin/procex-shell"; }; }) -- GitLab