Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
58f5a861f3 | ||
|
|
4bbc31f41b | ||
|
|
3ff0dc79d5 | ||
|
|
911e0f5f4f | ||
|
|
11ed38d364 | ||
|
|
7d7f628175 |
+9
-1
@@ -13,6 +13,9 @@
|
|||||||
|
|
||||||
module Main (main) where
|
module Main (main) where
|
||||||
|
|
||||||
|
import Control.DeepSeq (force)
|
||||||
|
import Control.Exception (evaluate)
|
||||||
|
import Control.Monad (void)
|
||||||
import Data.Char (chr)
|
import Data.Char (chr)
|
||||||
import Data.FileEmbed (embedFile)
|
import Data.FileEmbed (embedFile)
|
||||||
import Data.Foldable (for_)
|
import Data.Foldable (for_)
|
||||||
@@ -55,7 +58,12 @@ import qualified UToy.Names as Names
|
|||||||
import qualified UToy.Parsers as Parsers
|
import qualified UToy.Parsers as Parsers
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = Warp.run 3000 app
|
main = do
|
||||||
|
-- Forced evaluation of Names.lowerNames to reduce number of thunks.
|
||||||
|
putStrLn "* Building search index"
|
||||||
|
void $ evaluate $ force Names.lowerNames
|
||||||
|
putStrLn "* Listening on http://localhost:3000"
|
||||||
|
Warp.run 3000 app
|
||||||
|
|
||||||
app :: Application
|
app :: Application
|
||||||
app = serve (Proxy :: Proxy API) server
|
app = serve (Proxy :: Proxy API) server
|
||||||
|
|||||||
Generated
+38
-4
@@ -1,25 +1,59 @@
|
|||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
|
"flake-utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1731533236,
|
||||||
|
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1703693486,
|
"lastModified": 1751290243,
|
||||||
"narHash": "sha256-tuzNTOs+1zR2BEVKKrRRGdpR/n095AXIcT8Me1px2bI=",
|
"narHash": "sha256-kNf+obkpJZWar7HZymXZbW+Rlk3HTEIMlpc6FCNz0Ds=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "671c2d3e1506a7ee1583515ca80cb3474fdc9c95",
|
"rev": "5ab036a8d97cb9476fbe81b09076e6e91d15e1b6",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"ref": "release-23.11",
|
"ref": "release-24.11",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"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",
|
"root": "root",
|
||||||
|
|||||||
@@ -1,37 +1,79 @@
|
|||||||
{
|
{
|
||||||
description = "Unicode toy";
|
description = "Unicode toy";
|
||||||
|
|
||||||
inputs.nixpkgs.url = "github:nixos/nixpkgs/release-23.11";
|
inputs.nixpkgs.url = "github:nixos/nixpkgs/release-24.11";
|
||||||
|
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
|
||||||
outputs = { self, nixpkgs }:
|
outputs = { self, nixpkgs, flake-utils }:
|
||||||
let
|
flake-utils.lib.eachSystem ["x86_64-linux" "aarch64-linux" "aarch64-darwin"] (system:
|
||||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
let
|
||||||
|
pkgs = import nixpkgs { inherit system; };
|
||||||
|
|
||||||
utoy = pkgs.haskellPackages.developPackage {
|
inherit (pkgs.haskell.lib) compose;
|
||||||
root = ./.;
|
|
||||||
};
|
|
||||||
in {
|
|
||||||
packages.x86_64-linux = rec {
|
|
||||||
docker =
|
|
||||||
pkgs.dockerTools.buildImage {
|
|
||||||
name = "git.pbrinkmeier.de/paul/utoy";
|
|
||||||
tag = utoy.version;
|
|
||||||
config.Cmd = [ "${pkgs.haskell.lib.justStaticExecutables utoy}/bin/utoy" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
default = utoy;
|
# Fix broken unicode-data-names by overriding the version of the unicode-data package.
|
||||||
};
|
haskellPackagesOverrides = self: super: {
|
||||||
|
unicode-data = super.unicode-data_0_6_0;
|
||||||
|
unicode-data-names = pkgs.haskell.lib.markUnbroken super.unicode-data-names;
|
||||||
|
};
|
||||||
|
|
||||||
devShells.x86_64-linux.default =
|
utoy = pkgs.lib.pipe
|
||||||
(pkgs.haskellPackages.developPackage {
|
# The basic package
|
||||||
root = ./.;
|
(pkgs.haskellPackages.developPackage {
|
||||||
modifier = drv:
|
root = ./.;
|
||||||
pkgs.haskell.lib.addBuildTools drv [
|
overrides = haskellPackagesOverrides;
|
||||||
pkgs.cabal-install
|
})
|
||||||
pkgs.haskellPackages.implicit-hie
|
# And some build configuration.
|
||||||
pkgs.haskell-language-server
|
# See https://nixos.org/manual/nixpkgs/unstable/#haskell-packaging-helpers.
|
||||||
];
|
[
|
||||||
cabal2nixOptions = "--benchmark";
|
# Configurable static build. Set cabal options...
|
||||||
}).env;
|
compose.disableSharedExecutables
|
||||||
};
|
compose.disableSharedLibraries
|
||||||
|
# ... and link required static libraries.
|
||||||
|
(compose.appendConfigureFlags [
|
||||||
|
"--ghc-option=-optl=-static"
|
||||||
|
"--ghc-option=-optl=-pthread"
|
||||||
|
"--extra-lib-dirs=${pkgs.gmp6.override { withStatic = true; }}/lib"
|
||||||
|
"--extra-lib-dirs=${pkgs.zlib.static}/lib"
|
||||||
|
"--extra-lib-dirs=${pkgs.glibc.static}/lib"
|
||||||
|
"--extra-lib-dirs=${pkgs.libffi.overrideAttrs (old: { dontDisableStatic = true; })}/lib"
|
||||||
|
])
|
||||||
|
# Remove all references to the Nix store from the executable.
|
||||||
|
# This is important because Nix uses the references for calculating
|
||||||
|
# what needs to be in the Docker container.
|
||||||
|
# FIXME: Using static linking, these references shouldn't even still be there.
|
||||||
|
# Can we somehow make GHC stop emitting them?
|
||||||
|
(compose.overrideCabal (drv: {
|
||||||
|
postInstall = ''
|
||||||
|
${pkgs.nukeReferences}/bin/nuke-refs $out/bin/utoy
|
||||||
|
'';
|
||||||
|
}))
|
||||||
|
# Return only the bin folder to curb image size.
|
||||||
|
compose.justStaticExecutables
|
||||||
|
];
|
||||||
|
in {
|
||||||
|
packages = rec {
|
||||||
|
docker =
|
||||||
|
pkgs.dockerTools.buildImage {
|
||||||
|
name = "git.pbrinkmeier.de/paul/utoy";
|
||||||
|
tag = utoy.version;
|
||||||
|
config.Cmd = [ "${utoy}/bin/utoy" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
default = utoy;
|
||||||
|
};
|
||||||
|
|
||||||
|
devShells.default =
|
||||||
|
(pkgs.haskellPackages.developPackage {
|
||||||
|
root = ./.;
|
||||||
|
overrides = haskellPackagesOverrides;
|
||||||
|
modifier = drv:
|
||||||
|
pkgs.haskell.lib.addBuildTools drv [
|
||||||
|
pkgs.cabal-install
|
||||||
|
pkgs.haskellPackages.implicit-hie
|
||||||
|
pkgs.haskell-language-server
|
||||||
|
];
|
||||||
|
cabal2nixOptions = "--benchmark";
|
||||||
|
}).env;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -1,4 +1,4 @@
|
|||||||
module UToy.Names (allNames, blockName, searchCaseInsensitive) where
|
module UToy.Names (allNames, blockName, lowerNames, searchCaseInsensitive) where
|
||||||
|
|
||||||
import Data.Char (ord)
|
import Data.Char (ord)
|
||||||
import Data.Maybe (maybeToList)
|
import Data.Maybe (maybeToList)
|
||||||
@@ -25,7 +25,7 @@ searchCaseInsensitive search = filter go [minBound..maxBound]
|
|||||||
go c = any matches $ Vector.unsafeIndex lowerNames (ord c - ord minBound)
|
go c = any matches $ Vector.unsafeIndex lowerNames (ord c - ord minBound)
|
||||||
matches t = Text.toLower search `Text.isInfixOf` t
|
matches t = Text.toLower search `Text.isInfixOf` t
|
||||||
|
|
||||||
lowerNames :: Vector [Text]
|
lowerNames :: Vector (Vector Text)
|
||||||
lowerNames = Vector.fromList $ map go [minBound..maxBound]
|
lowerNames = Vector.fromList $ map go [minBound..maxBound]
|
||||||
where
|
where
|
||||||
go = map Text.toLower . allNames
|
go = Vector.fromList . map Text.toLower . allNames
|
||||||
|
|||||||
+2
-1
@@ -1,7 +1,7 @@
|
|||||||
cabal-version: 1.12
|
cabal-version: 1.12
|
||||||
|
|
||||||
name: utoy
|
name: utoy
|
||||||
version: 0.6.2
|
version: 0.6.3
|
||||||
author: Paul Brinkmeier
|
author: Paul Brinkmeier
|
||||||
maintainer: hallo@pbrinkmeier.de
|
maintainer: hallo@pbrinkmeier.de
|
||||||
copyright: 2023 Paul Brinkmeier
|
copyright: 2023 Paul Brinkmeier
|
||||||
@@ -46,6 +46,7 @@ executable utoy
|
|||||||
, base >=4.7 && <5
|
, base >=4.7 && <5
|
||||||
, blaze-html
|
, blaze-html
|
||||||
, bytestring
|
, bytestring
|
||||||
|
, deepseq
|
||||||
, file-embed
|
, file-embed
|
||||||
, http-media
|
, http-media
|
||||||
, servant-server
|
, servant-server
|
||||||
|
|||||||
Reference in New Issue
Block a user