Skip to content

Commit

Permalink
Added a flake build instead of shell.nix
Browse files Browse the repository at this point in the history
  • Loading branch information
The1Penguin committed Sep 27, 2023
1 parent 2f723e0 commit e59eda0
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 64 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ cabal.sandbox.config
.*.swp
*.log
*.dump-hi
.direnv/
.envrc
dist-newstyle/
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 82 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
description = "mat-chalmers goes flakes";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

nixConfig.allow-import-from-derivation = true; # cabal2nix uses IFD

outputs = { self, nixpkgs, flake-utils }:
let
ghcVer = "ghc810";
makeHaskellOverlay = overlay: final: prev: {
haskell = prev.haskell // {
packages = prev.haskell.packages // {
${ghcVer} = prev.haskell.packages."${ghcVer}".override (oldArgs: {
overrides =
prev.lib.composeExtensions (oldArgs.overrides or (_: _: { }))
(overlay prev);
});
};
};
};

out = system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
config.allowBroken = true;
};

in
{
packages = rec {
default = mat;
mat = pkgs.haskell.packages.${ghcVer}.mat;
};

checks = {
inherit (self.packages.${system}) mat;
};

# for debugging
# inherit pkgs;

devShells.default =
let haskellPackages = pkgs.haskell.packages.${ghcVer};
in
haskellPackages.shellFor {
packages = p: [ self.packages.${system}.mat ];
withHoogle = true;
buildInputs =
[ pkgs.docker ] ++
(with haskellPackages; [
haskell-language-server
cabal-install
]);
# Change the prompt to show that you are in a devShell
# shellHook = "export PS1='\\e[1;34mdev > \\e[0m'";
};
};
in
flake-utils.lib.eachDefaultSystem out // {
# this stuff is *not* per-system
overlays = {
default = makeHaskellOverlay (prev: hfinal: hprev:
let hlib = prev.haskell.lib; in
{
mat = hprev.callCabal2nix "mat" ./. { };

# here's how to do hacks to the package set
# don't run the test suite
# fast-tags = hlib.dontCheck hprev.fast-tags;
#
# don't check version bounds
# friendly = hlib.doJailbreak hprev.friendly;
});
};
};
}
18 changes: 9 additions & 9 deletions mat-chalmers.cabal
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cabal-version: 3.0
name: mat-chalmers
version: 0.1.0.0
license: MIT
Expand All @@ -6,7 +7,6 @@ author: Adam Sandberg Eriksson
maintainer: [email protected]
category: Web
build-type: Simple
cabal-version: >=1.10
data-files:
static/style.css
static/icon.png
Expand Down Expand Up @@ -35,17 +35,17 @@ library
, exceptions == 0.10.4
, heredoc == 0.2.0.0
, http-client
, http-client-tls == 0.3.5.3
, logging-effect == 1.3.12
, http-client-tls
, logging-effect
, microlens-platform
, lucid >= 2
, mtl == 2.2.2
, old-locale == 1.0.0.7
, prettyprinter == 1.7.1
, safe == 0.3.19
, tagsoup == 0.14.8
, text == 1.2.4.1
, bytestring == 0.10.12.0
, text
, bytestring
, file-embed
, thyme
, word8 == 0.1.3
Expand All @@ -58,12 +58,12 @@ executable mat-chalmers
, base >= 4.7
, bytestring
, file-embed
, http-client-tls == 0.3.5.3
, http-client-tls
, microlens-platform
, logging-effect
, mtl
, scotty
, time == 1.9.3
, time
, wai-extra
, wai-middleware-static-embedded == 0.1.0.0
, async >= 2.1.1
Expand All @@ -77,7 +77,7 @@ Test-Suite test-mat
build-depends: base >= 4.7
, bytestring
, mat-chalmers
, hspec == 2.7.10
, hspec
, HUnit == 1.6.2.0
, text
, thyme == 0.3.5.5
, thyme
44 changes: 0 additions & 44 deletions shell.nix

This file was deleted.

20 changes: 9 additions & 11 deletions src/View.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{-# LANGUAGE OverloadedStrings, TemplateHaskell, RecordWildCards #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TemplateHaskell #-}

module View
( View(..)
Expand All @@ -7,20 +9,16 @@ module View
where

import Data.FileEmbed
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.Builder as T
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.Builder as T
import Data.Thyme
import Lens.Micro.Platform ( (&)
, (%~)
, both
)
import Lens.Micro.Platform (both, (%~), (&))
import Lucid
import System.Locale ( defaultTimeLocale )
import qualified Text.CSS.Parse as CSS
import qualified Text.CSS.Render as CSS
import qualified Text.CSS.Parse as CSS
import qualified Text.CSS.Render as CSS

import Model
import Model.Types ( NoMenu(..) )
import Model.Types (NoMenu (..))

render :: View -> T.Text
render v = renderText (renderView v)
Expand Down

0 comments on commit e59eda0

Please sign in to comment.