mirror of
https://github.com/Smaug123/static-site-pdfs
synced 2025-10-17 04:58:39 +00:00
Extract shell script
This commit is contained in:
37
flake.nix
37
flake.nix
@@ -4,12 +4,14 @@
|
||||
inputs = {
|
||||
flake-utils.url = github:numtide/flake-utils;
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
|
||||
scripts.url = "github:Smaug123/flake-shell-script";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
scripts,
|
||||
}: let
|
||||
commit = self.shortRev or "dirty";
|
||||
date = self.lastModifiedDate or self.lastModified or "19700101";
|
||||
@@ -21,46 +23,15 @@
|
||||
texlive = pkgs.texlive.combine {
|
||||
inherit (pkgs.texlive) scheme-medium mdframed etoolbox zref needspace tikz-cd;
|
||||
};
|
||||
in let
|
||||
createShellScript = name: contents:
|
||||
pkgs.stdenv.mkDerivation {
|
||||
__contentAddressed = true;
|
||||
pname = name;
|
||||
version = "0.1.0";
|
||||
src = contents;
|
||||
|
||||
buildInputs = [
|
||||
pkgs.shellcheck
|
||||
];
|
||||
|
||||
phases = ["configurePhase" "buildPhase" "installPhase"];
|
||||
|
||||
configurePhase = ''
|
||||
${pkgs.shellcheck}/bin/shellcheck "${contents}"
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
cp "${contents}" run.sh
|
||||
patchShebangs run.sh
|
||||
sed -i 's_"/bin/bash"_"${pkgs.bash}/bin/bash"_' run.sh
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
mv run.sh $out/run.sh
|
||||
'';
|
||||
};
|
||||
in let
|
||||
buildLatex = createShellScript "latex" ./build.sh;
|
||||
in {
|
||||
packages.default = pkgs.stdenv.mkDerivation {
|
||||
__contentAddressed = true;
|
||||
inherit version;
|
||||
pname = "patrickstevens.co.uk-pdfs";
|
||||
src = ./.;
|
||||
buildInputs = [texlive buildLatex];
|
||||
buildInputs = [texlive];
|
||||
buildPhase = ''
|
||||
${pkgs.bash}/bin/sh ${buildLatex}/run.sh .
|
||||
${pkgs.bash}/bin/sh ${scripts.lib.createShellScript pkgs "latex" ./build.sh}/run.sh .
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
|
Reference in New Issue
Block a user