This repository has been archived by the owner on Nov 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Invoking an external script with Nix interpolation #3
Comments
This is still hacky! You can use foo = pkgs.substituteAll {
name = "foo.nu";
src = ./foo.nu;
system = "${system}";
nushell = "${pkgs.nushell}";
nix-health = "${./nix-health.nu}";
}
However, I'm not sure of an elegant way to plug the resulting file into the Instead you can reuse the same syntax and just use foo = pkgs.nuenv.mkScript {
name = "foo";
script = (builtins.replaceStrings
[ "@system@" "@nushell@" "@nix-health@ ]
[ "${system}" "${pkgs.nushell}" "${./nix-health.nu}" ]
(builtins.readFile ./foo.nu)
);
}; |
I pushed PR #27 which adds packages.default = pkgs.nuenv.writeShellApplication {
name = "nix-health";
runtimeEnv = { inherit system };
text = builtins.readFile ./nix-health.nu;
}; Then in |
Great! I'll see if I can use that to replace this: |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I feel like this is a bit of a hack,
https://github.com/srid/nix-health/blob/0c4735b6403a4fd13ef170f3c21296e05cd32fe5/flake.nix#L21
nix-health.nu
references thesystem
variable, so I'm passing it as a command-line argument. Also, I have to manually pull inpkgs.nushell
to invoke the script. Is there a more idiomatic way of achieving this? The main goal is to put thescript
body in a separate file, whilst still being able to reference Nix variables in scope.The text was updated successfully, but these errors were encountered: