Created
December 28, 2024 19:22
-
-
Save kayvank/e8a7e8aab2c883fbf6bd31fda52b25c5 to your computer and use it in GitHub Desktop.
nix flake to create a simple shell script
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
| { | |
| description = "A better simple script flake"; | |
| inputs = { | |
| nixpkgs.url = "github:NixOS/nixpkgs"; | |
| flake-utils.url = "github:numtide/flake-utils"; | |
| }; | |
| outputs = {self, nixpkgs, flake-utils}: | |
| flake-utils.lib.eachDefaultSystem (system: | |
| let | |
| pkgs = import nixpkgs {system = system;}; | |
| my-name = "my-script"; | |
| my-src = builtins.readFile ./simple-script.sh; | |
| my-script = (pkgs.writeScriptBin my-name my-src).overrideAttrs(old: { | |
| buildCommand = "${old.buildCommand}\n patchShebangs $out"; | |
| }); | |
| ## create a variable to store the list of dependencies | |
| my-buildInputs = with pkgs; [cowsay ddate]; | |
| in rec { | |
| defaultPackage = packages.my-script; | |
| packages.my-script = pkgs.symlinkJoin { | |
| name = my-name; | |
| paths = [ my-script ] ++ my-buildInputs; | |
| buildInputs = [ pkgs.makeWrapper ]; | |
| postBuild = | |
| "wrapProgram $out/bin/${my-name} --prefix PATH : $out/bin"; | |
| }; | |
| }); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where the
simple-script.shshell script is: