{"id":17862603,"url":"https://github.com/ekala-project/nix-lib","last_synced_at":"2025-03-20T23:32:25.304Z","repository":{"id":255044911,"uuid":"847506057","full_name":"ekala-project/nix-lib","owner":"ekala-project","description":"Standalone lib for use with nix","archived":false,"fork":false,"pushed_at":"2024-10-10T06:18:56.000Z","size":271,"stargazers_count":35,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-17T18:53:49.560Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Nix","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ekala-project.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-26T01:49:09.000Z","updated_at":"2025-03-04T23:33:48.000Z","dependencies_parsed_at":"2024-08-27T18:25:58.949Z","dependency_job_id":"3cadf69a-5c92-45a3-b775-064ae9acf66c","html_url":"https://github.com/ekala-project/nix-lib","commit_stats":null,"previous_names":["jonringer/nix-lib"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekala-project%2Fnix-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekala-project%2Fnix-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekala-project%2Fnix-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekala-project%2Fnix-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ekala-project","download_url":"https://codeload.github.com/ekala-project/nix-lib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244711540,"owners_count":20497412,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-28T08:53:33.005Z","updated_at":"2025-03-20T23:32:25.297Z","avatar_url":"https://github.com/ekala-project.png","language":"Nix","funding_links":[],"categories":["Nix"],"sub_categories":[],"readme":"# Standalone Lib\n\nThis repository is largely taken from nixpkgs/lib. This library is meant to serve as the basis\nof a poly-repo nixpkgs fork or for standalone use in a flake which doesn't need all of nixpkgs.\n\nNoteable exceptions from `nixpkgs/lib`:\n- `systems/` was removed as it included information about system platforms which are not relevant to nix utilities.\n- `maintainers` and `teams` were removed, as that's related to package maintainership\n- Contributing instructions no longer include usage of \"lib.\", as the repo now fixates on these functions.\n- Added `packageSets.mkAutoCalledPackageDir` lib, which enables the easy creation\npackage sets from a directory\n- `lib.trivial` no longer includes nixpkgs release related information\n\n\n# Nixpkgs lib (original readme)\n\nThis directory contains the implementation, documentation and tests for the Nixpkgs `lib` library.\n\n## Overview\n\nThe evaluation entry point for `lib` is [`default.nix`](default.nix).\nThis file evaluates to an attribute set containing two separate kinds of attributes:\n- Sub-libraries:\n  Attribute sets grouping together similar functionality.\n  Each sub-library is defined in a separate file usually matching its attribute name.\n\n  Example: `lib.lists` is a sub-library containing list-related functionality such as `lib.lists.take` and `lib.lists.imap0`.\n  These are defined in the file [`lists.nix`](lists.nix).\n\n- Aliases:\n  Attributes that point to an attribute of the same name in some sub-library.\n\n  Example: `lib.take` is an alias for `lib.lists.take`.\n\nMost files in this directory are definitions of sub-libraries, but there are a few others:\n- [`minver.nix`](minver.nix): A string of the minimum version of Nix that is required to evaluate Nixpkgs.\n- [`tests`](tests): Tests, see [Running tests](#running-tests)\n  - [`release.nix`](tests/release.nix): A derivation aggregating all tests\n  - [`misc.nix`](tests/misc.nix): Evaluation unit tests for most sub-libraries\n  - `*.sh`: Bash scripts that run tests for specific sub-libraries\n  - All other files in this directory exist to support the tests\n- [`systems`](systems): The `lib.systems` sub-library, structured into a directory instead of a file due to its complexity\n- [`path`](path): The `lib.path` sub-library, which includes tests as well as a document describing the design goals of `lib.path`\n- All other files in this directory are sub-libraries\n\n### Module system\n\nThe [module system](https://nixos.org/manual/nixpkgs/#module-system) spans multiple sub-libraries:\n- [`modules.nix`](modules.nix): `lib.modules` for the core functions and anything not relating to option definitions\n- [`options.nix`](options.nix): `lib.options` for anything relating to option definitions\n- [`types.nix`](types.nix): `lib.types` for module system types\n\n## PR Guidelines\n\nFollow these guidelines for proposing a change to the interface of `lib`.\n\n### Provide a Motivation\n\nClearly describe why the change is necessary and its use cases.\n\nMake sure that the change benefits the user more than the added mental effort of looking it up and keeping track of its definition.\nIf the same can reasonably be done with the existing interface,\nconsider just updating the documentation with more examples and links.\nThis is also known as the [Fairbairn Threshold](https://wiki.haskell.org/Fairbairn_threshold).\n\nThrough this principle we avoid the human cost of duplicated functionality in an overly large library.\n\n### Make one PR for each change\n\nDon't have multiple changes in one PR, instead split it up into multiple ones.\n\nThis keeps the conversation focused and has a higher chance of getting merged.\n\n### Name the interface appropriately\n\nWhen introducing new names to the interface, such as new function, or new function attributes,\nmake sure to name it appropriately.\n\nNames should be self-explanatory and consistent with the rest of `lib`.\nIf there's no obvious best name, include the alternatives you considered.\n\n### Write documentation\n\nUpdate the [reference documentation](#reference-documentation) to reflect the change.\n\nBe generous with links to related functionality.\n\n### Write tests\n\nAdd good test coverage for the change, including:\n\n- Tests for edge cases, such as empty values or lists.\n- Tests for tricky inputs, such as a string with string context or a path that doesn't exist.\n- Test all code paths, such as `if-then-else` branches and returned attributes.\n- If the tests for the sub-library are written in bash,\n  test messages of custom errors, such as `throw` or `abortMsg`,\n\n  At the time this is only not necessary for sub-libraries tested with [`tests/misc.nix`](./tests/misc.nix).\n\nSee [running tests](#running-tests) for more details on the test suites.\n\n### Write tidy code\n\nName variables well, even if they're internal.\nThe code should be as self-explanatory as possible.\nBe generous with code comments when appropriate.\n\nAs a baseline, follow the [Nixpkgs code conventions](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#code-conventions).\n\n### Write efficient code\n\nNix generally does not have free abstractions.\nBe aware that seemingly straightforward changes can cause more allocations and a decrease in performance.\nThat said, don't optimise prematurely, especially in new code.\n\n## Reference documentation\n\nReference documentation for library functions is written above each function as a multi-line comment.\nThese comments are processed using [nixdoc](https://github.com/nix-community/nixdoc) and [rendered in the Nixpkgs manual](https://nixos.org/manual/nixpkgs/stable/#chap-functions).\nThe nixdoc README describes the [comment format](https://github.com/nix-community/nixdoc#comment-format).\n\nSee [doc/README.md](../doc/README.md) for how to build the manual.\n\n## Running tests\n\nAll library tests can be run by building the derivation in [`tests/release.nix`](tests/release.nix):\n\n```bash\nnix-build tests/release.nix\n```\n\nSome commands for quicker iteration over parts of the test suite are also available:\n\n```bash\n# Run all evaluation unit tests in tests/misc.nix\n# if the resulting list is empty, all tests passed\nnix-instantiate --eval --strict tests/misc.nix\n\n# Run the module system tests\ntests/modules.sh\n\n# Run the lib.sources tests\ntests/sources.sh\n\n# Run the lib.filesystem tests\ntests/filesystem.sh\n\n# Run the lib.path property tests\npath/tests/prop.sh\n\n# Run the lib.fileset tests\nfileset/tests.sh\n```\n\n## Commit conventions\n\n- Make sure you read about the [commit conventions](../CONTRIBUTING.md#commit-conventions) common to Nixpkgs as a whole.\n\n- Format the commit messages in the following way:\n\n  ```\n  (section): (init | add additional argument | refactor | etc)\n\n  (Motivation for change. Additional information.)\n  ```\n\n  Examples:\n\n  * getExe': check arguments\n  * fileset: Add an additional argument in the design docs\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fekala-project%2Fnix-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fekala-project%2Fnix-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fekala-project%2Fnix-lib/lists"}