From 6240fd4b14bd8099edb6abaeeb98e8b2bb91b616 Mon Sep 17 00:00:00 2001 From: didier amyot Date: Wed, 17 May 2023 07:42:40 -0400 Subject: [PATCH] Added possibility to use specific python in writePythonApplication. This feature can be useful to add script dependant dependencies using pkgs.python3.withPackages. --- flake.nix | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/flake.nix b/flake.nix index 92c5a0a..c2d64f2 100644 --- a/flake.nix +++ b/flake.nix @@ -12,18 +12,20 @@ pkgs = import nixpkgs { inherit system;}; in { - writePythonApplication = {name, contentFile, extraRuntimeInputs ? []}: let + writePythonApplication = {name, contentFile, extraRuntimeInputs ? [], python ? null}: + let + python-to-use = python == null then pkgs.python311 else python; wrappedScript = pkgs.writeText "wrappedScript" (builtins.readFile contentFile); - in + in pkgs.writeShellApplication { - name = name; - runtimeInputs = [ - wrappedScript - pkgs.python311] ++ extraRuntimeInputs; - text = '' - exec ${pkgs.python38}/bin/python ${wrappedScript} "$@" - ''; - }; + name = name; + runtimeInputs = [ + wrappedScript + if python-to-use] ++ extraRuntimeInputs; + text = '' + exec ${python-to-use}/bin/python ${wrappedScript} "$@" + ''; + }; writeBabashkaApplication = {name, contentFile, extraRuntimeInputs ? []}: let wrappedScript = pkgs.writeText "wrappedScript" (builtins.readFile contentFile);