-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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: https://github.com/srid/nixos-flake/blob/cab6539d198792f94fbac029e5a63523604fd172/nix/nu.nix#L4-L7 |
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: