nix-samples/flake-mkDerivation/flake.nix

54 lines
1.7 KiB
Nix
Raw Normal View History

2024-03-19 07:46:33 +01:00
# Source: https://fasterthanli.me/series/building-a-rust-service-with-nix/part-10#a-flake-with-derivation
# nix build .#packages.x86_64-linux.shaka-packager
# nix build .#shaka-packager
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
name = "simple";
src = ./.;
pkgs = nixpkgs.legacyPackages.${system};
in
{
packages.default = derivation {
inherit system name src;
builder = with pkgs; "${bash}/bin/bash";
args = [ "-c" "echo foo > $out" ];
};
packages.shaka-packager =
let
version = "2.6.1";
inherit (pkgs) stdenv lib;
in
stdenv.mkDerivation
{
name = "shaka-packager-${version}";
# https://nixos.wiki/wiki/Packaging/Binaries
src = pkgs.fetchurl {
url =
"https://github.com/shaka-project/shaka-packager/releases/download/v${version}/packager-linux-x64";
sha256 = "sha256-MoMX6PEtvPmloXJwRpnC2lHlT+tozsV4dmbCqweyyI0=";
};
dontUnpack = true;
sourceRoot = ".";
installPhase = ''
install -m755 -D $src $out/bin/shaka-packager
'';
meta = with nixpkgs.lib; {
homepage = "https://shaka-project.github.io/shaka-packager/html/";
description =
"Media packaging framework for VOD and Live DASH and HLS applications";
platforms = platforms.linux;
};
};
}
);
}