Skip to content

Commit

Permalink
Improve definitions for building on Nix
Browse files Browse the repository at this point in the history
  • Loading branch information
jbboehr committed Nov 11, 2018
1 parent b4f9dee commit 9306f30
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 36 deletions.
46 changes: 10 additions & 36 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,37 +1,11 @@
{ pkgs ? import <nixpkgs> {} }:

let
stdenv = pkgs.stdenv;
fetchurl = pkgs.fetchurl;
in
stdenv.mkDerivation rec {
name = "handlebars-spec-4.0.5-p1";

builder = pkgs.writeText "builder.sh" ''
source $stdenv/setup
buildPhase() {
echo do nothing
}
installPhase() {
mkdir -p $out/share/handlebars-spec
cp -prvd spec export $out/share/handlebars-spec/
}
genericBuild
'';

src = fetchurl {
url = https://github.com/jbboehr/handlebars-spec/archive/v4.0.5-p1.tar.gz;
sha256 = "223985eba1ce477c92bcc9c8fab212c059775a54c123dd041b813a6d3844190f";
};

meta = {
description = "The Handlebars.js specification converted to JSON.";
homepage = https://github.com/jbboehr/handlebars-spec;
license = "MIT";
maintainers = [ "John Boehr <jbboehr@gmail.com>" ];
};
}
{
pkgs ? import <nixpkgs> {},
handlebarsSpecVersion ? null,
handlebarsSpecSrc ? ./.,
handlebarsSpecSha256 ? null
}:

pkgs.callPackage ./derivation.nix {
inherit handlebarsSpecVersion handlebarsSpecSrc handlebarsSpecSha256;
}

45 changes: 45 additions & 0 deletions derivation.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
lib,
stdenv,
writeText,
fetchurl,
handlebarsSpecVersion ? null,
handlebarsSpecSrc ? null,
handlebarsSpecSha256 ? null
}:

let
orDefault = x: y: (if (!isNull x) then x else y);
in

stdenv.mkDerivation rec {
name = "handlebars-spec-${version}";
version = orDefault handlebarsSpecVersion "v4.0.5-p1";
src = orDefault handlebarsSpecSrc (fetchurl {
url = "https://github.com/jbboehr/handlebars-spec/archive/${version}.tar.gz";
sha256 = orDefault handlebarsSpecSha256 "477552869cf4a8d3cadb74f0d297988dfa9edddbc818ee8f56bae0a097dc657c";
});

builder = writeText "builder.sh" ''
source $stdenv/setup
buildPhase() {
echo do nothing
}
installPhase() {
mkdir -p $out/share/handlebars-spec
cp -prvd spec export $out/share/handlebars-spec/
}
genericBuild
'';

meta = {
description = "The Handlebars.js specification converted to JSON.";
homepage = https://github.com/jbboehr/handlebars-spec;
license = "MIT";
maintainers = [ "John Boehr <jbboehr@gmail.com>" ];
};
}

0 comments on commit 9306f30

Please sign in to comment.