diff --git a/flake.lock b/flake.lock index 8a1bae3..edb15bd 100644 --- a/flake.lock +++ b/flake.lock @@ -37,7 +37,23 @@ "root": { "inputs": { "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "scripts": "scripts" + } + }, + "scripts": { + "locked": { + "lastModified": 1696031019, + "narHash": "sha256-MuKEC8ZZ1Znm2idxQEQYU18z/1l9rjBZaj5gdKd9elQ=", + "owner": "Smaug123", + "repo": "flake-shell-script", + "rev": "05cc0582a193d3b42b6b4e64c6ec7a9bca4bb3c5", + "type": "github" + }, + "original": { + "owner": "Smaug123", + "repo": "flake-shell-script", + "type": "github" } }, "systems": { diff --git a/flake.nix b/flake.nix index 5e473dd..0598a90 100644 --- a/flake.nix +++ b/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 = ''