https://github.com/drupol/my-own-nixpkgs
A template for maintaining your own Nix expressions in your own repository
https://github.com/drupol/my-own-nixpkgs
Last synced: 7 months ago
JSON representation
A template for maintaining your own Nix expressions in your own repository
- Host: GitHub
- URL: https://github.com/drupol/my-own-nixpkgs
- Owner: drupol
- License: mit
- Created: 2024-04-15T17:15:29.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-22T19:50:08.000Z (over 1 year ago)
- Last Synced: 2025-02-01T20:44:59.483Z (over 1 year ago)
- Language: Nix
- Size: 10.7 KB
- Stars: 21
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
[![Donate!][donate github]][github sponsors link]
# My Custom Nixpkgs Overlay
This project provides templates for creating your own collection of custom Nix
expressions, similar to what is done in [`nixpkgs`]. It includes a `default`
[overlay](https://wiki.nixos.org/wiki/Overlays) that exposes all custom
packages, facilitating their integration into other projects.
While this custom repository provides a platform for developing, integrating and
sharing your own packages, we encourage contributors to also consider submitting
their packages directly to the official [`nixpkgs`] repository. Contributing to
`nixpkgs` helps to enrich the broader Nix community by making your work
available to a wider audience and benefiting from the collective expertise of
Nix developers. However, maintaining your own repository can be advantageous for
experimental, personal, or organization-specific packages that require specific
configurations or are not yet ready for broader adoption.
It also includes a template to create your own infrastructure using Nix.
## Usage
### Setting Up Your Own Repository
This repository can be used to host your custom Nix packages.
1. Use the `my-own-nixpkgs` template
`nix flake new --template git+https://github.com/drupol/my-own-nixpkgs#my-own-nixpkgs ./my-repo`
as a starting point
2. Begin adding packages to the `pkgs/by-name` directory. Follow the same
approach as adding packages in `nixpkgs` (similar to [RFC140]). Packages
added in this directory will be automatically discovered.
- Create a new directory for each package.
- Inside each directory, create a `package.nix` file.
3. Optionally, you can add packages directly to the `pkgs/` directory and
manually update the bindings in the `imports/pkgs-all.nix` file.
### Using Your Own Repository
Use the `client` template
`nix flake new --template git+https://github.com/drupol/my-own-nixpkgs#client ./my-nix-project`
as a starting point or follow the manual steps hereunder.
To use this repository as an overlay in another project, follow these steps:
1. **Add the Repository as an Input**:
Add the following to your `nix` file to include this repository as an input:
```nix
inputs = {
my-custom-nixpkgs.url = "repo-url"; # Replace "repo-url" with the actual URL to your repository
};
```
2. **Include the Overlay in `pkgs`**:
When constructing `pkgs`, include the overlay as follows:
```nix
pkgs = import inputs.nixpkgs {
overlays = [
inputs.my-custom-nixpkgs.overlays.default
];
};
```
3. **Use Your Packages**:
Access the packages in your project like this:
```nix
buildInputs = [ pkgs.example1 pkgs.example2 ];
```
[RFC140]: https://github.com/NixOS/rfcs/pull/140
### Create your infrastructure repository
This repository can be used to host your own infrastructure using Nix.
1. Use the `infra` template
`nix flake new --template git+https://github.com/drupol/my-own-nixpkgs#infra ./my-infra`
as a starting point
### Examples
Refer to the dummy projects `example1` and `example2` for practical examples of
how packages can be structured.
## Going further
- Use the continuous integration service of your choice to build and test your
packages
- Add a binary cache to your repository to speed up builds and avoid
recompilation using [Cachix](https://cachix.org/)
- This project uses `flake-parts`, a flake framework. We recommend to it
[flake-parts](https://flake.parts)
## Contributing
Feel free to contribute by sending pull requests. We are a usually very
responsive team and we will help you going through your pull request from the
beginning to the end.
For some reasons, if you can't contribute to the code and willing to help,
sponsoring is a good, sound and safe way to show us some gratitude for the hours
we invested in this package.
Sponsor me on [Github][github sponsors link] and/or any of [the
contributors][6].
[donate github]:
https://img.shields.io/badge/Sponsor-Github-brightgreen.svg?style=flat-square
[github sponsors link]: https://github.com/sponsors/drupol
[6]: https://github.com/drupol/my-own-nixpkgs/graphs/contributors
[`nixpkgs`]: https://github.com/NixOS/nixpkgs