Something went wrong. Try again.
A minimal wrapper around nixpkgs' `pkgs.mkShell`.
Something went wrong. Try again.
Files
README.md
tinyshell #
tinyshell is a minimal wrapper around nixpkgs' mkShell and mkShellNoCC builders, specifically offering the following functionality:
- Automatically determining and setting the
PRJ_ROOTenvironment variable.git rev-parse --show-toplevelis used for this. If the project is not a git repository, this will default to$PWDinstead.
- Automatically determining and setting the
PRJ_DATA_DIRenvironment variable. (Disable withsetDataDir = false;)- Automatically creating the
PRJ_DATA_DIRdirectory ($PRJ_ROOT/.data). (Disable withcreateDataDir = false;)
- Automatically creating the
This is meant to offer some of the utility of something like devshell without the extraneous dependencies.
Usage #
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
systems.url = "github:nix-systems/default";
tinyshell.url = "git+https://tangled.org/csw.im/tinyshell";
};
outputs = {
nixpkgs,
systems,
tinyshell,
...
}: let
eachSystem = f: (nixpkgs.lib.genAttrs (import systems) (
system: f system (import nixpkgs {inherit system;})
));
in {
devShells = eachSystem (system: pkgs: {
default = (tinyshell.lib pkgs).mkTinyShell {
shellHook = ''echo "Project root: $PRJ_ROOT"'';
};
});
};
}
Templates #
tinyshell offers some minimal templates to get you started.
simple (default) #
Just the bare-bones tinyshell. No flake-utils, nothing extra but nix-systems.
nix flake init -t git+https://tangled.org/csw.im/tinyshell#simple
nixhooks #
A tinyshell with nixhooks configured.
nix flake init -t git+https://tangled.org/csw.im/tinyshell#nixhooks
Function Reference #
Exported functions #
| Function | Underlying implementation | Description |
|---|---|---|
mkTinyShell |
pkgs.mkShell |
Creates a development shell with the tinyshell project-root and data-directory setup. |
mkTinyShellNoCC |
pkgs.mkShellNoCC |
Same tinyshell setup, using pkgs.mkShellNoCC for shells that do not need a C compiler toolchain by default. |
_mkTinyShell Arguments #
All arguments understood by tinyshell (those listed below, aside from ...) are removed from the arguments passed through to the underlying mkShell implementation.
| Argument | Type | Default | Description |
|---|---|---|---|
shellHook |
String | "" |
Additional shell commands appended to the generated shell hook. |
projectVarName |
String | PRJ_ROOT |
The name of the environment variable to export the project's root directory to. |
dataDirVarName |
String | PRJ_DATA_DIR |
The name of the environment variable to export the project's data directory to. |
dataDir |
String or null |
".data" |
Relative path to the project data directory, resolved against projectVarName. Set to null to disable data-directory configuration and creation. |
setDataDir |
Boolean | dataDir != null |
Whether to export ${dataDirVarName} as ${projectVarName}/${dataDir}. |
createDataDir |
Boolean | setDataDir |
Whether to create the directory specified by dataDirVarName using mkdir -vp. Requires setDataDir = true. |
gitPackage |
Derivation | pkgs.git |
Git package used to determine the project root with git rev-parse --show-toplevel. Falls back to $PWD if the command fails. |
... |
— | — | Accepts additional arguments supported by pkgs.mkShell or pkgs.mkShellNoCC, such as packages, buildInputs, and nativeBuildInputs. |
·
Copy SHA
·
Copy SHA
·
Copy SHA
·
Copy SHA
·
Copy SHA
·
Copy SHA
·
Copy SHA
- Nix 100%