Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wunderwerkio/nix-utils
Opinionated Nix-Utilities and Nix-specific bash scripts
https://github.com/wunderwerkio/nix-utils
bash-script flake nix nix-flake
Last synced: 15 days ago
JSON representation
Opinionated Nix-Utilities and Nix-specific bash scripts
- Host: GitHub
- URL: https://github.com/wunderwerkio/nix-utils
- Owner: wunderwerkio
- Created: 2024-10-15T09:14:58.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-10-17T08:32:43.000Z (2 months ago)
- Last Synced: 2024-11-03T10:22:29.965Z (about 2 months ago)
- Topics: bash-script, flake, nix, nix-flake
- Language: Nix
- Homepage:
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Nix Utils
Opinionated collection of various Nix utilies and Nix-specific bash scripts
for use in other Nix Flakes.This Flake provides the following:
- **Nix utilities**
System related utilities taken from [numtide/flake-utils](https://github.com/numtide/flake-utils)
- **Utility Bash functions**
Common functionality as bash functions that can be sourced in
scripts of other Nix Flakes.## Nix Utilities
### Systems
Utilities related to systems.
Helps generating the required attribute sets for each supported system in your flake.This is taken from [numtide/flake-utils](https://github.com/numtide/flake-utils),
so all credit goes to them!#### `lib.systems.eachDefault`
Same as `lib.systems.eachSystem` but populated with each system defined in `defaultSystems`.
#### `lib.systems.eachSystem :: []`
Builds a map from ` = value` to `. = value` for each system.
**Example:**
```nix
inputs.utils.lib.systems.eachSystem ["x86_64-linux"] (system: {
packages = {
default = import ./my-package.nix;
};
})# Results in:
{
packages = {
"x86_64-linux" = {
default = import ./my-package.nix;
};
};
}
```#### `lib.systems.defaultSystems`
A list with all default systems that are used for the `Default` functions.
Defaults to:
```nix
[
"aarch64-linux"
"aarch64-darwin"
"x86_64-darwin"
"x86_64-linux"
]
```#### `lib.systems.eachDefaultMapped`
Same as `lib.systems.eachSystemMapped` but populated with each system defined
in `defaultSystems`.#### `lib.systems.eachSystemMapped :: []`
Builds a map from ` = value` to `. = value` for each system.
**Example:**
```nix
inputs.utils.lib.systems.eachSystemMapped ["x86_64-linux"] (system: {
packages = {
default = import ./my-package.nix;
};
})# Results in:
{
"x86_64-linux" = {
packages = {
default = import ./my-package.nix;
};
};
}
```#### `lib.systems.eachDefaultPassthrough`
Same as `lib.systems.eachSystemPassthrough` but populated with each system defined
in `defaultSystems`.#### `lib.systems.eachSystemPassthrough :: []`
Just provides a callback with the `system` argument, does not alter
the attribute set.**Example:**
```nix
inputs.utils.lib.systems.eachSystemPassthrough ["x86_64-linux"] (system: {
packages = {
default = import ./my-package.nix;
};
})# Results in:
{
packages = {
default = import ./my-package.nix;
};
}
```## Utility Bash functions
Useful bash functions can be sourced in other bash scripts.
Just import the functions that you need in your script.
The bash functions can then directly be called.See the scripts in `./nix/scripts/*` for the available functions
and their corresponding documentation.**Example:**
```nix
#
# Import the packages for your system:
# inputs.utils.lib.system.eachDefaultSystem (system: {
# utilsPkgs = inputs.utils.packages.${system};
# });
#
pkgs.writeShellScript ''
source ${utilsPkgs.env-sh}
source ${utilsPkgs.utils-sh}
source ${utilsPkgs.git-sh}
source ${utilsPkgs.print-sh}
source ${utilsPkgs.devenv-sh}
'';
```