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}"'')) + ]; + +})