From 11d7ff9b91b67305ea5e6a7e8100a197d2b4c0b2 Mon Sep 17 00:00:00 2001 From: Andreas Fehn Date: Tue, 5 Nov 2024 22:43:11 +0100 Subject: [PATCH] Use absolute path to bash-env-json for module (#38) Thank you for this nice project :+1: This PR simplifies the setup for the module. Before this change you would need to install `bash-env-json` separately. Now you only need to load the module with ```nix use ${bash-env-nushell.packages.${self.system}.module}/bash-env.nu ``` --- flake.nix | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/flake.nix b/flake.nix index 851dfa7..798d42d 100644 --- a/flake.nix +++ b/flake.nix @@ -24,26 +24,25 @@ inherit system overlays; }; - inherit (builtins) readFile; - inherit (pkgs) rust-bin symlinkJoin writeShellScriptBin writeTextFile; + inherit (pkgs) lib rust-bin stdenvNoCC writeShellScriptBin; flakePkgs = { bash-env-json = bash-env-json.packages.${system}.default; }; - bash-env-module = writeTextFile - { - name = "bash-env.nu"; - text = readFile ./bash-env.nu; - destination = "/bash-env.nu"; - }; - - bash-env-module-with-bash-env-json = symlinkJoin + bash-env-module-with-bash-env-json = stdenvNoCC.mkDerivation { name = "bash-env.nu-with-bash-env-json"; - paths = [ - bash-env-module - flakePkgs.bash-env-json - ]; + src = ./bash-env.nu; + dontUnpack = true; + preferLocalBuild = true; + allowSubstitutes = false; + + buildPhase = '' + runHook preBuild + mkdir -p "$out" + substitute "$src" "$out/bash-env.nu" --replace-fail ${lib.escapeShellArg "bash-env-json"} ${lib.escapeShellArg "${flakePkgs.bash-env-json}/bin/bash-env-json"} + runHook postBuild + ''; }; # cargo-nightly based on https://github.com/oxalica/rust-overlay/issues/82