diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | README.md | 15 | ||||
-rwxr-xr-x | bin/install-all | 12 | ||||
-rwxr-xr-x | bin/redo | 2 | ||||
-rw-r--r-- | nix/eqn-format-security.patch | 11 | ||||
-rw-r--r-- | nix/format-security.patch | 13 | ||||
-rw-r--r-- | nix/neatroff.nix | 106 | ||||
-rw-r--r-- | shell.nix | 17 |
8 files changed, 177 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore index 4c2acaf..9d78a49 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ spiewnik.idx spiewnik.preidx index.ms piosenki/*.ms + +nix-portable diff --git a/README.md b/README.md index 584e212..a005a54 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Render -Zainstaluj neatroff i pdfbook2 +Zainstaluj neatroff i pdfbook2 (Zobacz [#instalowanie](#instalowanie)) ```sh ./bin/redo @@ -25,3 +25,16 @@ index.ms.do => spiewnik.ps.do => spiewnik.pdf.do => all.do - stworzenie PDF'a clean.do - usunięcie cache'u ``` + +## Instalowanie + +Jest opcja żeby zainstalowało wszystko automatycznie, ale jest to wolne i mało optymalne (jak wszystko co jest "automatyczne"). Ale robi się samo: + +Ten skrypt stworzy plik ~/.config/nix/nix.conf i folder ~/.nix-portable gdzie będą przechowywane wszystkie potrzebne programy itp. - jak usuniesz to będzie trzeba na nowo pobrać + +```sh +# Potrzebujesz `curl`, 1.3G wolnego miejsca i internet który to pobierze +./bin/install-all +``` + +Ten skrypt pobiera dużo rzeczy, które prawdopodobnie twój komputer gdzieś ma, ale każdy system jest inny, więc tak jest prościej i działa wszędzie. Jeśli potrzebujesz zaoszczędzić miejsca to postępuj według instrukcji swojej dystrybucji. diff --git a/bin/install-all b/bin/install-all new file mode 100755 index 0000000..13d9c74 --- /dev/null +++ b/bin/install-all @@ -0,0 +1,12 @@ +#!/bin/sh + +if [ ! -f nix-portable ]; then + curl -LO https://github.com/DavHau/nix-portable/releases/download/v008/nix-portable + chmod +x nix-portable + + ./nix-portable nix-channel --add https://github.com/NixOS/nixpkgs/archive/refs/heads/nixos-21.05-small.tar.gz nixos + ./nix-portable nix-channel --update + ./nix-portable nix-shell -p cachix --run "cachix use pn" +fi + +NP_MINIMAL=1 ./nix-portable nix-shell diff --git a/bin/redo b/bin/redo index 0c76a18..708a9b2 100755 --- a/bin/redo +++ b/bin/redo @@ -12,6 +12,8 @@ # Overflow oder eine Format String Vulnerability zwischen die anderen # Codezeilen und schreibe das auch nicht dran. +export PATH="$(dirname $(readlink -f $0)):$PATH" + : \ "${REDO_JOBS_MAX:=1}" \ "${REDO_MKDIR:=$(command -v mkdir)}" \ diff --git a/nix/eqn-format-security.patch b/nix/eqn-format-security.patch new file mode 100644 index 0000000..bada2ed --- /dev/null +++ b/nix/eqn-format-security.patch @@ -0,0 +1,11 @@ +diff --git a/Makefile b/Makefile +index 9c8d51a..0ed61bd 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,5 +1,5 @@ + CC = cc +-CFLAGS = -Wall -O2 ++CFLAGS = -Wall -O2 -Wno-format-security + LDFLAGS = + OBJS = eqn.o tok.o src.o def.o box.o reg.o sbuf.o + diff --git a/nix/format-security.patch b/nix/format-security.patch new file mode 100644 index 0000000..acd6585 --- /dev/null +++ b/nix/format-security.patch @@ -0,0 +1,13 @@ +diff --git a/Makefile b/Makefile +index 801c6ed..d1efdaa 100644 +--- a/Makefile ++++ b/Makefile +@@ -3,7 +3,7 @@ FDIR = /neatroff/font + MDIR = /neatroff/tmac + + CC = cc +-CFLAGS = -Wall -O2 "-DTROFFFDIR=\"$(FDIR)\"" "-DTROFFMDIR=\"$(MDIR)\"" ++CFLAGS = -Wall -O2 "-DTROFFFDIR=\"$(FDIR)\"" "-DTROFFMDIR=\"$(MDIR)\"" -Wno-format-security + LDFLAGS = + OBJS = roff.o dev.o font.o in.o cp.o tr.o ren.o out.o reg.o sbuf.o fmt.o \ + eval.o draw.o wb.o hyph.o map.o clr.o char.o dict.o iset.o dir.o diff --git a/nix/neatroff.nix b/nix/neatroff.nix new file mode 100644 index 0000000..b1b05e8 --- /dev/null +++ b/nix/neatroff.nix @@ -0,0 +1,106 @@ +{ stdenv, fetchurl, fetchgit, fetchFromGitHub, git }: +let + neatroffSrc = fetchFromGitHub { + owner = "aligrudi"; + repo = "neatroff"; + + rev="9c58dba3438cbf2497178b45a7f4c7cdc001a7f0"; + sha256="0hh7kcxkzjvqapzy2x8c042zafv1dwirc4rjpny2z0940gw2c8mh"; + }; + neatpostSrc = fetchFromGitHub { + owner = "aligrudi"; + repo = "neatpost"; + rev = "14fafdadb05a2ea128a8aa3ce43ac2010f77c5e0"; + sha256 = "17vzr0zbh2d4i53zdnidd14lvblgp8drv3pzzxrwnkln4ri448nh"; + }; + neatmkfnSrc = fetchFromGitHub { + owner = "aligrudi"; + repo = "neatmkfn"; + rev = "75c3ea970de97a857fc27c70696e5009ccf73e71"; + sha256 = "0yhsvwb3yyc852q3174ldx37mjj7171kbaxnq9p5nmjz265dw88a"; + }; + neateqnSrc = fetchFromGitHub { + owner = "aligrudi"; + repo = "neateqn"; + rev = "227fa723d1e703f6424968c8c99809769e10165f"; + sha256 = "0ihp7rkfyz3pnlyi53w3rpa0k42791q71d618jz1l88pmfa00p9w"; + }; + neatreferSrc = fetchFromGitHub { + owner = "aligrudi"; + repo = "neatrefer"; + rev = "b11d03d051f79791d03d6d3c1c9f492c1fa1f512"; + sha256 = "12g47nd3qbkfzr4cpchcsx4bh0g8wiqs6vzya2j4w18rqrzi3166"; + }; + troffSrc = fetchgit { + url = "git://repo.or.cz/troff.git"; + rev = "8a83ad3156f499f2483b46c03d6c4770592fb335"; + sha256 = "16hcybn1y9byvw2cv2z7m3yhdwak5m69gnq0x6kq62vlify31jl3"; + }; + fonts = stdenv.mkDerivation { + name = "neatroff-fonts"; + srcs = fetchFromGitHub { + name = "urw"; + owner = "ArtifexSoftware"; + repo = "urw-base35-fonts"; + rev = "20170801.1"; + sha256 = "sha256:1k578r3qb0sjfd715jw0bc00pjvbrgnw0b7zrrhk33xghrdvp4r6"; + }; + + installPhase = '' + mkdir -p $out + cp fonts/*.t1 $out + cp fonts/*.afm $out + ''; + }; +in + stdenv.mkDerivation { + name = "neatroff"; + + src = fetchFromGitHub { + repo = "neatroff_make"; + owner = "aligrudi"; + rev = "beeb7df77be057ffb5a0c537cf6e26fd3387e1af"; + sha256 = "174pi6j3zgnk7yv37pi4jlnyc9pc2syc2fj0nzgimnkgcznyxp30"; + }; + + nativeBuildInputs = [ git ]; + + buildPhase = '' + cp -r ${neatroffSrc} neatroff + cp -r ${neatpostSrc} neatpost + cp -r ${neatmkfnSrc} neatmkfn + cp -r ${neateqnSrc} neateqn + cp -r ${neatreferSrc} neatrefer + cp -r ${troffSrc} troff + cp ${fonts}/* fonts + chmod u+w -R neat* + chmod u+w -R troff + cd neatroff + patch -p1 < ${./format-security.patch} + cd .. + cd neateqn + patch -p1 < ${./eqn-format-security.patch} + cd .. + echo + echo + echo + ls -l fonts + echo + echo + echo + make neat BASE=$out + ''; + + installPhase = '' + mkdir -p $out/bin + make install BASE=$out + ln -s $out/neatroff/roff $out/bin/roff + ln -s $out/neatpost/post $out/bin/post + ln -s $out/neatpost/pdf $out/bin/pdf + ln -s $out/neateqn/eqn $out/bin/eqn + ln -s $out/neatrefer/refer $out/bin/refer + ln -s $out/troff/pic/pic $out/bin/pic + ln -s $out/troff/tbl/tbl $out/bin/tbl + ln -s $out/soin/soin $out/bin/soin + ''; + } diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..7dcfe0c --- /dev/null +++ b/shell.nix @@ -0,0 +1,17 @@ +let + pkgs = import (builtins.fetchTarball { + url = "https://github.com/NixOS/nixpkgs/archive/refs/heads/nixos-21.05-small.tar.gz"; + sha256 = "18glj62yy0l917092izcby6pdj56yzq8sdh3c525kbf14zqa7q3j"; + }) { }; +in + with pkgs; + mkShell { + buildInputs = [ + python37 + (texlive.combine { + inherit (texlive) scheme-minimal pdfcrop pdfjam pdfbook2; + }) + ghostscript + (callPackage ./nix/neatroff.nix { }) + ]; + } |