set up hakyll

This commit is contained in:
Gregor Kleen 2023-05-11 09:50:56 +02:00
commit faec92ae37
12 changed files with 365 additions and 0 deletions

4
.dir-locals.el Normal file
View File

@ -0,0 +1,4 @@
;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")
((haskell-mode . ((tab-width . 4))))

1
.envrc Normal file
View File

@ -0,0 +1 @@
use flake

15
.gitignore vendored Normal file
View File

@ -0,0 +1,15 @@
**/.direnv
**/result
**/result-*
.stack-work
_cache
_site
**/#*#
**/.#*
.pre-commit-config.yaml
uniworx-de.cabal

1
content/index.html Normal file
View File

@ -0,0 +1 @@
<span class="red">Hello World</span>

170
flake.lock Normal file
View File

@ -0,0 +1,170 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1683560683,
"narHash": "sha256-XAygPMN5Xnk/W2c1aW0jyEa6lfMDZWlQgiNtmHXytPc=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "006c75898cf814ef9497252b022e91c946ba8e17",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks-nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1660459072,
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1683786124,
"narHash": "sha256-0NdMJ09GrR8NulIQSThytukQrTz2oDcsczMUy2u/qKg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "0bda75b5203a0a8bdad82a787039e8c8bc0a8746",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1682879489,
"narHash": "sha256-sASwo8gBt7JDnOOstnps90K1wxmVfyhsTPPNTGBPjjg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "da45bf6ec7bbcc5d1e14d3795c025199f28e0de0",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1678872516,
"narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9b8e5abb18324c7fe9f07cb100c3cd4a29cda8b8",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-22.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1681303793,
"narHash": "sha256-JEdQHsYuCfRL2PICHlOiH/2ue3DwoxUX7DJ6zZxZXFk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "fe2ecaf706a5907b5e54d979fbde4924d84b65fc",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks-nix": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"gitignore": "gitignore",
"nixpkgs": "nixpkgs_2",
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1682596858,
"narHash": "sha256-Hf9XVpqaGqe/4oDGr30W8HlsWvJXtMsEPHDqHZA6dDg=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "fb58866e20af98779017134319b5663b8215d912",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs",
"pre-commit-hooks-nix": "pre-commit-hooks-nix"
}
}
},
"root": "root",
"version": 7
}

90
flake.nix Normal file
View File

@ -0,0 +1,90 @@
{
inputs = {
nixpkgs = {
type = "github";
owner = "NixOS";
repo = "nixpkgs";
};
flake-parts = {
type = "github";
owner = "hercules-ci";
repo = "flake-parts";
};
pre-commit-hooks-nix = {
type = "github";
owner = "cachix";
repo = "pre-commit-hooks.nix";
};
};
outputs = inputs @ {
self,
nixpkgs,
flake-parts,
pre-commit-hooks-nix,
...
}:
flake-parts.lib.mkFlake
{inherit inputs;}
({...}: {
imports = [
pre-commit-hooks-nix.flakeModule
];
config = {
systems = ["x86_64-linux"];
perSystem = {
system,
config,
pkgs,
...
}: {
devShells.default = pkgs.mkShell {
packages = with pkgs; [
(pkgs.symlinkJoin {
inherit (stack) name;
paths = [stack];
nativeBuildInputs = [makeWrapper];
postBuild = ''
wrapProgram $out/bin/stack \
--add-flags "\
--nix \
--no-nix-pure \
--nix-shell-file=${pkgs.writeText "shell.nix" ''
{ ghc }:
with (import <nixpkgs> {});
haskell.lib.buildStackProject {
inherit ghc;
name = "uniworx-de";
buildInputs = [ zlib ];
}
''} \
--nix-path=nixpkgs=${nixpkgs} \
"
'';
})
];
shellHook = ''
${config.pre-commit.installationScript}
'';
};
pre-commit = {
settings.hooks = {
alejandra.enable = true;
fourmolu.enable = true;
};
};
packages = {
};
};
};
});
}

1
fourmolu.yaml Normal file
View File

@ -0,0 +1 @@
indentation: 2

28
package.yaml Normal file
View File

@ -0,0 +1,28 @@
name: uniworx-de
version: 1.0.0
default-extensions:
- OverloadedStrings
- NoImplicitPrelude
- ViewPatterns
executables:
site:
main: Main
source-dirs: src
ghc-options:
- -threaded
- -Werror
- -Wall
- -Wmissing-home-modules
- -Wredundant-constraints
- -Widentities
- -Wincomplete-uni-patterns
- -fwarn-tabs
- -j
dependencies:
- base
- hakyll
- filepath

28
src/Main.hs Normal file
View File

@ -0,0 +1,28 @@
module Main (main) where
import Prelude
import Hakyll
import qualified Data.List as List
import Data.Maybe
import System.FilePath
config :: Configuration
config = defaultConfiguration
stripPathPrefix :: FilePath -> Routes
stripPathPrefix (splitDirectories -> prefix) =
customRoute $
joinPath . (\x -> fromMaybe x $ List.stripPrefix prefix x) . splitDirectories . toFilePath
main :: IO ()
main = hakyllWith config $ do
match "content/index.html" $ do
route $ stripPathPrefix "content"
compile $ do
getResourceBody
>>= loadAndApplyTemplate "templates/site-layout.html" defaultContext
match "templates/*" $ compile templateBodyCompiler

3
stack.yaml Normal file
View File

@ -0,0 +1,3 @@
resolver: lts-20.20
packages:
- .

12
stack.yaml.lock Normal file
View File

@ -0,0 +1,12 @@
# This file was autogenerated by Stack.
# You should not edit this file by hand.
# For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files
packages: []
snapshots:
- completed:
sha256: 126fa33ceb11f5e85ceb4e86d434756bd9a8439e2e5776d306a15fbc63b01e89
size: 650041
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/20/20.yaml
original: lts-20.20

View File

@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
$body$
</body>
</html>