Skip to content

Instantly share code, notes, and snippets.

@kayvank
Created December 28, 2024 19:22
Show Gist options
  • Select an option

  • Save kayvank/e8a7e8aab2c883fbf6bd31fda52b25c5 to your computer and use it in GitHub Desktop.

Select an option

Save kayvank/e8a7e8aab2c883fbf6bd31fda52b25c5 to your computer and use it in GitHub Desktop.

Revisions

  1. kayvank created this gist Dec 28, 2024.
    29 changes: 29 additions & 0 deletions flake.nix
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    {
    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";
    };
    });
    }