From 0499e3ab958d132dfa0a75487dbef97febfd1158 Mon Sep 17 00:00:00 2001 From: ene Date: Sun, 19 Feb 2023 19:13:36 +0100 Subject: Feat(bootstrap): Separate the builder to a library --- bootstrap/default.nix | 16 +++++----------- lib/default.nix | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 lib/default.nix diff --git a/bootstrap/default.nix b/bootstrap/default.nix index e013ade4..8cd7b394 100644 --- a/bootstrap/default.nix +++ b/bootstrap/default.nix @@ -1,18 +1,12 @@ +# vim: ts=2 { pkgs, shell-library, ... -}: -#pkgs.writeShellScriptBin "install" (builtins.readFile ./install) -let +}: let dependencies = with pkgs; [jq dash]; name = "install"; + script = ./install; + lib = import ../lib {inherit pkgs shell-library;}; in - pkgs.runCommandLocal name { - nativeBuildInputs = [pkgs.makeWrapper] ++ dependencies; - } '' - install -m755 ${./install} -D "$out/bin/${name}" - sed -i 's|%SHELL_LIBRARY_PATH|${shell-library}/lib|' "$out/bin/${name}" - #patchShebangs "$out/bin/${name}" - wrapProgram "$out/bin/${name}" --prefix PATH : ${pkgs.lib.makeBinPath dependencies} - '' + lib.makeShellScriptWithLibrary {inherit dependencies name script;} diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 00000000..0e2caf1b --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,20 @@ +{ + pkgs, + shell-library, + ... +}: { + makeShellScriptWithLibrary = { + dependencies, + name, + script, + ... + }: + pkgs.runCommandLocal name { + nativeBuildInputs = [pkgs.makeWrapper] ++ dependencies; + } '' + install -m755 ${script} -D "$out/bin/${name}" + sed -i 's|%SHELL_LIBRARY_PATH|${shell-library}/lib|' "$out/bin/${name}" + patchShebangs "$out/bin/${name}" + wrapProgram "$out/bin/${name}" --prefix PATH : ${pkgs.lib.makeBinPath dependencies} + ''; +} -- cgit 1.4.1