- Switch from `cabal2nix` and haskell overlay to `developPackage`
- Restructure directories to have more descriptive names
- Fix `nix run`
main
Oystein Kristoffer Tveit 2023-03-11 16:51:23 +01:00
parent 669ded6d45
commit dcdf36f4dd
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
104 changed files with 51 additions and 232 deletions

View File

@ -2,16 +2,16 @@
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1667254466,
"narHash": "sha256-YrMQzDVOo+uz5gg1REj2q/uVhJE3WcpkqGiMzh3Da3o=",
"lastModified": 1678426640,
"narHash": "sha256-3Q4KN0XAXQT7YE3A8n3LzLtRNUCo0U++W3gl+5NhKHs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "1b4722674c315de0e191d0d79790b4eac51570a1",
"rev": "824f886682fc893e6dbf27114e5001ebf2770ea1",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-22.05",
"ref": "nixos-22.11",
"type": "indirect"
}
},

View File

@ -1,54 +1,55 @@
{
description = "hakyll-nix-template";
inputs.nixpkgs.url = "nixpkgs/nixos-22.11";
nixConfig.bash-prompt = "[nix]λ ";
inputs.nixpkgs.url = "nixpkgs/nixos-22.05";
outputs = { nixpkgs, self }: let
outputs = { self, nixpkgs }: let
system = "x86_64-linux";
overlays = [ (import ./nix/haskell-overlay.nix) ];
pkgs = import nixpkgs { inherit overlays system; };
pkgs = nixpkgs.legacyPackages.${system};
in {
overlays = {
haskell-overlay = import ./nix/haskell-overlay.nix;
default = self.overlays.haskell-overlay;
};
packages.${system} = {
static-site-generator = pkgs.haskellPackages.developPackage {
name = "static-site-generator";
root = ./.;
};
packages.${system} = with pkgs.myHaskellPackages; {
inherit ssg website;
default = website;
default = self.packages.${system}.website;
website = pkgs.stdenvNoCC.mkDerivation {
name = "website";
buildInputs = with pkgs; [
self.packages.${system}.static-site-generator
graphviz
];
src = pkgs.nix-gitignore.gitignoreSourcePure [
".gitignore"
".git"
".github"
] ./.;
buildPhase = ''
hakyll-site build --verbose
'';
installPhase = ''
cp -r dist "$out"
'';
};
};
apps.${system} = {
hakyll-site = let
drv = self.packages.${system}.ssg;
exePath = "/bin/hakyll-site";
default = self.apps.${system}.watch-hakyll-site;
watch-hakyll-site = let
ssg = self.packages.${system}.static-site-generator;
drv = pkgs.writeScriptBin "watch-hakyll-site" ''
${ssg}/bin/static-site-generator watch
'';
in {
type = "app";
program = "${drv}${exePath}";
program = "${drv}/bin/watch-hakyll-site";
};
default = self.apps.${system}.hakyll-site;
};
devShells.${system}.default = pkgs.myHaskellPackages.shellFor {
packages = p: [ p.ssg ];
buildInputs = with pkgs.myHaskellPackages; [
# ssg
# Helpful tools for `nix develop` shells
ghcid # https://github.com/ndmitchell/ghcid
haskell-language-server # https://github.com/haskell/haskell-language-server
hlint # https://github.com/ndmitchell/hlint
ormolu # https://github.com/tweag/ormolu
];
withHoogle = true;
};
hydraJobs = {
ssg.${system} = self.packages.${system}.ssg;
static-site-generator.${system} = self.packages.${system}.static-site-generator;
website.${system} = self.packages.${system}.website;
};
};

View File

View File

@ -1,68 +0,0 @@
final: prev:
let
inherit (prev.stdenv) mkDerivation;
inherit (prev.lib.trivial) flip pipe;
inherit (prev.haskell.lib)
appendPatch
appendConfigureFlags
dontCheck
doJailbreak;
withPatch = flip appendPatch;
withFlags = flip appendConfigureFlags;
haskellCompiler = "ghc884";
in {
myHaskellPackages = prev.haskell.packages.${haskellCompiler}.override {
overrides = hpFinal: hpPrev:
rec {
hakyll = pipe hpPrev.hakyll [
doJailbreak
dontCheck
# (withPatch ./hakyll.patch)
(withFlags [ "-f" "watch" ])
];
pandoc = pipe hpPrev.pandoc [
doJailbreak
dontCheck
];
slugger = hpPrev.slugger;
ssg = hpPrev.callCabal2nix "ssg" ../ssg {};
website = prev.stdenv.mkDerivation {
#__contentAddressed = true; # uncomment if using cas: https://www.tweag.io/blog/2020-09-10-nix-cas/
name = "website";
buildInputs = [
ssg
final.graphviz
];
src = prev.nix-gitignore.gitignoreSourcePure [
../.gitignore
"../.git"
"../.github"
] ../.;
# LANG and LOCALE_ARCHIVE are fixes pulled from the community:
# https://github.com/jaspervdj/hakyll/issues/614#issuecomment-411520691
# https://github.com/NixOS/nix/issues/318#issuecomment-52986702
# https://github.com/MaxDaten/brutal-recipes/blob/source/default.nix#L24
LANG = "en_US.UTF-8";
LOCALE_ARCHIVE = prev.lib.optionalString
(prev.buildPlatform.libc == "glibc")
"${prev.glibcLocales}/lib/locale/locale-archive";
buildPhase = ''
hakyll-site build --verbose
'';
installPhase = ''
mkdir -p "$out"
cp -r dist/* "$out"
'';
};
};
};
}

View File

@ -1,55 +0,0 @@
{ pkgs ? import <nixpkgs> {} }:
with pkgs.stdenv.lib;
let
name = "pure-css";
version = "v2.0.6";
# pull in the code for building npm packages
nodePackages = import ./npm-packages.nix {
inherit pkgs;
inherit (pkgs) stdenv nodejs fetchurl fetchgit;
neededNatives = [ pkgs.python ] ++ pkgs.lib.optional
pkgs.stdenv.isLinux pkgs.utillinux;
self = nodePackages;
};
buildModules = [
nodePackages."bower"
nodePackages."grunt"
nodePackages."grunt-cli"
nodePackages."grunt-contrib-cssmin"
nodePackages."grunt-contrib-clean"
nodePackages."grunt-contrib-copy"
nodePackages."grunt-contrib-concat"
nodePackages."grunt-contrib-compress"
nodePackages."grunt-contrib-csslint"
nodePackages."grunt-contrib-watch"
nodePackages."grunt-css-selectors"
nodePackages."grunt-pure-grids"
nodePackages."grunt-stripmq"
];
in pkgs.stdenv.mkDerivation {
name = "${name}-${version}";
src = pkgs.fetchgit {
url = https://github.com/pure-css/pure;
rev = "refs/tags/v2.0.6";
sha256 =
"049ac2ef812771852978d11cd5aecac2dd561e97bb16ad89c79eb1e10aa57672";
};
buildInputs = buildModules;
buildCommand = ''
cp -r $src src
chmod +w src
cd src
grunt
'';
}

View File

@ -1,30 +0,0 @@
{ pkgs, stdenv, nodejs, fetchurl, fetchgit, neededNatives, self }:
rec {
nativeDeps = {};
buildNodePackage = import
"${pkgs.path}/pkgs/development/web/nodejs/build-node-package.nix" {
inherit stdenv nodejs neededNatives;
inherit (pkgs) runCommand;
};
patchSource = fn: srcAttrs:
let src = fn srcAttrs; in pkgs.runCommand src.name {} ''
mkdir unpack
cd unpack
unpackFile ${src}
chmod -R +w */
mv */ package 2>/dev/null || true
sed -i -e "s/:\s*\"latest\"/: \"*\"/" -e
"s/:\s*\"\(https\?\|git\(\+\(ssh\|http\|https\)\)\?\):\/\/[^\"]*\"/:
\"*\"/" package/package.json
mv */ $out
'';
# Backwards compat
patchLatest = patchSource fetchurl;
} // import ./purecss-npm-generated.nix { inherit self fetchurl fetchgit;
inherit (pkgs) lib; }

View File

@ -1,29 +0,0 @@
BSD 3-Clause License
Copyright (c) 2020, Robert Pearce
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,14 +1,14 @@
cabal-version: 2.4
name: ssg
name: static-site-generator
version: 0.1.0.0
build-type: Simple
license: BSD-3-Clause
license-file: LICENSE
executable hakyll-site
executable static-site-generator
main-is: Main.hs
hs-source-dirs: src
hs-source-dirs: static-site-generator
build-depends: base >= 4.8
, hakyll >= 4.15
, pandoc >= 2.14

View File

@ -38,7 +38,7 @@ root =
siteName :: String
siteName =
"Nani~"
"Nani"
config :: Configuration
config =
@ -47,9 +47,9 @@ config =
, ignoreFile = const False
, previewHost = "127.0.0.1"
, previewPort = 8000
, providerDirectory = "src"
, storeDirectory = "ssg/_cache"
, tmpDirectory = "ssg/_tmp"
, providerDirectory = "www"
, storeDirectory = "/tmp/nani-wtf-hakyll/store"
, tmpDirectory = "/tmp/nani-wtf-hakyll/tmp"
}
--------------------------------------------------------------------------------
@ -57,7 +57,7 @@ config =
main :: IO ()
main = hakyllWith config $ do
fileHashes <- preprocess (mapKeys (fromFilePath . drop 4 . toFilePath) <$> mkFileHashes "src/posts")
fileHashes <- preprocess (mapKeys (fromFilePath . drop 4 . toFilePath) <$> mkFileHashes "www/posts")
forM_
[ "CNAME"
@ -279,4 +279,4 @@ feedConfiguration =
, feedAuthorName = "h7x4"
, feedAuthorEmail = "h7x4@protonmail.com"
, feedRoot = root
}
}

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Before

Width:  |  Height:  |  Size: 256 KiB

After

Width:  |  Height:  |  Size: 256 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

View File

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 786 B

After

Width:  |  Height:  |  Size: 786 B

View File

Before

Width:  |  Height:  |  Size: 855 B

After

Width:  |  Height:  |  Size: 855 B

View File

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

Before

Width:  |  Height:  |  Size: 404 B

After

Width:  |  Height:  |  Size: 404 B

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

Before

Width:  |  Height:  |  Size: 401 B

After

Width:  |  Height:  |  Size: 401 B

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
www/images/nani.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Some files were not shown because too many files have changed in this diff Show More