diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0f61285 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,11 @@ +name: Foundry CI +on: push +jobs: + minimal: + runs-on: ubuntu-latest + steps: + - uses: nixbuild/nix-quick-install-action@v26 + - uses: actions/checkout@v4 + - run: nix --version + - run: nix flake check + - run: nix build diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d8cc8ef..0000000 --- a/.travis.yml +++ /dev/null @@ -1 +0,0 @@ -language: nix diff --git a/README.md b/README.md index a50f49e..ac8637f 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,5 @@ # Godsmen Foundry -[![Build Status](https://dev.azure.com/int-index/Personal/_apis/build/status/serokell.foundry?branchName=master)](https://dev.azure.com/int-index/Personal/_build/latest?definitionId=3&branchName=master) -[![Build Status](https://travis-ci.org/serokell/foundry.svg?branch=master)](https://travis-ci.org/serokell/foundry) - Godsmen Foundry is a Morte IDE based on Source. Implementation status: @@ -15,13 +12,12 @@ Implementation status: * [ ] local storage * [ ] browsing Sigil -[sigil.place/tutorial/morte/1.7.1/even](http://sigil.place/tutorial/morte/1.7.1/even) ![Rendering Morte](examples/expr.svg) ## Getting Started ``` -$ nix-build +$ nix build $ result/bin/morte-to-sdam "./examples/expr.morte" > expr.sd $ result/bin/sdam-to-svg --morte expr.sd $ result/bin/foundry expr.sd @@ -30,7 +26,7 @@ $ result/bin/foundry expr.sd ## Tooling ``` -$ nix-shell -p haskellPackages.fast-tags haskellPackages.ormolu +$ nix develop -c $SHELL $ make tags $ make fmt ``` @@ -38,6 +34,6 @@ $ make fmt ## SVG Optimization ``` -$ nix-shell -p nodePackages.svgo +$ nix shell nixpkgs#nodePackages.svgo $ svgo expr.svg ``` diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index c04eb98..0000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,60 +0,0 @@ -jobs: - - job: Formatting - pool: - vmImage: 'ubuntu-16.04' - steps: - - script: | - cd $HOME - mkdir -p $HOME/.ghcup/bin && curl https://raw.githubusercontent.com/haskell/ghcup/master/ghcup > $HOME/.ghcup/bin/ghcup && chmod +x $HOME/.ghcup/bin/ghcup - export PATH="$HOME/.cabal/bin:$HOME/.ghcup/bin:$PATH" - ghcup install 8.6.5 - ghcup set 8.6.5 - ghcup install-cabal - cabal v2-update - cabal v2-install ormolu - displayName: 'Install ormolu' - - script: | - export PATH="$HOME/.cabal/bin:$HOME/.ghcup/bin:$PATH" - FILES=$(find lib src -name "*.hs") - echo "Checking files:" - echo $FILES - ormolu -c --mode check $FILES - displayName: 'Check formatting' - - job: Ubuntu - pool: - vmImage: 'ubuntu-16.04' - steps: - - script: | - sudo apt-get install libgtk-3-dev - mkdir -p $HOME/.ghcup/bin && curl https://raw.githubusercontent.com/haskell/ghcup/master/ghcup > $HOME/.ghcup/bin/ghcup && chmod +x $HOME/.ghcup/bin/ghcup - export PATH="$HOME/.cabal/bin:$HOME/.ghcup/bin:$PATH" - ghcup install 8.6.5 - ghcup set 8.6.5 - ghcup install-cabal - cabal v2-update - displayName: 'Prepare system' - - script: | - export PATH="$HOME/.cabal/bin:$HOME/.ghcup/bin:$PATH" - cabal v2-build - cabal v2-exec -- which foundry hask - displayName: 'Build' - - job: macOS - pool: - vmImage: 'macOS-10.14' - steps: - - script: | - brew install gtk+3 libffi pkgconfig - export PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig:$PKG_CONFIG_PATH - mkdir -p $HOME/.ghcup/bin && curl https://raw.githubusercontent.com/haskell/ghcup/master/ghcup > $HOME/.ghcup/bin/ghcup && chmod +x $HOME/.ghcup/bin/ghcup - export PATH="$HOME/.cabal/bin:$HOME/.ghcup/bin:$PATH" - ghcup install 8.6.5 - ghcup set 8.6.5 - ghcup install-cabal - cabal v2-update - displayName: 'Prepare system' - - script: | - export PATH="$HOME/.cabal/bin:$HOME/.ghcup/bin:$PATH" - export PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig:$PKG_CONFIG_PATH - cabal v2-build - cabal v2-exec -- which foundry hask - displayName: 'Build' diff --git a/cabal.project b/cabal.project index 64d5a73..ba0c3b2 100644 --- a/cabal.project +++ b/cabal.project @@ -1,5 +1,5 @@ packages: - foundry.cabal + src/foundry.cabal allow-newer: morte:optparse-applicative diff --git a/default.nix b/default.nix deleted file mode 100644 index ad8c64a..0000000 --- a/default.nix +++ /dev/null @@ -1,101 +0,0 @@ -let - - nixpkgsPin = import ./nix/nixpkgs-pin.nix; - -in - -{ pkgs ? import (builtins.fetchTarball nixpkgsPin) {}, - hc ? "ghc925" -}: - -let - - sdam_from_github = - pkgs.fetchFromGitHub { - owner = "int-index"; - repo = "sdam"; - rev = "3943cd2662eff11e1a36bc629ac832652ec43a6e"; - sha256 = "05p43wvmx41rlnj5nwlcngr8rxhms5dxlh210ag2r04gxwra2mrv"; - }; - - slay_from_github = - pkgs.fetchFromGitHub { - owner = "int-index"; - repo = "slay"; - rev = "1c9d39b8cb4f32f0b4778677c21ebb85cc1cddf7"; - sha256 = "0x9xqaykdw5z3ggi7mkm7f5605c7z4jalhydvf9p1asdi5i34f8j"; - }; - - morte_from_github = - pkgs.fetchFromGitHub { - owner = "Gabriella439"; - repo = "Haskell-Morte-Library"; - rev = "b7ebbcbea21e3894b889ebd882856ffcdb154160"; - hash = "sha256-jO4EpCA+Xm7+oo0Xa8TIN+TX/bAjvQIcVYfQfbtAC5k="; - }; - - haskell_inputs = p: [ - p.gtk3 - p.lens - p.dlist - p.ghc-lib-parser - p.megaparsec - p.inj - p.inj-base - p.regex-applicative - p.split - p.streams - p.sdam - p.slay-core - p.slay-combinators - p.slay-cairo - p.morte - ]; - - haskellPackages = - pkgs.haskell.packages.${hc}.override { - overrides = self: super: rec { - inj-base = pkgs.haskell.lib.appendPatch (self.callHackage "inj-base" "0.2.0.0" {}) ./patches/inj-base.patch; - morte = pkgs.haskell.lib.doJailbreak (self.callCabal2nix "morte" "${morte_from_github}" {}); - lrucaching = pkgs.haskell.lib.dontCheck (self.callHackage "lrucaching" "0.3.3" {}); - ListLike = pkgs.haskell.lib.dontCheck super.ListLike; - sdam = self.callCabal2nix "sdam" sdam_from_github {}; - slay-core = self.callCabal2nix "slay-core" "${slay_from_github}/core" {}; - slay-combinators = self.callCabal2nix "slay-combinators" "${slay_from_github}/combinators" {}; - slay-cairo = self.callCabal2nix "slay-cairo" "${slay_from_github}/cairo" {}; - }; - }; - -in - -pkgs.stdenv.mkDerivation rec { - name = "foundry"; - src = ./.; - buildCommand = '' - mkdir -p $out/bin $out/home - cp -r $src/foundry.cabal $src/src . - HOME=$out/home \ - cabal --offline --config-file /dev/null v2-install \ - --builddir=$out/dist \ - --installdir=$out/bin \ - exe:foundry exe:morte-to-sdam exe:hask exe:haskell-to-sdam exe:sdam-to-svg - ''; - buildInputs = [ - (haskellPackages.ghcWithPackages haskell_inputs) - pkgs.cabal-install - pkgs.git - pkgs.zlib - pkgs.pkgconfig - pkgs.cairo - pkgs.pango - pkgs.gtk3 - ]; - shellHook = '' - export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath buildInputs}:$LD_LIBRARY_PATH - export LANG=en_US.UTF-8 - ''; - LOCALE_ARCHIVE = - if pkgs.stdenv.isLinux - then "${pkgs.glibcLocales}/lib/locale/locale-archive" - else ""; -} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..3ad2d35 --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1704666331, + "narHash": "sha256-RoB/KNSKvmurR+PB9GWKs7WKLBG1TLOmuUUl9l29up0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "40830f825335d4f5400a5337e9139fe43113a69e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..6332c0c --- /dev/null +++ b/flake.nix @@ -0,0 +1,69 @@ +{ + description = "foundry - a structure for Morte"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs"; + }; + + outputs = + { self, nixpkgs }: + let + system = "x86_64-linux"; + ghc = "ghc92"; + pkgs = nixpkgs.legacyPackages.${system}; + sdam-git = + pkgs.fetchFromGitHub { + owner = "int-index"; + repo = "sdam"; + rev = "3943cd2662eff11e1a36bc629ac832652ec43a6e"; + sha256 = "05p43wvmx41rlnj5nwlcngr8rxhms5dxlh210ag2r04gxwra2mrv"; + }; + slay-git = + pkgs.fetchFromGitHub { + owner = "int-index"; + repo = "slay"; + rev = "1c9d39b8cb4f32f0b4778677c21ebb85cc1cddf7"; + sha256 = "0x9xqaykdw5z3ggi7mkm7f5605c7z4jalhydvf9p1asdi5i34f8j"; + }; + morte-git = + pkgs.fetchFromGitHub { + owner = "Gabriella439"; + repo = "Haskell-Morte-Library"; + rev = "b7ebbcbea21e3894b889ebd882856ffcdb154160"; + hash = "sha256-jO4EpCA+Xm7+oo0Xa8TIN+TX/bAjvQIcVYfQfbtAC5k="; + }; + haskellPackages = + pkgs.haskell.packages.${ghc}.extend(hself: hsuper: { + foundry = hself.callCabal2nix "foundry" "${self}/src/" {}; + inj-base = pkgs.haskell.lib.appendPatch (hself.callHackage "inj-base" "0.2.0.0" {}) ./patches/inj-base.patch; + morte = pkgs.haskell.lib.doJailbreak (hself.callCabal2nix "morte" "${morte-git}" {}); + lrucaching = pkgs.haskell.lib.doJailbreak (hself.callHackage "lrucaching" "0.3.3" {}); + ListLike = pkgs.haskell.lib.dontCheck hsuper.ListLike; + sdam = hself.callCabal2nix "sdam" sdam-git {}; + slay-core = hself.callCabal2nix "slay-core" "${slay-git}/core" {}; + slay-combinators = hself.callCabal2nix "slay-combinators" "${slay-git}/combinators" {}; + slay-cairo = hself.callCabal2nix "slay-cairo" "${slay-git}/cairo" {}; + }); + in + { + packages.${system} = { + foundry = haskellPackages.foundry; + default = self.packages.${system}.foundry; + }; + + devShells.${system}.default = pkgs.mkShell { + buildInputs = [ + (haskellPackages.ghcWithPackages(p: + p.foundry.getCabalDeps.libraryHaskellDepends ++ + p.foundry.getCabalDeps.executableHaskellDepends + )) + haskellPackages.foundry.getCabalDeps.executableToolDepends + haskellPackages.hie-bios + haskellPackages.haskell-language-server + haskellPackages.cabal-install + haskellPackages.fast-tags + haskellPackages.ormolu + ]; + }; + }; +} diff --git a/nix/nixpkgs-pin.nix b/nix/nixpkgs-pin.nix deleted file mode 100644 index 2c8e022..0000000 --- a/nix/nixpkgs-pin.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ - # Commit hash source: https://nixos.org/channels/ - url = https://github.com/nixos/nixpkgs/archive/97b8d9459f7922ce0e666113a1e8e6071424ae16.tar.gz; - - # Hash obtained using `nix-prefetch-url --unpack ` - sha256 = "0nhmvgy2w4d9dxx4jvsy5hhzk29h8bb5z0850bdh82a3k157dnxc"; -} diff --git a/src/bin/Foundry.hs b/src/bin/Foundry.hs index 79da2e4..f0948e2 100644 --- a/src/bin/Foundry.hs +++ b/src/bin/Foundry.hs @@ -9,7 +9,7 @@ import Source import Source.Language.Morte import System.Environment (getArgs) import System.Exit (die) -import Text.Megaparsec as Megaparsec +import Text.Megaparsec as Megaparsec (errorBundlePretty) main :: IO () main = do diff --git a/src/bin/Hask.hs b/src/bin/Hask.hs index bea225f..2c08d0c 100644 --- a/src/bin/Hask.hs +++ b/src/bin/Hask.hs @@ -9,7 +9,7 @@ import Source import Source.Language.Haskell import System.Environment (getArgs) import System.Exit (die) -import Text.Megaparsec as Megaparsec +import Text.Megaparsec as Megaparsec (errorBundlePretty) main :: IO () main = do diff --git a/src/bin/HaskellToSdam.hs b/src/bin/HaskellToSdam.hs index 811202a..6d5df45 100644 --- a/src/bin/HaskellToSdam.hs +++ b/src/bin/HaskellToSdam.hs @@ -26,6 +26,8 @@ import qualified GHC.Data.StringBuffer as GHC import qualified GHC.Data.FastString as GHC import qualified GHC.Unit.Module as GHC import qualified GHC.Data.EnumSet as GHC.EnumSet +import qualified GHC.Utils.Outputable as GHC +import qualified GHC.Utils.Error as GHC main :: IO () main = do @@ -167,7 +169,7 @@ runGhcParser p s = initPState :: GHC.PState initPState = GHC.initParserState opts buffer location opts :: GHC.ParserOpts - opts = GHC.mkParserOpts GHC.EnumSet.empty GHC.EnumSet.empty False False False False + opts = GHC.mkParserOpts GHC.EnumSet.empty (GHC.DiagOpts GHC.EnumSet.empty GHC.EnumSet.empty False False Nothing GHC.defaultSDocContext) [] False False False False buffer :: GHC.StringBuffer buffer = GHC.stringToStringBuffer s location :: GHC.RealSrcLoc diff --git a/src/bin/SdamToSvg.hs b/src/bin/SdamToSvg.hs index 40f49a7..e7f3d4b 100644 --- a/src/bin/SdamToSvg.hs +++ b/src/bin/SdamToSvg.hs @@ -14,7 +14,7 @@ import Source.NewGen import System.Environment (getArgs) import System.Exit (die) import System.FilePath -import Text.Megaparsec as Megaparsec +import Text.Megaparsec as Megaparsec (errorBundlePretty) main :: IO () main = do diff --git a/src/driver/Source.hs b/src/driver/Source.hs index 07231df..81e63b6 100644 --- a/src/driver/Source.hs +++ b/src/driver/Source.hs @@ -38,7 +38,7 @@ runSource plugin mParsedValue = do createMainWindow :: NG.PluginInfo -> IORef NG.EditorState -> IO Gtk.Window createMainWindow pluginInfo esRef = do window <- Gtk.windowNew - Gtk.widgetSetAppPaintable window True + Gtk.widgetSetAppPaintable window True -- FIXME: broken on Wayland, use a drawing area Gtk.windowSetDefaultSize window 800 500 _ <- Gtk.on window Gtk.objectDestroy Gtk.mainQuit -- TODO: PointerMotionHintMask; eventRequestMotions diff --git a/foundry.cabal b/src/foundry.cabal similarity index 93% rename from foundry.cabal rename to src/foundry.cabal index 6a5dd65..068f376 100644 --- a/foundry.cabal +++ b/src/foundry.cabal @@ -36,7 +36,7 @@ library , source-plugin , num-non-negative - hs-source-dirs: src/driver + hs-source-dirs: driver default-language: Haskell2010 @@ -51,7 +51,7 @@ library source-plugin build-depends: base >=4.7, unordered-containers, text, primitive, hashable, sdam - hs-source-dirs: src/plugin + hs-source-dirs: plugin default-language: Haskell2010 ghc-options: -Wall -O2 ghc-prof-options: -fprof-auto @@ -64,7 +64,7 @@ library source-language-haskell build-depends: base >=4.7, unordered-containers, text, primitive, sdam, source-plugin - hs-source-dirs: src/lang/haskell + hs-source-dirs: lang/haskell default-language: Haskell2010 ghc-options: -Wall -O2 ghc-prof-options: -fprof-auto @@ -76,7 +76,7 @@ library source-language-morte build-depends: base >=4.7, unordered-containers, text, primitive, sdam, source-plugin - hs-source-dirs: src/lang/morte + hs-source-dirs: lang/morte default-language: Haskell2010 ghc-options: -Wall -O2 ghc-prof-options: -fprof-auto @@ -89,7 +89,7 @@ executable foundry build-depends: base, unordered-containers, megaparsec, sdam, source-language-morte, foundry - hs-source-dirs: src/bin + hs-source-dirs: bin default-language: Haskell2010 @@ -105,7 +105,7 @@ executable hask build-depends: base, unordered-containers, megaparsec, sdam, source-language-haskell, foundry - hs-source-dirs: src/bin + hs-source-dirs: bin default-language: Haskell2010 @@ -119,7 +119,7 @@ executable hask executable morte-to-sdam main-is: MorteToSdam.hs build-depends: base, text, containers, morte, sdam - hs-source-dirs: src/bin + hs-source-dirs: bin default-language: Haskell2010 ghc-options: -Wall -threaded -O2 @@ -127,7 +127,7 @@ executable haskell-to-sdam main-is: HaskellToSdam.hs build-depends: base, text, containers, unordered-containers, containers, ghc-lib-parser, sdam, source-language-haskell - hs-source-dirs: src/bin + hs-source-dirs: bin default-language: Haskell2010 ghc-options: -Wall -threaded -O2 @@ -137,6 +137,6 @@ executable sdam-to-svg slay-core, sdam, foundry, source-language-haskell, source-language-morte - hs-source-dirs: src/bin + hs-source-dirs: bin default-language: Haskell2010 ghc-options: -Wall -threaded -O2