Add SPDX license expressions
Consolidate on single LICENSE.md file
Add license files
# SPDX-License-Identifier: CC0-1.0 OR BlueOak-1.0.0 OR 0BSD
This is a simple library for building handy little Nix flakes that wrap shell scripts with just enough dependencies to let them run.
First, install Nix.
In your project, run the following command:
nix flake init --template sourcehut:~pmc/handy-flake
This will create a flake.nix
and hello-world.py
file in the current
directory. To test it out, run:
nix run .#hello-world
nix run
tells Nix to run an app from a flake, and .#
tells it to run an app
from the flake in the current directory (.
). If you look at flake.nix
, you
should see that it defines a script called hello-world
:
hello-world = {
dependencies = pkgs: [ pkgs.python3 ];
script = ./hello-world.py;
};
The dependencies
key contains a function that takes a value called pkgs
and
returns a list of packages you want to have in your script's PATH. This pkgs
value is a nixpkgs
instantiation for your current platform - in short, it's
an object that contains all of the packages from
nixpkgs. You can search these packages
using the tool at [https://search.nixos.org/packages].
The script
key contains a path to the script file. In this example, it's the
path to the hello-world.py
script. You can replace this with any script file,
whether it be a shell script, Perl script, Python script, or something else -
just make sure the shebang uses /usr/bin/env
like these examples:
#!/usr/bin/env bash
#!/usr/bin/env perl
#!/usr/bin/env python3
That way, the script gets run using the interpreter you added to the PATH
through dependencies
.
You can do this with as many scripts as you want, and you can put the actual script files anywhere you want in your project.
To update nixpkgs to the latest version, run:
nix flake update
To pin it to a preferred channel, add a line like this before the
inputs.handy-flake.url
line in your flake.nix
:
inputs.nixpkgs.url = github:nixos/nixpkgs/nixos-22.05;
Replace nixos-22.05
with whichever nixpkgs channel you'd like to follow.
This library is triple-licensed under the CC0-1.0
, BlueOak-1.0.0
, and
0BSD
licenses. See LICENSE.md
for the full text of these licenses.