Last active
September 10, 2026 22:30
-
-
Save con-f-use/a3581294dd54f44763a2d5f9c9996c76 to your computer and use it in GitHub Desktop.
basic shell app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Build with: | |
| # nix-build -E 'with import <nixpkgs> {}; pkgs.callPackage ./this-file.nix {}' | |
| # Run with: | |
| # result/bin/bunnytest | |
| { writeShellApplication, fetchurl, sox }: | |
| let | |
| sound = fetchurl { | |
| url = "https://samplelib.com/mp3/sample-3s.mp3"; | |
| hash = "sha256-AkRZDytLy2I1K1dOeL6pQOjYnPppgjtSCO9MQ+Cry0Q="; | |
| }; | |
| in | |
| writeShellApplication { | |
| name = "bunnytest"; | |
| text = '' # or: builtins.readFile ./some-shell-script.sh so you don't have to escape every dollar curly | |
| play "${toString sound}" | |
| ''; | |
| runtimeInputs = [ sox ]; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Build with: | |
| # nix-build -E 'with import <nixpkgs> {}; pkgs.callPackage ./this-file.nix {}' | |
| # Run with: | |
| # result/bin/bunnytest | |
| { writeShellApplication, sox, curl }: | |
| writeShellApplication { | |
| name = "bunnytest"; | |
| text = '' # or: builtins.readFile ./some-shell-script.sh so you don't have to escape every dollar curly | |
| curl -L 'https://samplelib.com/mp3/sample-3s.mp3' -o /tmp/sample.mp3 | |
| play /tmp/sample.mp3 | |
| ''; | |
| runtimeInputs = [ sox curl ]; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # requires default.nix from abouve | |
| # run with: | |
| # nix run './' | |
| { | |
| outputs = {nixpkgs, ...}: { | |
| packages = builtins.mapAttrs (system: pkgs: { | |
| default = pkgs.callPackage ./default.nix { }; | |
| }) nixpkgs.legacyPackages; | |
| }; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| lib, | |
| makeWrapper, | |
| runCommand, | |
| # runtime deps (depend on script) | |
| fish, | |
| tree, | |
| }: | |
| let | |
| # Your external shell script. | |
| src = ./some-script.fish: | |
| binName = "some-script"; | |
| deps = [ | |
| fish | |
| tree | |
| ]; | |
| in | |
| runCommand "${binName}" | |
| { | |
| nativeBuildInputs = [ makeWrapper ]; | |
| meta = { | |
| mainProgram = "${binName}"; | |
| }; | |
| } | |
| '' | |
| mkdir -p $out/bin | |
| install -m +x ${src} $out/bin/${binName} | |
| wrapProgram $out/bin/${binName} \ | |
| --prefix PATH : ${lib.makeBinPath deps} | |
| '' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment