Compare commits
4 commits
Author | SHA1 | Date | |
---|---|---|---|
389dfa71da | |||
ebe93d293f | |||
4f9041f463 | |||
b522d357d3 |
11
Dockerfile
Normal file
11
Dockerfile
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
FROM nixos/nix
|
||||||
|
|
||||||
|
RUN nix-channel --add https://nixos.org/channels/nixos-20.09 nixpkgs
|
||||||
|
RUN nix-channel --update
|
||||||
|
|
||||||
|
RUN nix-env -i git
|
||||||
|
RUN nix-env -i niv
|
||||||
|
|
||||||
|
RUN mkdir -p /home/her.esy.fun
|
||||||
|
COPY . /home/her.esy.fun
|
||||||
|
RUN cd /home/her.esy.fun && nix-shell
|
|
@ -371,11 +371,12 @@ genPdfAction _getPost out = do
|
||||||
["--pdf-engine=xelatex"
|
["--pdf-engine=xelatex"
|
||||||
, "--resource-path=" <> takeDirectory srcFile
|
, "--resource-path=" <> takeDirectory srcFile
|
||||||
, srcFile
|
, srcFile
|
||||||
|
, "--resource-path=."
|
||||||
, "-H", "engine" </> "deeplist.tex"
|
, "-H", "engine" </> "deeplist.tex"
|
||||||
, "-V", "mainfont:CMU Serif"
|
-- , "-V", "mainfont:CMU Serif"
|
||||||
, "-V", "mainfontoptions:Renderer=OpenType, Mapping=tex-text, ItalicFeatures={Alternate = 0}, Ligatures={Common,Rare,Historic,Contextual},Contextuals=Inner,Alternate=1"
|
-- , "-V", "mainfontoptions:Renderer=OpenType, Mapping=tex-text, ItalicFeatures={Alternate = 0}, Ligatures={Common,Rare,Historic,Contextual},Contextuals=Inner,Alternate=1"
|
||||||
, "-V", "monofont:Menlo"
|
-- , "-V", "monofont:Menlo"
|
||||||
, "-V", "monofontoptions:Scale=0.7"
|
-- , "-V", "monofontoptions:Scale=0.7"
|
||||||
, "-o", out ]
|
, "-o", out ]
|
||||||
|
|
||||||
|
|
||||||
|
|
4
engine/docker-build.sh
Executable file
4
engine/docker-build.sh
Executable file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
# Should build the docker image
|
||||||
|
docker build -t her.esy.fun .
|
8
engine/docker-run.sh
Executable file
8
engine/docker-run.sh
Executable file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
cd "$(git rev-parse --show-toplevel)" || exit 1
|
||||||
|
if (($#>0)); then
|
||||||
|
docker run --rm -v $PWD:/home/her.esy.fun -p 3000:3000 --name her.esy.fun -it her.esy.fun /bin/sh -c "cd /home/her.esy.fun && nix-shell --run '$*'"
|
||||||
|
else
|
||||||
|
docker run --rm -v $PWD:/home/her.esy.fun -p 3000:3000 --name her.esy.fun -it her.esy.fun
|
||||||
|
fi
|
|
@ -5,7 +5,7 @@ cd "$(git rev-parse --show-toplevel)" || exit 1
|
||||||
src="$1"
|
src="$1"
|
||||||
dst="$2"
|
dst="$2"
|
||||||
|
|
||||||
./engine/org2gemini_step1.sh "$src" | \
|
awk -f ./engine/org2gemini_step1.sh "$src" | \
|
||||||
perl -pe 's#^email:\s+yann\@esposito.host\s*#$&=> /files/publickey.txt gpg\n#g;' | \
|
perl -pe 's#^email:\s+yann\@esposito.host\s*#$&=> /files/publickey.txt gpg\n#g;' | \
|
||||||
perl -pe 's#\[\[([^]]*)\]\[([^]]*)\]\]#\n=> $1 $2#g;' | \
|
perl -pe 's#\[\[([^]]*)\]\[([^]]*)\]\]#\n=> $1 $2#g;' | \
|
||||||
perl -pe 's#=> file:([^ ]*)\.org#=> $1.gmi#g;' | \
|
perl -pe 's#=> file:([^ ]*)\.org#=> $1.gmi#g;' | \
|
||||||
|
|
|
@ -10,4 +10,4 @@ fi
|
||||||
|
|
||||||
cd $webdir && \
|
cd $webdir && \
|
||||||
echo "Serving: $webdir" && \
|
echo "Serving: $webdir" && \
|
||||||
sws -d --port 3000 .
|
http-server -p 3000
|
||||||
|
|
|
@ -29,7 +29,7 @@ executable her-esy-fun
|
||||||
|
|
||||||
-- LANGUAGE extensions used by modules in this package.
|
-- LANGUAGE extensions used by modules in this package.
|
||||||
-- other-extensions:
|
-- other-extensions:
|
||||||
build-depends: base ^>=4.14.1.0
|
build-depends: base
|
||||||
, aeson
|
, aeson
|
||||||
, pandoc
|
, pandoc
|
||||||
, pandoc-types
|
, pandoc-types
|
||||||
|
|
|
@ -1,38 +1,26 @@
|
||||||
{
|
{
|
||||||
"ghc.nix": {
|
|
||||||
"branch": "master",
|
|
||||||
"description": "Nix (shell) expression for working on GHC",
|
|
||||||
"homepage": "https://haskell.org/ghc/",
|
|
||||||
"owner": "alpmestan",
|
|
||||||
"repo": "ghc.nix",
|
|
||||||
"rev": "9adaf8abe53fa0618c1561919ddfbc4342fe144b",
|
|
||||||
"sha256": "0qmkkildzl21y88czgnschvi8mdkqrj9hgvpban58zzjnxw5s4nd",
|
|
||||||
"type": "tarball",
|
|
||||||
"url": "https://github.com/alpmestan/ghc.nix/archive/9adaf8abe53fa0618c1561919ddfbc4342fe144b.tar.gz",
|
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
|
||||||
},
|
|
||||||
"niv": {
|
"niv": {
|
||||||
"branch": "master",
|
"branch": "master",
|
||||||
"description": "Easy dependency management for Nix projects",
|
"description": "Easy dependency management for Nix projects",
|
||||||
"homepage": "https://github.com/nmattia/niv",
|
"homepage": "https://github.com/nmattia/niv",
|
||||||
"owner": "nmattia",
|
"owner": "nmattia",
|
||||||
"repo": "niv",
|
"repo": "niv",
|
||||||
"rev": "f73bf8d584148677b01859677a63191c31911eae",
|
"rev": "af958e8057f345ee1aca714c1247ef3ba1c15f5e",
|
||||||
"sha256": "0jlmrx633jvqrqlyhlzpvdrnim128gc81q5psz2lpp2af8p8q9qs",
|
"sha256": "1qjavxabbrsh73yck5dcq8jggvh3r2jkbr6b5nlz5d9yrqm9255n",
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://github.com/nmattia/niv/archive/f73bf8d584148677b01859677a63191c31911eae.tar.gz",
|
"url": "https://github.com/nmattia/niv/archive/af958e8057f345ee1aca714c1247ef3ba1c15f5e.tar.gz",
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"branch": "nixpkgs-20.09-darwin",
|
"branch": "nixos-20.09",
|
||||||
"description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
|
"description": "NixOS/nixpkgs repository instead.",
|
||||||
"homepage": "https://github.com/NixOS/nixpkgs",
|
"homepage": "https://github.com/NixOS/nixpkgs",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "e716ddfac4be879ffbae75c3914a538dd5d4d12e",
|
"rev": "4263ba5e133cc3fc699c1152ab5ee46ef668e675",
|
||||||
"sha256": "0c2090sz4nvd1bqa9bfz3b6mj0q8b7v4jzgsykn2hf291l3h94d6",
|
"sha256": "1nzqrdw0lhbldbs9r651zmgqpwhjhh9sssykhcl2155kgsfsrk7i",
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://github.com/NixOS/nixpkgs/archive/e716ddfac4be879ffbae75c3914a538dd5d4d12e.tar.gz",
|
"url": "https://github.com/NixOS/nixpkgs/archive/4263ba5e133cc3fc699c1152ab5ee46ef668e675.tar.gz",
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
},
|
},
|
||||||
"shake": {
|
"shake": {
|
||||||
|
@ -41,10 +29,10 @@
|
||||||
"homepage": "http://shakebuild.com",
|
"homepage": "http://shakebuild.com",
|
||||||
"owner": "ndmitchell",
|
"owner": "ndmitchell",
|
||||||
"repo": "shake",
|
"repo": "shake",
|
||||||
"rev": "4536d9ce5cef0e56395fd61ccef9816c9b420fd1",
|
"rev": "79a098c55f62de9efd851546435945b7f7f9b9df",
|
||||||
"sha256": "1s7hjhcc09l026jaca3ndbb103s9d7qlx4vqzx2s6j4rr751nd70",
|
"sha256": "15p7szja7ngvmw1jdfik4n6yli3cwzy9irb9wqkrkkdx7cg9vvk4",
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://github.com/ndmitchell/shake/archive/4536d9ce5cef0e56395fd61ccef9816c9b420fd1.tar.gz",
|
"url": "https://github.com/ndmitchell/shake/archive/79a098c55f62de9efd851546435945b7f7f9b9df.tar.gz",
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,25 +6,33 @@ let
|
||||||
# The fetchers. fetch_<type> fetches specs of type <type>.
|
# The fetchers. fetch_<type> fetches specs of type <type>.
|
||||||
#
|
#
|
||||||
|
|
||||||
fetch_file = pkgs: spec:
|
fetch_file = pkgs: name: spec:
|
||||||
|
let
|
||||||
|
name' = sanitizeName name + "-src";
|
||||||
|
in
|
||||||
if spec.builtin or true then
|
if spec.builtin or true then
|
||||||
builtins_fetchurl { inherit (spec) url sha256; }
|
builtins_fetchurl { inherit (spec) url sha256; name = name'; }
|
||||||
else
|
else
|
||||||
pkgs.fetchurl { inherit (spec) url sha256; };
|
pkgs.fetchurl { inherit (spec) url sha256; name = name'; };
|
||||||
|
|
||||||
fetch_tarball = pkgs: name: spec:
|
fetch_tarball = pkgs: name: spec:
|
||||||
let
|
let
|
||||||
ok = str: ! builtins.isNull (builtins.match "[a-zA-Z0-9+-._?=]" str);
|
name' = sanitizeName name + "-src";
|
||||||
# sanitize the name, though nix will still fail if name starts with period
|
|
||||||
name' = stringAsChars (x: if ! ok x then "-" else x) "${name}-src";
|
|
||||||
in
|
in
|
||||||
if spec.builtin or true then
|
if spec.builtin or true then
|
||||||
builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
|
builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
|
||||||
else
|
else
|
||||||
pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
|
pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
|
||||||
|
|
||||||
fetch_git = spec:
|
fetch_git = name: spec:
|
||||||
builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; };
|
let
|
||||||
|
ref =
|
||||||
|
if spec ? ref then spec.ref else
|
||||||
|
if spec ? branch then "refs/heads/${spec.branch}" else
|
||||||
|
if spec ? tag then "refs/tags/${spec.tag}" else
|
||||||
|
abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
|
||||||
|
in
|
||||||
|
builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; };
|
||||||
|
|
||||||
fetch_local = spec: spec.path;
|
fetch_local = spec: spec.path;
|
||||||
|
|
||||||
|
@ -40,11 +48,21 @@ let
|
||||||
# Various helpers
|
# Various helpers
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695
|
||||||
|
sanitizeName = name:
|
||||||
|
(
|
||||||
|
concatMapStrings (s: if builtins.isList s then "-" else s)
|
||||||
|
(
|
||||||
|
builtins.split "[^[:alnum:]+._?=-]+"
|
||||||
|
((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
# The set of packages used when specs are fetched using non-builtins.
|
# The set of packages used when specs are fetched using non-builtins.
|
||||||
mkPkgs = sources:
|
mkPkgs = sources: system:
|
||||||
let
|
let
|
||||||
sourcesNixpkgs =
|
sourcesNixpkgs =
|
||||||
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) {};
|
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; };
|
||||||
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
|
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
|
||||||
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
|
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
|
||||||
in
|
in
|
||||||
|
@ -64,9 +82,9 @@ let
|
||||||
|
|
||||||
if ! builtins.hasAttr "type" spec then
|
if ! builtins.hasAttr "type" spec then
|
||||||
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
|
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
|
||||||
else if spec.type == "file" then fetch_file pkgs spec
|
else if spec.type == "file" then fetch_file pkgs name spec
|
||||||
else if spec.type == "tarball" then fetch_tarball pkgs name spec
|
else if spec.type == "tarball" then fetch_tarball pkgs name spec
|
||||||
else if spec.type == "git" then fetch_git spec
|
else if spec.type == "git" then fetch_git name spec
|
||||||
else if spec.type == "local" then fetch_local spec
|
else if spec.type == "local" then fetch_local spec
|
||||||
else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
|
else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
|
||||||
else if spec.type == "builtin-url" then fetch_builtin-url name
|
else if spec.type == "builtin-url" then fetch_builtin-url name
|
||||||
|
@ -80,7 +98,10 @@ let
|
||||||
saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
|
saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
|
||||||
ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
|
ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
|
||||||
in
|
in
|
||||||
if ersatz == "" then drv else ersatz;
|
if ersatz == "" then drv else
|
||||||
|
# this turns the string into an actual Nix path (for both absolute and
|
||||||
|
# relative paths)
|
||||||
|
if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}";
|
||||||
|
|
||||||
# Ports of functions for older nix versions
|
# Ports of functions for older nix versions
|
||||||
|
|
||||||
|
@ -98,25 +119,29 @@ let
|
||||||
|
|
||||||
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
|
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
|
||||||
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
|
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
|
||||||
|
concatMapStrings = f: list: concatStrings (map f list);
|
||||||
concatStrings = builtins.concatStringsSep "";
|
concatStrings = builtins.concatStringsSep "";
|
||||||
|
|
||||||
|
# https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
|
||||||
|
optionalAttrs = cond: as: if cond then as else {};
|
||||||
|
|
||||||
# fetchTarball version that is compatible between all the versions of Nix
|
# fetchTarball version that is compatible between all the versions of Nix
|
||||||
builtins_fetchTarball = { url, name, sha256 }@attrs:
|
builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
|
||||||
let
|
let
|
||||||
inherit (builtins) lessThan nixVersion fetchTarball;
|
inherit (builtins) lessThan nixVersion fetchTarball;
|
||||||
in
|
in
|
||||||
if lessThan nixVersion "1.12" then
|
if lessThan nixVersion "1.12" then
|
||||||
fetchTarball { inherit name url; }
|
fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
|
||||||
else
|
else
|
||||||
fetchTarball attrs;
|
fetchTarball attrs;
|
||||||
|
|
||||||
# fetchurl version that is compatible between all the versions of Nix
|
# fetchurl version that is compatible between all the versions of Nix
|
||||||
builtins_fetchurl = { url, sha256 }@attrs:
|
builtins_fetchurl = { url, name ? null, sha256 }@attrs:
|
||||||
let
|
let
|
||||||
inherit (builtins) lessThan nixVersion fetchurl;
|
inherit (builtins) lessThan nixVersion fetchurl;
|
||||||
in
|
in
|
||||||
if lessThan nixVersion "1.12" then
|
if lessThan nixVersion "1.12" then
|
||||||
fetchurl { inherit url; }
|
fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
|
||||||
else
|
else
|
||||||
fetchurl attrs;
|
fetchurl attrs;
|
||||||
|
|
||||||
|
@ -135,7 +160,8 @@ let
|
||||||
mkConfig =
|
mkConfig =
|
||||||
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
|
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
|
||||||
, sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
|
, sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
|
||||||
, pkgs ? mkPkgs sources
|
, system ? builtins.currentSystem
|
||||||
|
, pkgs ? mkPkgs sources system
|
||||||
}: rec {
|
}: rec {
|
||||||
# The sources, i.e. the attribute set of spec name to spec
|
# The sources, i.e. the attribute set of spec name to spec
|
||||||
inherit sources;
|
inherit sources;
|
||||||
|
|
20
shell.nix
20
shell.nix
|
@ -1,16 +1,15 @@
|
||||||
let
|
let
|
||||||
sources = import ./nix/sources.nix;
|
sources = import ./nix/sources.nix;
|
||||||
pkgs = import sources.nixpkgs {};
|
pkgs = import sources.nixpkgs {};
|
||||||
pkgs1909 = import (fetchTarball https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz) {};
|
|
||||||
haskellDeps = ps : with ps; [
|
haskellDeps = ps : with ps; [
|
||||||
shake
|
shake
|
||||||
pandoc
|
pandoc
|
||||||
data-default
|
data-default
|
||||||
protolude
|
protolude
|
||||||
pkgs1909.haskellPackages.sws
|
|
||||||
stache
|
stache
|
||||||
turtle
|
turtle
|
||||||
ansi-terminal
|
ansi-terminal
|
||||||
|
time
|
||||||
];
|
];
|
||||||
ghc = pkgs.haskellPackages.ghcWithPackages haskellDeps;
|
ghc = pkgs.haskellPackages.ghcWithPackages haskellDeps;
|
||||||
in
|
in
|
||||||
|
@ -18,19 +17,30 @@ pkgs.mkShell {
|
||||||
buildInputs = with pkgs;
|
buildInputs = with pkgs;
|
||||||
[ cacert
|
[ cacert
|
||||||
coreutils
|
coreutils
|
||||||
|
# build
|
||||||
|
ghc
|
||||||
|
haskellPackages.shake
|
||||||
|
wget # for cabal-install
|
||||||
|
haskellPackages.cabal-install
|
||||||
entr
|
entr
|
||||||
html-xml-utils
|
html-xml-utils
|
||||||
zsh
|
zsh
|
||||||
perl
|
perl
|
||||||
perlPackages.URI
|
perlPackages.URI
|
||||||
minify
|
minify
|
||||||
niv
|
imagemagick
|
||||||
|
texlive.combined.scheme-full # https://nixos.wiki/wiki/TexLive
|
||||||
|
cm_unicode
|
||||||
|
# dev env
|
||||||
|
# niv
|
||||||
git
|
git
|
||||||
direnv
|
direnv
|
||||||
ghc
|
|
||||||
haskellPackages.shake
|
|
||||||
tmux
|
tmux
|
||||||
# for emacs dev
|
# for emacs dev
|
||||||
ripgrep
|
ripgrep
|
||||||
|
nodePackages.http-server
|
||||||
];
|
];
|
||||||
|
shellHook = ''
|
||||||
|
export FONTCONFIG_FILE=${pkgs.fontconfig.out}/etc/fonts/fonts.conf
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue