Skip to content

Added a nix flake for cddl-codegen #243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions flake.lock

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

72 changes: 72 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
description = "cddl-codegen: Generate Rust, WASM and JSON code from CDDL specifications";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = {
nixpkgs,
flake-utils,
rust-overlay,
...
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs {
overlays = [(import rust-overlay)];
inherit system;
};

rustToolchain = pkgs.rust-bin.nightly.latest.default;

nativeBuildInputs = with pkgs; [
rustToolchain
pkg-config
which
rustfmt
makeWrapper
];
in {
devShells.default = pkgs.mkShell {
buildInputs = nativeBuildInputs;
};

packages.default = pkgs.rustPlatform.buildRustPackage {
pname = "cddl-codegen";
version = "0.1.0";
src = ./.;

inherit nativeBuildInputs;

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

# the regular tests don't run yet
checkPhase = ''
cargo test comment_ast
'';

postInstall = ''
wrapProgram $out/bin/cddl-codegen \
--set PATH ${pkgs.lib.makeBinPath [pkgs.rustfmt pkgs.which]} \
--add-flags "--static-dir ${./static}"
'';

meta = with pkgs.lib; {
description = "Codegen serialization logic for CBOR automatically from a CDDL specification";
homepage = "https://github.com/dcSpark/cddl-codegen";
license = licenses.mit;
maintainers = [];
};
};
}
);
}