From 5024a2be4c4cb18b807abc04ee106d2a9d0aa7c3 Mon Sep 17 00:00:00 2001 From: James Eversole Date: Sat, 8 Feb 2025 10:24:14 -0600 Subject: [PATCH] Revert flake.nix --- README.md | 4 +--- flake.lock | 44 +++++++---------------------------------- flake.nix | 56 ++++++++++++++++++++++------------------------------- src/REPL.hs | 17 ++++++++-------- 4 files changed, 39 insertions(+), 82 deletions(-) diff --git a/README.md b/README.md index 20f495e..a62c8fd 100644 --- a/README.md +++ b/README.md @@ -55,9 +55,7 @@ tricu < !version -- Print tricu version ## Installation and Use -[Releases are available for Linux.](https://git.eversole.co/James/tricu/releases) - -Or you can easily build and run this project using [Nix](https://nixos.org/download/). +You can easily build and run this project using [Nix](https://nixos.org/download/). - Quick Start (REPL): - `nix run git+https://git.eversole.co/James/tricu` diff --git a/flake.lock b/flake.lock index 4d7ad24..4e16d41 100644 --- a/flake.lock +++ b/flake.lock @@ -18,55 +18,25 @@ "type": "github" } }, - "nh2pkgs": { - "flake": false, - "locked": { - "lastModified": 1718490232, - "narHash": "sha256-0Fh3aJZuTJVmiiKY/5SyvHlfhZ3HeZTDUQnd+Fx6/Qo=", - "type": "tarball", - "url": "https://github.com/nh2/nixpkgs/archive/ede5282c487a1fd2de64303ba59adad6726f1225.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://github.com/nh2/nixpkgs/archive/ede5282c487a1fd2de64303ba59adad6726f1225.tar.gz" - } - }, "nixpkgs": { "locked": { - "lastModified": 1738797219, - "narHash": "sha256-KRwX9Z1XavpgeSDVM/THdFd6uH8rNm/6R+7kIbGa+2s=", + "lastModified": 1734566935, + "narHash": "sha256-cnBItmSwoH132tH3D4jxmMLVmk8G5VJ6q/SC3kszv9E=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "1da52dd49a127ad74486b135898da2cef8c62665", + "rev": "087408a407440892c1b00d80360fd64639b8091d", "type": "github" }, "original": { - "id": "nixpkgs", - "type": "indirect" + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" } }, "root": { "inputs": { "flake-utils": "flake-utils", - "nh2pkgs": "nh2pkgs", - "nixpkgs": "nixpkgs", - "static-haskell-nix": "static-haskell-nix" - } - }, - "static-haskell-nix": { - "flake": false, - "locked": { - "lastModified": 1718492291, - "narHash": "sha256-XbBHPJk3ln+uLW+Dsio7vJNYnsHhmqenbI7cLsP8kHg=", - "owner": "nh2", - "repo": "static-haskell-nix", - "rev": "481e7d73ca624278ef0f840a0a2ba09e3a583217", - "type": "github" - }, - "original": { - "owner": "nh2", - "repo": "static-haskell-nix", - "type": "github" + "nixpkgs": "nixpkgs" } }, "systems": { diff --git a/flake.nix b/flake.nix index d4b7936..0667747 100644 --- a/flake.nix +++ b/flake.nix @@ -2,56 +2,46 @@ description = "tricu"; inputs = { - nh2pkgs = { - url = "https://github.com/nh2/nixpkgs/archive/ede5282c487a1fd2de64303ba59adad6726f1225.tar.gz"; - type = "tarball"; - flake = false; - }; - static-haskell-nix = { - url = "github:nh2/static-haskell-nix"; - flake = false; - }; + nixpkgs.url = "github:NixOS/nixpkgs"; flake-utils.url = "github:numtide/flake-utils"; }; - outputs = { self, flake-utils, nh2pkgs, nixpkgs, static-haskell-nix }: + outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system: let - compiler = "ghc948"; - packageName = "tricu"; + pkgs = nixpkgs.legacyPackages.${system}; + packageName = "tricu"; + containerPackageName = "${packageName}-container"; - overlay = self: super: { - haskell = super.haskell // { - packages = super.haskell.packages // { - ${compiler} = super.haskell.packages.${compiler}.override { - overrides = final: prev: { - ${packageName} = prev.callCabal2nix packageName ./. {}; - }; - }; - }; - }; - }; + customGHC = pkgs.haskellPackages.ghcWithPackages (hpkgs: with hpkgs; [ + megaparsec + ]); - overlays = [overlay]; + haskellPackages = pkgs.haskellPackages; - pkgs = import nh2pkgs { inherit overlays system; }; - - survey = import "${static-haskell-nix}/survey" { inherit compiler pkgs; }; - - tricuStatic = survey.haskellPackages.${packageName}; + enableSharedExecutables = false; + enableSharedLibraries = false; + tricu = pkgs.haskell.lib.justStaticExecutables self.packages.${system}.default; in { - packages.default = tricuStatic; + + packages.${packageName} = + haskellPackages.callCabal2nix packageName self rec {}; + + packages.default = self.packages.${system}.${packageName}; + defaultPackage = self.packages.${system}.default; devShells.default = pkgs.mkShell { - buildInputs = with survey; [ + buildInputs = with pkgs; [ haskellPackages.cabal-install haskellPackages.ghc-events haskellPackages.ghcid - ] ++ [pkgs.upx]; + customGHC + upx + ]; inputsFrom = builtins.attrValues self.packages.${system}; }; devShell = self.devShells.${system}.default; + }); } - diff --git a/src/REPL.hs b/src/REPL.hs index 76e5050..3966cb5 100644 --- a/src/REPL.hs +++ b/src/REPL.hs @@ -6,23 +6,22 @@ import Lexer import Parser import Research -import Control.Exception (IOException, SomeException, catch, displayException) +import Control.Exception (IOException, SomeException, catch + , displayException) import Control.Monad (forM_) -import Control.Monad.IO.Class (liftIO) import Control.Monad.Catch (handle, MonadCatch) +import Control.Monad.IO.Class (liftIO) import Control.Monad.Trans.Class (lift) import Control.Monad.Trans.Maybe (MaybeT(..), runMaybeT) import Data.Char (isSpace, isUpper) -import Data.List ( dropWhile - , dropWhileEnd - , isPrefixOf) -import System.Console.Haskeline -import Paths_tricu (version) +import Data.List (dropWhile, dropWhileEnd, isPrefixOf) import Data.Version (showVersion) -import qualified Data.Text as T -import qualified Data.Text.IO as T +import Paths_tricu (version) +import System.Console.Haskeline import qualified Data.Map as Map +import qualified Data.Text as T +import qualified Data.Text.IO as T repl :: Env -> IO () repl env = runInputT settings (withInterrupt (loop env Decode))