Skip to content

Commit

Permalink
Set up a nix flake for typeshare
Browse files Browse the repository at this point in the history
  • Loading branch information
savannidgerinel committed Apr 17, 2023
1 parent 02e53c2 commit e207997
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
60 changes: 60 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Nix Flake for installing typeshare outside of the NixPkgs source tree.
#
# Thank you to figsoda, who originally wrote the package build and install
# instructions. I (savannidgerinel) copied that stanza from the nixpkgs
# repository.
# https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/development/tools/rust/typeshare/default.nix#L32
#
# To use this in your repository,
{
description = "Create types in Rust and convert them to other languages";

inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = inputs@{ self, nixpkgs, flake-utils }:
flake-utils.lib.eachSystem ["x86_64-linux"] (system:
let
pkgs = import nixpkgs { inherit system; };
typeshare = with pkgs;
rustPlatform.buildRustPackage rec {
pname = "typeshare";
version = (builtins.fromTOML (builtins.readFile ./cli/Cargo.toml)).package.version;

src = lib.cleanSource ./.;

cargoLock = { lockFile = ./Cargo.lock; };

nativeBuildInputs = [ installShellFiles ];

buildFeatures = [ "go" ];

postInstall = ''
installShellCompletion --cmd typeshare \
--bash <($out/bin/typeshare completions bash) \
--fish <($out/bin/typeshare completions fish) \
--zsh <($out/bin/typeshare completions zsh)
'';

meta = with lib; {
description = "Command Line Tool for generating language files with typeshare";
homepage = "https://github.com/1password/typeshare";
changelog = "https://github.com/1password/typeshare/blob/v${version}/CHANGELOG.md";
license = with licenses; [ asl20 /* or */ mit ];
};
};
in rec {
packages.default = typeshare;
});
}

0 comments on commit e207997

Please sign in to comment.