A simple helper that makes it easy to package Nu scripts with Nix, including inline dependency declarations for external commands and other packaged scripts.
flake nu nushell nix
1

Configure Feed

Select the types of activity you want to include in your feed.

add usage example

cswimr (Jul 13, 2026, 12:26 PM EDT) 5a07650c 8544660c

+48
+2
.gitignore
··· 1 + example/**/flake.lock 2 + result*
+27
example/flake.nix
··· 1 + { 2 + inputs = { 3 + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; 4 + systems.url = "github:nix-systems/default"; 5 + nu2nix.url = "git+https://tangled.org/csw.im/nu2nix"; 6 + }; 7 + 8 + outputs = 9 + { self, nixpkgs, ... }@inputs: 10 + let 11 + eachSystem = nixpkgs.lib.genAttrs (import inputs.systems); 12 + in 13 + { 14 + packages = eachSystem (system: { 15 + example = inputs.nu2nix.lib.mkNuScript { 16 + pkgs = import nixpkgs { inherit system; }; 17 + inherit self inputs; 18 + script = ./scripts/example.nu; 19 + }; 20 + helper = inputs.nu2nix.lib.mkNuScript { 21 + pkgs = import nixpkgs { inherit system; }; 22 + inherit self inputs; 23 + script = ./scripts/helper.nu; 24 + }; 25 + }); 26 + }; 27 + }
+10
example/scripts/example.nu
··· 1 + #!/usr/bin/env nu 2 + 3 + # START: External Dependencies 4 + # hello 5 + # self.helper 6 + # END: External Dependencies 7 + 8 + def main []: nothing -> string { 9 + ^hello | ^helper 10 + }
+9
example/scripts/helper.nu
··· 1 + #!/usr/bin/env -S nu --stdin 2 + 3 + # START: External Dependencies 4 + # cowsay 5 + # END: External Dependencies 6 + 7 + def main []: string -> string { 8 + ^cowsay $in 9 + }