All Projects → jonringer → nix-template

jonringer / nix-template

Licence: CC0-1.0 license
Make creating nix expressions easy

Programming Languages

rust
11053 projects
Nix
1067 projects

Projects that are alternatives of or similar to nix-template

crane
A Nix library for building cargo projects. Never build twice thanks to incremental artifact caching.
Stars: ✭ 348 (+116.15%)
Mutual labels:  cargo, nixpkgs
cross
“Zero setup” cross compilation and “cross testing” of Rust crates
Stars: ✭ 3,550 (+2104.97%)
Mutual labels:  cargo
cargo-cook
A rust cargo subcommand which cooks your crate
Stars: ✭ 29 (-81.99%)
Mutual labels:  cargo
cargo-i18n
A Rust Cargo sub-command and libraries to extract and build localization resources to embed in your application/library
Stars: ✭ 88 (-45.34%)
Mutual labels:  cargo
haskell-overridez
Simplify usage of nix dependencies during haskell development
Stars: ✭ 32 (-80.12%)
Mutual labels:  nixpkgs
nixpkgs
Nix Packages collection used in Nubank
Stars: ✭ 24 (-85.09%)
Mutual labels:  nixpkgs
cargo-supply-chain
Gather author, contributor and publisher data on crates in your dependency graph.
Stars: ✭ 287 (+78.26%)
Mutual labels:  cargo
rust-azure-devops
[No longer maintain] 🦀 Rust extension for Azure DevOps
Stars: ✭ 26 (-83.85%)
Mutual labels:  cargo
kingslayer
A text-based adventure written in Rust
Stars: ✭ 28 (-82.61%)
Mutual labels:  cargo
terraform-provider-nix
terraform provider that manages nix builds and nixos machines.
Stars: ✭ 105 (-34.78%)
Mutual labels:  nixpkgs
cargo-limit
Cargo with less noise: warnings are skipped until errors are fixed, Neovim integration, etc.
Stars: ✭ 105 (-34.78%)
Mutual labels:  cargo
naersk
Build rust crates in Nix. No configuration, no code generation, no IFD. Sandbox friendly. [maintainer: @Patryk27]
Stars: ✭ 440 (+173.29%)
Mutual labels:  cargo
crates
crates is an extension aims to help people to manage their dependencies for rust (crates.io & TOML).
Stars: ✭ 156 (-3.11%)
Mutual labels:  cargo
carnet
A Tool for Sandboxing Cargo and Buildscripts
Stars: ✭ 78 (-51.55%)
Mutual labels:  cargo
yants
Yet Another Nix Type System | Source has moved to https://git.tazj.in/tree/nix/yants
Stars: ✭ 35 (-78.26%)
Mutual labels:  nixpkgs
rsblocks
A fast status-bar for dwm window manager written in Rust 🦀
Stars: ✭ 30 (-81.37%)
Mutual labels:  cargo
nexus-repository-cargo
Nexus Repository Cargo Format
Stars: ✭ 33 (-79.5%)
Mutual labels:  cargo
dotfiles
Dotfiles. Mac and *nix. Handy scripts, configurations for bash, zsh, git, asdf, Sublime Text, Karabiner-Elements, BetterTouchTool and more.
Stars: ✭ 15 (-90.68%)
Mutual labels:  nixpkgs
cargo-release
Cargo subcommand `release`: everything about releasing a rust crate.
Stars: ✭ 854 (+430.43%)
Mutual labels:  cargo
cargo-aur
Prepare Rust projects to be released on the Arch Linux User Repository
Stars: ✭ 49 (-69.57%)
Mutual labels:  cargo

Nix-template

NOTE: This is still WIP, but should be useful in most situations

Make creating nix expressions easy. Provide a nice way to create largely boilerplate nix-expressions.

Packaging status

Roadmap

  • Finalize cli semantics
  • Ease usage with nixpkgs repo
    • Write to correct location using path
      • Improve logic around directories vs files
      • Improve template-specific items
        • generate buildGoModule's depsSha256
        • generate buildRustPackages's cargoSha256
    • Print top-level addition statement
  • Support Language/frameworks/usage templates:
    • Stdenv
    • Python
    • mkShell
    • Qt
    • Go
    • Rust
    • Flakes
    • NixOS Module
    • NixOS Test
    • Haskell
    • and many more...
  • Add option (--comments?) to embed noob-friendly comments and explanations about common usage patterns
  • Allow contributor information to be set locally (similar to git settings)
    • Set maintainer name through $XDG_CONFIG_HOME
    • Set nixpkgs-root path through $XDG_CONFIG_HOME
  • Better integration with fetchers
    • Automatically determine version and sha256
      • Github (need a way to pass owner and repo)
      • Pypi (will need a way to pass pypi pname, as it may differ from installable path)
  • Implement shell completion (nix-template completions )

Current Usage (--from-url, github and pypi only)

$ nix-template rust -n --from-url github.com/jonringer/nix-template
Creating directory: /home/jon/projects/nixpkgs/pkgs/applications/misc/nix-template
Generating python expression at /home/jon/projects/nixpkgs/pkgs/applications/misc/nix-template/default.nix
Please add the following line to the approriate file in top-level:

  nix-template = callPackage ../applications/misc/nix-template { };

The resulting file:

# $NIXPKGS_ROOT/pkgs/applications/misc/nix-template/default.nix
{ lib
, rustPlatform
, fetchFromGitHub
}:

rustPlatform.buildRustPackage rec {
  pname = "nix-template";
  version = "0.2.0";

  src = fetchFromGitHub {
    owner = "jonringer";
    repo = pname;
    rev = "v${version}";
    sha256 = "0iw2ag0mnb373kgi39c8sgi6ij44xmpfl0vs1471aq6ly54n3lch";
  };

  cargoSha256 = "0000000000000000000000000000000000000000000000000000";

  buildInputs = [ ];

  meta = with lib; {
    description = "Make creating nix expressions easy";
    homepage = "https://github.com/jonringer/nix-template/";
    license = licenses.cc0;
    maintainers = with maintainers; [ jonringer ];
  };
}

Current Usage (Generically)

# only need to config once per user
$ nix-template config name jonringer
$ nix-template config nixpkgs-root /home/jon/projects/nixpkgs

# add a package
$ nix-template python --nixpkgs --pname requests -f pypi -l asl20
Creating directory: /home/jon/projects/nixpkgs/pkgs/development/python-modules/requests/
Generating python expression at /home/jon/projects/nixpkgs/pkgs/development/python-modules/requests/default.nix
Please add the following line to the approriate file in top-level:

  requests = callPackage ../development/python-modules/requests { };
# pkgs/development/python-modules/requests/default.nix
{ lib
, buildPythonPackage
, fetchPypi
}:

buildPythonPackage rec {
  pname = "requests";
  version = "0.0.1";

  src = fetchPypi {
    inherit pname version;
    sha256 = "0000000000000000000000000000000000000000000000000000";
  };

  propagatedBuildInputs = [ ];

  pythonImportsCheck = [ "requests" ];

  meta = with lib; {
    description = "CHANGEME";
    homepage = "https://github.com/CHANGEME/requests/";
    license = licenses.asl20;
    maintainer = with maintainers; [ jonringer ];
  };
}

Installation

from nixpkgs (unstable, not available in 20.03):

$ nixenv -iA nix-template

with nix-cli (from this repository):

$ nix-env -f default.nix -iA ""

with cargo

$ cargo install --path .

Development

Installing depedencies on nixpkgs:

nix-shell
# or
nix develop

Other platforms, you'll need the following dependencies:

  • cargo
  • rustc
  • rust-clippy

End Goal (Only better nixpkgs support missing)

# only need to config once per user
$ nix-template config name jonringer
$ nix-template config nixpkgs-root /home/jon/projects/nixpkgs

# add a package
$ nix-template python --nixpkgs -u https://pypi.org/project/requests/
Determining latest release for requests
Creating directory: /home/jon/projects/nixpkgs/pkgs/development/python-modules/requests/
Generating python expression at /home/jon/projects/nixpkgs/pkgs/development/python-modules/requests/default.nix
For an addition to nixpkgs as a python package, please add the following to pkgs/top-level/python-packages.nix:

  requests = callPackage ../development/python-modules/requests { };

For an addition to nixpkgs as a python application, please add the following to pkgs/top-level/all-packages.nix:

  requests = with python3Packages; toPythonApplication requests { };
{ lib
, buildPythonPackage
, fetchPypi
}:

buildPythonPackage rec {
  pname = "requests";
  version = "2.26.0";

  src = fetchPypi {
    inherit pname version;
    sha256 = "b8aa58f8cf793ffd8782d3d8cb19e66ef36f7aba4353eec859e74678b01b07a7";
  };

  propagatedBuildInputs = [ ];

  pythonImportsCheck = [ "requests" ];

  meta = with lib; {
    description = "Python HTTP for Humans";
    homepage = "https://requests.readthedocs.io";
    license = licenses.asl20;
    maintainers = with maintainers; [ jonringer ];
  };
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].