feat(nix): Replace Makefile with flake
- Remove makefile to use a flake for consistency. - Modify convert.py to accept input for filename to open. - Add flake.nix, flake.lock, and .envrc
This commit is contained in:
parent
fb042840b1
commit
fba5ac850f
4
.gitignore
vendored
4
.gitignore
vendored
@ -2,3 +2,7 @@ esv
|
||||
ESV.json
|
||||
esv.tsv
|
||||
esv.zip
|
||||
|
||||
result/
|
||||
result
|
||||
.direnv/
|
||||
|
54
Makefile
54
Makefile
@ -1,54 +0,0 @@
|
||||
##
|
||||
# esv command line bible
|
||||
# Changelog:
|
||||
# 2024-03-04 Added download feature to pull esv without distributing with source
|
||||
|
||||
PREFIX = /usr/local
|
||||
|
||||
|
||||
esv: esv.sh esv.awk esv.tsv
|
||||
cat esv.sh > $@
|
||||
echo 'exit 0' >> $@
|
||||
echo '#EOF' >> $@
|
||||
tar czf - esv.awk esv.tsv >> $@
|
||||
chmod +x $@
|
||||
|
||||
test: esv.sh
|
||||
shellcheck -s sh esv.sh
|
||||
|
||||
clean:
|
||||
rm -f esv ESV.json esv.zip
|
||||
|
||||
install: esv
|
||||
mkdir -p $(DESTDIR)$(PREFIX)/bin
|
||||
cp -f esv $(DESTDIR)$(PREFIX)/bin
|
||||
chmod 755 $(DESTDIR)$(PREFIX)/bin/esv
|
||||
|
||||
uninstall:
|
||||
rm -f $(DESTDIR)$(PREFIX)/bin/esv
|
||||
|
||||
esv.tsv: download
|
||||
|
||||
download:
|
||||
ifeq ("$(wildcard ./esv.tsv)","") # Check if the file exists before downloading
|
||||
ifeq ( $(strip $(unzip -v)), )
|
||||
ifeq ("$(wildcard ./ESV.json)","") # Check if the file exists before downloading
|
||||
curl --location \
|
||||
--request GET "https://bolls.life/static/translations/ESV.json" \
|
||||
-o ESV.json
|
||||
endif
|
||||
else
|
||||
ifeq ("$(wildcard ./esv.zip)","") # Check if the file exists before downloading
|
||||
curl --location \
|
||||
--request GET "https://bolls.life/static/translations/ESV.zip" \
|
||||
-o esv.zip
|
||||
endif
|
||||
unzip esv.zip
|
||||
endif
|
||||
./convert.py
|
||||
endif
|
||||
|
||||
|
||||
.PHONY: test clean install uninstall
|
||||
|
||||
# end
|
@ -19,6 +19,7 @@ import json
|
||||
import pandas
|
||||
import re
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
titles = [
|
||||
@ -159,7 +160,7 @@ abbreviations = [
|
||||
"Rev"
|
||||
]
|
||||
|
||||
f = open('ESV.json')
|
||||
f = open(sys.argv[1])
|
||||
json_list = json.load(f)
|
||||
|
||||
# The keys we need to extract from the json data
|
||||
@ -189,4 +190,4 @@ if file_stats.st_size != 4616589:
|
||||
print("Recorded value: 4616589")
|
||||
print("Found value: ", file_stats.st_size)
|
||||
else:
|
||||
print("Convertion successful!")
|
||||
print("Conversion successful!")
|
||||
|
1
esv.sh
1
esv.sh
@ -93,3 +93,4 @@ if [ $# -eq 0 ]; then
|
||||
fi
|
||||
|
||||
get_data esv.tsv | awk -v cmd=ref -v ref="$*" "$(get_data esv.awk)" | ${PAGER}
|
||||
exit 0
|
||||
|
41
flake.lock
generated
Normal file
41
flake.lock
generated
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
"nodes": {
|
||||
"bible": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1639253344,
|
||||
"narHash": "sha256-0lAEyDmDz/DAQpbeQDr3UIw6bvZMLXYND+CMR86c8pw=",
|
||||
"type": "tarball",
|
||||
"url": "https://bolls.life/static/translations/ESV.zip"
|
||||
},
|
||||
"original": {
|
||||
"type": "tarball",
|
||||
"url": "https://bolls.life/static/translations/ESV.zip"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1726463316,
|
||||
"narHash": "sha256-gI9kkaH0ZjakJOKrdjaI/VbaMEo9qBbSUl93DnU7f4c=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "99dc8785f6a0adac95f5e2ab05cc2e1bf666d172",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"bible": "bible",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
52
flake.nix
Normal file
52
flake.nix
Normal file
@ -0,0 +1,52 @@
|
||||
{
|
||||
description = "Read the Word of God from your command line";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||
bible = {
|
||||
url = "https://bolls.life/static/translations/ESV.zip";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, bible }:
|
||||
let
|
||||
# Systems supported
|
||||
allSystems = [
|
||||
"x86_64-linux" # 64-bit Intel/AMD Linux
|
||||
"aarch64-linux" # 64-bit ARM Linux
|
||||
"x86_64-darwin" # 64-bit Intel macOS
|
||||
"aarch64-darwin" # 64-bit ARM macOS
|
||||
];
|
||||
|
||||
# Helper to provide system-specific attributes
|
||||
forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
});
|
||||
in
|
||||
{
|
||||
packages = forAllSystems ({ pkgs }: {
|
||||
default =
|
||||
let binName = "esv"; in
|
||||
pkgs.stdenv.mkDerivation {
|
||||
name = binName;
|
||||
src = self;
|
||||
buildInputs = [ ];
|
||||
nativeBuildInputs = with pkgs; [ shellcheck gawk unzip python3 python312Packages.pandas ];
|
||||
|
||||
buildPhase = ''
|
||||
python3 ${./convert.py} ${bible}
|
||||
cat ${./esv.sh} > ${binName}
|
||||
echo '#EOF' >> ${binName}
|
||||
tar czf - esv.awk esv.tsv >> ${binName}
|
||||
chmod +x ${binName}
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin/
|
||||
cp ${binName} $out/bin/
|
||||
'';
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user