{"id":13822332,"url":"https://github.com/jonringer/nix-template","last_synced_at":"2025-07-06T13:34:02.546Z","repository":{"id":38974710,"uuid":"280289843","full_name":"jonringer/nix-template","owner":"jonringer","description":"Make creating nix expressions easy","archived":false,"fork":false,"pushed_at":"2024-11-20T19:15:33.000Z","size":206,"stargazers_count":212,"open_issues_count":9,"forks_count":8,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-28T07:03:58.596Z","etag":null,"topics":["cargo","nixpkgs","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonringer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2020-07-17T00:41:15.000Z","updated_at":"2025-03-22T01:55:06.000Z","dependencies_parsed_at":"2024-08-04T08:08:18.413Z","dependency_job_id":"41cf0cd7-3218-4ff7-9cd0-4fb4367ae9f4","html_url":"https://github.com/jonringer/nix-template","commit_stats":{"total_commits":147,"total_committers":7,"mean_commits":21.0,"dds":0.09523809523809523,"last_synced_commit":"ca34220b1c4fa615dee576b4ca571694d9730384"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonringer%2Fnix-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonringer%2Fnix-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonringer%2Fnix-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonringer%2Fnix-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonringer","download_url":"https://codeload.github.com/jonringer/nix-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247139625,"owners_count":20890262,"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":["cargo","nixpkgs","rust"],"created_at":"2024-08-04T08:01:55.243Z","updated_at":"2025-04-04T08:05:15.892Z","avatar_url":"https://github.com/jonringer.png","language":"Rust","funding_links":[],"categories":["Rust","Learning"],"sub_categories":[],"readme":"# Nix-template\n\n*NOTE:* This is still WIP, but should be useful in most situations\n\nMake creating nix expressions easy. Provide a nice way to create largely boilerplate nix-expressions.\n\n[![Packaging status](https://repology.org/badge/vertical-allrepos/nix-template.svg)](https://repology.org/project/nix-template/versions)\n\n## Roadmap\n\n- [ ] Finalize cli semantics\n- Ease usage with nixpkgs repo\n  - [X] Write to correct location using path\n    - [X] Improve logic around directories vs files\n    - [ ] Improve template-specific items\n      - [ ] generate buildGoModule's depsSha256\n      - [ ] generate buildRustPackages's cargoSha256\n  - [X] Print top-level addition statement\n- Support Language/frameworks/usage templates:\n  - [X] Stdenv\n  - [X] Python\n  - [X] mkShell\n  - [x] Qt\n  - [x] Go\n  - [x] Rust\n  - [x] Flakes\n  - [x] NixOS Module\n  - [x] NixOS Test\n  - [ ] Haskell\n  - [ ] and many more...\n- [ ] Add option (-d, --documentation-url) to embed noob-friendly comments and explanations about common usage patterns\n- Allow contributor information to be set locally (similar to git settings)\n  - [X] Set maintainer name through `$XDG_CONFIG_HOME`\n  - [X] Set nixpkgs-root path through `$XDG_CONFIG_HOME`\n- Better integration with fetchers\n  - Automatically determine version and sha256\n    - [X] Github (need a way to pass owner and repo)\n    - [X] Pypi (will need a way to pass pypi pname, as it may differ from installable path)\n- [X] Implement shell completion (nix-template completions \u003cSHELL\u003e)\n- [ ] Implement `project` subcommand, for creating a flake setup for new projects #51\n  - [ ] Implement `init` subcommand, for creating new projects #52\n\n## Current Usage (--from-url, github and pypi only)\n\n```bash\n$ nix-template rust -n --from-url github.com/jonringer/nix-template\nCreating directory: /home/jon/projects/nixpkgs/pkgs/applications/misc/nix-template\nGenerating python expression at /home/jon/projects/nixpkgs/pkgs/applications/misc/nix-template/default.nix\nPlease add the following line to the approriate file in top-level:\n\n  nix-template = callPackage ../applications/misc/nix-template { };\n```\nThe resulting file:\n```\n# $NIXPKGS_ROOT/pkgs/applications/misc/nix-template/default.nix\n{ lib\n, rustPlatform\n, fetchFromGitHub\n}:\n\nrustPlatform.buildRustPackage rec {\n  pname = \"nix-template\";\n  version = \"0.3.0\";\n\n  src = fetchFromGitHub {\n    owner = \"jonringer\";\n    repo = pname;\n    rev = \"v${version}\";\n    sha256 = \"sha256-5redgssfwbNEgpjmakIcU8cL4Xg1kPvyK88v+xMqAtw=\";\n  };\n\n  cargoSha256 = \"0000000000000000000000000000000000000000000000000000\";\n\n  buildInputs = [ ];\n\n  meta = with lib; {\n    description = \"Make creating nix expressions easy\";\n    homepage = \"https://github.com/jonringer/nix-template\";\n    license = licenses.cc0;\n    maintainers = with maintainers; [ jonringer ];\n  };\n}\n```\n\n## Current Usage (Generically)\n\n```bash\n# only need to config once per user\n$ nix-template config name jonringer\n$ nix-template config nixpkgs-root /home/jon/projects/nixpkgs\n\n# add a package\n$ nix-template python --nixpkgs --pname requests -f pypi -l asl20\nCreating directory: /home/jon/projects/nixpkgs/pkgs/development/python-modules/requests/\nGenerating python expression at /home/jon/projects/nixpkgs/pkgs/development/python-modules/requests/default.nix\nPlease add the following line to the approriate file in top-level:\n\n  requests = callPackage ../development/python-modules/requests { };\n```\n```nix\n# pkgs/development/python-modules/requests/default.nix\n{ lib\n, buildPythonPackage\n, fetchPypi\n}:\n\nbuildPythonPackage rec {\n  pname = \"requests\";\n  version = \"0.0.1\";\n\n  src = fetchPypi {\n    inherit pname version;\n    sha256 = \"0000000000000000000000000000000000000000000000000000\";\n  };\n\n  propagatedBuildInputs = [ ];\n\n  pythonImportsCheck = [ \"requests\" ];\n\n  meta = with lib; {\n    description = \"CHANGEME\";\n    homepage = \"https://github.com/CHANGEME/requests/\";\n    license = licenses.asl20;\n    maintainer = with maintainers; [ jonringer ];\n  };\n}\n```\n\n### Installation\n\nfrom nixpkgs (unstable, not available in 20.03):\n```\n$ nixenv -iA nix-template\n```\n\nwith nix-cli (from this repository):\n```\n$ nix-env -f default.nix -iA \"\"\n```\n\nwith cargo\n```\n$ cargo install --path .\n```\n\n### Development\n\nInstalling depedencies on nixpkgs:\n```\nnix-shell\n# or\nnix develop\n```\n\nOther platforms, you'll need the following dependencies:\n  - cargo\n  - rustc\n  - rust-clippy\n\n## End Goal (Only better nixpkgs support missing)\n\n```bash\n# only need to config once per user\n$ nix-template config name jonringer\n$ nix-template config nixpkgs-root /home/jon/projects/nixpkgs\n\n# add a package\n$ nix-template python --nixpkgs -u https://pypi.org/project/requests/\nDetermining latest release for requests\nCreating directory: /home/jon/projects/nixpkgs/pkgs/development/python-modules/requests/\nGenerating python expression at /home/jon/projects/nixpkgs/pkgs/development/python-modules/requests/default.nix\nFor an addition to nixpkgs as a python package, please add the following to pkgs/top-level/python-packages.nix:\n\n  requests = callPackage ../development/python-modules/requests { };\n\nFor an addition to nixpkgs as a python application, please add the following to pkgs/top-level/all-packages.nix:\n\n  requests = with python3Packages; toPythonApplication requests { };\n```\n```nix\n{ lib\n, buildPythonPackage\n, fetchPypi\n, certifi\n, charset-normalizer\n, idna\n, urllib3\n}:\n\nbuildPythonPackage rec {\n  pname = \"requests\";\n  version = \"2.28.1\";\n\n  src = fetchPypi {\n    inherit pname version;\n    sha256 = \"sha256-fFWZsQL+3apmHIJsVqtP7ii/0X9avKHrvj5/GdfJeYM=\";\n  };\n\n  propagatedBuildInputs = [\n    certifi\n    charset-normalizer\n    idna\n    urllib3\n  ];\n\n  pythonImportsCheck = [ \"requests\" ];\n\n  meta = with lib; {\n    description = \"Python HTTP for Humans\";\n    homepage = \"https://requests.readthedocs.io\";\n    license = licenses.asl20;\n    maintainers = with maintainers; [ jonringer ];\n  };\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonringer%2Fnix-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonringer%2Fnix-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonringer%2Fnix-template/lists"}