Reshuffle the files for better nix organization

This commit is contained in:
Mats Rauhala 2021-01-25 18:19:17 +02:00
parent 712b61059f
commit c62ff908af
31 changed files with 74 additions and 67 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
_site/
_cache/
dist/
dist-newstyle/
result*

View File

@ -1,3 +1,8 @@
{ haskellPackages, haskell }:
{ pkgs ? import <nixpkgs> {} }:
haskell.lib.disableSharedExecutables (haskellPackages.callCabal2nix "site" ./. {})
with pkgs;
rec {
site = haskellPackages.callPackage ./site {};
rauhala-info = callPackage ./rauhala.info { site = site; };
}

1
rauhala.info/.envrc Normal file
View File

@ -0,0 +1 @@
use nix

2
rauhala.info/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
_site
_cache

24
rauhala.info/default.nix Normal file
View File

@ -0,0 +1,24 @@
{ stdenv, glibcLocales, site }:
stdenv.mkDerivation {
pname = "rauhala.info";
version = "0.1.0";
src = builtins.filterSource (path: type: baseNameOf path != "_cache" && baseNameOf path != "_site") ./.;
phases = ["buildPhase" "installPhase"];
buildPhase = ''
export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive"
export LANG=en_US.UTF-8
cp -r $src/* .
${site}/bin/site build
'';
installPhase = ''
mkdir -p $out/share/
cp -r _site/* $out/share/
'';
}

View File

Before

Width:  |  Height:  |  Size: 684 B

After

Width:  |  Height:  |  Size: 684 B

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

Before

Width:  |  Height:  |  Size: 485 B

After

Width:  |  Height:  |  Size: 485 B

View File

Before

Width:  |  Height:  |  Size: 684 B

After

Width:  |  Height:  |  Size: 684 B

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

10
rauhala.info/shell.nix Normal file
View File

@ -0,0 +1,10 @@
with (import <nixpkgs> {});
let site = haskellPackages.callPackage ../site {};
in
mkShell {
buildInputs = [ site ];
}

View File

@ -1,44 +0,0 @@
let
pin = builtins.fromJSON (builtins.readFile ./nixpkgs.json);
pinnedPkgs = with pin; import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
inherit sha256;
}) {};
in
{ pkgs ? pinnedPkgs }:
let
haskellPackages = pkgs.haskellPackages;
site = pkgs.callPackage ./default.nix {};
website = with pkgs; stdenv.mkDerivation {
pname = "rauhala.info";
version = "0.1.0";
src = lib.cleanSource ./.;
LANG = "en_US.UTF-8";
LOCALE_ARCHIVE = lib.optionalString stdenv.isLinux "${glibcLocales}/lib/locale/locale-archive";
buildPhase = ''
${site}/bin/site clean
${site}/bin/site build
'';
installPhase = ''
mkdir -p $out/share/
mv _site $out/share/html
'';
};
shell = pkgs.buildEnv {
name = "site-shell";
paths = [];
buildInputs = [
haskellPackages.ghcid
haskellPackages.hasktags
(haskellPackages.ghcWithHoogle (h: site.buildInputs ++ site.propagatedBuildInputs))
];
};
in
{
inherit site shell website;
}

View File

@ -1,2 +0,0 @@
(import ./release.nix {}).shell

1
site/.envrc Normal file
View File

@ -0,0 +1 @@
use nix

View File

@ -1,9 +1,6 @@
--------------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
import Data.Monoid (mappend)
import Hakyll
import Data.List (sortBy, sortOn)
import Data.Time (formatTime, defaultTimeLocale)
--------------------------------------------------------------------------------
@ -39,22 +36,6 @@ main = hakyllWith defaultConfiguration $ do
match "templates/*" $ compile templateBodyCompiler
modFirst :: [Item a] -> Compiler [Item a]
modFirst = fmap reverse . modified
where
modified = sortByM (getItemModificationTime . itemIdentifier)
sortByM f xs = map fst . sortOn snd <$> mapM (\x -> (,) x <$> f x) xs
--------------------------------------------------------------------------------
postCtx :: Context String
postCtx =
dateField "date" "%B %e, %Y" `mappend`
modifiedField "modified" "%B %e, %Y" `mappend`
defaultContext
where
modifiedField key format = field key $ \i -> do
time <- getItemModificationTime $ itemIdentifier i
return $ formatTime defaultTimeLocale format time
prepend :: a -> [a] -> [a]
prepend = (:)

10
site/default.nix Normal file
View File

@ -0,0 +1,10 @@
{ mkDerivation, base, hakyll, stdenv, time }:
mkDerivation {
pname = "site";
version = "0.1.0.0";
src = ./.;
isLibrary = false;
isExecutable = true;
executableHaskellDepends = [ base hakyll time ];
license = stdenv.lib.licenses.bsd3;
}

16
site/shell.nix Normal file
View File

@ -0,0 +1,16 @@
with (import <nixpkgs> {});
let site = haskellPackages.callPackage ./. {};
in
mkShell {
buildInputs = [
ghcid
stylish-haskell
haskellPackages.cabal-install
hlint
(haskellPackages.ghcWithPackages (_: site.buildInputs ++ site.propagatedBuildInputs))
];
}

View File

@ -9,6 +9,7 @@ maintainer: mats.rauhala@iki.fi
executable site
main-is: site.hs
hs-source-dirs: app
build-depends: base == 4.*
, hakyll >= 4.10
, time