I would like to package elsa.
I started with a default.nix to nix-build
which led me to an error (pls have a look at the linked ticket conversation) which seems to break the build somehow and does not occur when I run the seemingly same Makefile clauses manually in a nix-shell equipped with proper env.
When I rewrote the derivation based on this conversation entry I was able to run nix-shell
inside which I would make build
with a successful build as a result.
First my derivation as of now:
The elsa derivation
# derivation.nix
# https://kalbas.it/2019/03/17/announcing-the-new-golang-infrastructure-buildgomodule/
# https://github.com/NixOS/nixpkgs/search?q=buildGoModule
# https://discourse.nixos.org/search?q=buildGoModule
# https://github.com/NixOS/nixpkgs/search?q=go-bindata
{ fetchFromGitHub, buildGoModule, lib, go-bindata, go-bindata-assetfs }:
buildGoModule rec {
pname = "elsa";
version = "master";
src = fetchFromGitHub {
owner = "elsaland";
repo = "elsa";
rev = "0375d76d2c802b497cec44e5069920643287cc98";
sha256 = "0ny2fsj7r05711d7k3xpl35k4pz86y2vnrk4bqqrdb5xqlh1i7aq";
};
vendorSha256 = "1n3yj3p5nikbr5fwk44rpjk3wvay015k0gvl6pwdyx0yvpazrl4p";
buildInputs = [ go-bindata-assetfs go-bindata ];
postBuild = ''
# what I do in nix-shell
make build
'';
meta = with lib; {
maintainer = with maintainers; [ ];
license = licenses.mit;
description = "Elsa is a minimal, fast and secure runtime for Javascript and Typescript written in Go";
};
}
The overlay
# overlay.nix
self: super:
{
elsa = self.callPackage ./derivation.nix { };
}
default.nix
# default.nix
let
nixpkgs =
import <nixpkgs> { overlays = [ (import ./overlay.nix) ]; };
in nixpkgs.elsa
shell.nix
# shell.nix
let
pkgs =
import <nixpkgs> { overlays = [ (import ./overlay.nix) ]; };
go-toolchain = pkgs.symlinkJoin {
name = "go-toolchain";
paths = [ pkgs.go ];
};
in with pkgs;
mkShell {
name = "buildr";
buildInputs = [go-bindata-assetfs go-bindata go-toolchain];
}
If the nix-shell approach is correct how I could achieve the same (env ?) using the nix-build approach (meaning no extra nix-shell spawned just nix-build with the default.nix).
The derivations in both (first nix-build then nix-shell) cases are as behind the links:
nix-buil(d)t derivation and above env I named buildr in nix-shell