From 85c506b7ce8bb8a495d98de1ff5fbbd49991ea60 Mon Sep 17 00:00:00 2001 From: Emery Hemingway <ehmry@posteo.net> Date: Wed, 11 Oct 2023 11:15:37 +0100 Subject: [PATCH] nim_lk: init at 20231031 https://git.sr.ht/~ehmry/nim_lk --- pkgs/by-name/ni/nim_lk/lock.json | 1 + pkgs/by-name/ni/nim_lk/package.nix | 52 ++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 pkgs/by-name/ni/nim_lk/lock.json create mode 100644 pkgs/by-name/ni/nim_lk/package.nix diff --git a/pkgs/by-name/ni/nim_lk/lock.json b/pkgs/by-name/ni/nim_lk/lock.json new file mode 100644 index 000000000000..38a4f8c8e3e8 --- /dev/null +++ b/pkgs/by-name/ni/nim_lk/lock.json @@ -0,0 +1 @@ +{"depends":[{"method":"fetchzip","packages":["npeg"],"path":"/nix/store/ffkxmjmigfs7zhhiiqm0iw2c34smyciy-source","ref":"1.2.1","rev":"26d62fdc40feb84c6533956dc11d5ee9ea9b6c09","sha256":"0xpzifjkfp49w76qmaylan8q181bs45anmp46l4bwr3lkrr7bpwh","srcDir":"src","url":"https://github.com/zevv/npeg/archive/26d62fdc40feb84c6533956dc11d5ee9ea9b6c09.tar.gz"},{"method":"fetchzip","packages":["preserves"],"path":"/nix/store/nrcpzf9hx70kry3gwhrdzcs3qicjncjh-source","ref":"20231021","rev":"edece399be70818208bf2263c30cb2bcf435bbff","sha256":"0xmw35wmw3a4lja9q4qvlvpxv3xk0hnkjg4fwfw6f3inh6zfiqki","srcDir":"src","url":"https://git.syndicate-lang.org/ehmry/preserves-nim/archive/edece399be70818208bf2263c30cb2bcf435bbff.tar.gz"}]} diff --git a/pkgs/by-name/ni/nim_lk/package.nix b/pkgs/by-name/ni/nim_lk/package.nix new file mode 100644 index 000000000000..833860b357fe --- /dev/null +++ b/pkgs/by-name/ni/nim_lk/package.nix @@ -0,0 +1,52 @@ +{ lib, buildPackages, nim2Packages, fetchFromSourcehut, openssl }: + +nim2Packages.buildNimPackage (finalAttrs: { + pname = "nim_lk"; + version = "20231031"; + nimBinOnly = true; + + src = fetchFromSourcehut { + owner = "~ehmry"; + repo = "nim_lk"; + rev = finalAttrs.version; + hash = "sha256-dXm3dfXAxgucek19f1KdRShOsJyELPTB32qgGSKId6A="; + }; + + buildInputs = [ openssl ]; + + nimFlags = finalAttrs.passthru.nimFlagsFromLockFile ./lock.json; + + meta = finalAttrs.src.meta // { + description = "Generate Nix specific lock files for Nim packages"; + homepage = "https://git.sr.ht/~ehmry/nim_lk"; + mainProgram = "nim_lk"; + license = lib.licenses.bsd3; + platforms = lib.platforms.unix; + maintainers = with lib.maintainers; [ ehmry ]; + }; + + passthru.nimFlagsFromLockFile = let + fetchDependency = let + methods = { + fetchzip = { url, sha256, ... }: + buildPackages.fetchzip { + name = "source"; + inherit url sha256; + }; + git = { fetchSubmodules, leaveDotGit, rev, sha256, url, ... }: + buildPackages.fetchgit { + inherit fetchSubmodules leaveDotGit rev sha256 url; + }; + }; + in attrs@{ method, ... }: methods.${method} attrs // attrs; + in lockFile: + with builtins; + lib.pipe lockFile [ + readFile + fromJSON + (getAttr "depends") + (map fetchDependency) + (map ({ outPath, srcDir, ... }: ''--path:"${outPath}/${srcDir}"'')) + ]; + +})