{"id":13531772,"url":"https://github.com/vmchale/cpkg","last_synced_at":"2026-03-10T12:31:02.899Z","repository":{"id":128760772,"uuid":"159444003","full_name":"vmchale/cpkg","owner":"vmchale","description":"A build tool/package manager for C, configured with Dhall","archived":false,"fork":false,"pushed_at":"2023-11-06T16:08:42.000Z","size":896,"stargazers_count":68,"open_issues_count":0,"forks_count":7,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-02-25T23:17:05.522Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dhall","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vmchale.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-28T04:33:31.000Z","updated_at":"2024-10-09T12:10:57.000Z","dependencies_parsed_at":"2024-11-02T18:33:15.515Z","dependency_job_id":"d4138a70-1de6-4f38-bf01-30041d109c73","html_url":"https://github.com/vmchale/cpkg","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/vmchale/cpkg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmchale%2Fcpkg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmchale%2Fcpkg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmchale%2Fcpkg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmchale%2Fcpkg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vmchale","download_url":"https://codeload.github.com/vmchale/cpkg/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmchale%2Fcpkg/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30333430,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T05:25:20.737Z","status":"ssl_error","status_checked_at":"2026-03-10T05:25:17.430Z","response_time":106,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T07:01:05.546Z","updated_at":"2026-03-10T12:31:02.873Z","avatar_url":"https://github.com/vmchale.png","language":"Dhall","funding_links":[],"categories":["Projects","Dhall"],"sub_categories":[],"readme":"# cpkg\n\n[![Hackage CI](https://matrix.hackage.haskell.org/api/v2/packages/cpkg/badge)](https://matrix.hackage.haskell.org/package/cpkg)\n[![Hackage](https://img.shields.io/hackage/v/cpkg.svg)](http://hackage.haskell.org/package/cpkg)\n[![Dependencies of latest version on Hackage](https://img.shields.io/hackage-deps/v/cpkg.svg)](https://hackage.haskell.org/package/cpkg)\n\n`cpkg` is a build tool for C with a particular emphasis on cross compilation.\nIt is configured using\n[Dhall](http://github.com/dhall-lang/dhall-haskell).\n\nBy considering a package to be a *function* taking a `cpkg`-supplied\ninstallation directory to a series of steps, we can effectively package\nC projects with diverse build systems and handle dependencies between them.\n\nThis tool provides reasonably good support for cross-compilation of C projects\nand packages. It is not a full-fledged package manager.\n\n- [Installation](#installation)\n  - [Shell Completions](#shell-completions)\n  - [Packages](#packages)\n- [Example](#example)\n  - [Configuration](#configuration)\n  - [Dhall Prelude](#dhall-prelude)\n  - [Cabal Integration](#cabal-integration)\n- [Known Deficiencies](#known-deficiences)\n  - [Security](#security)\n  - [Performance](#performance)\n  - [Dependency Solver](#dependency-solver)\n  - [Garbage Collection](#garbage-collection)\n- [Contents](#contents)\n\n## Installation\n\n```\ncabal new-install cpkg\n```\n\n### Shell Completions\n\nAdd the following to your `~/.bashrc` for shell completions:\n\n```\neval \"$(cpkg --bash-completion-script cpkg)\"\n```\n\n### Packages\n\nTo view available packages, use `cpkg list`\n\n```\nvanessa@thinkpad ~/programming/haskell/done/cpkg 🌸 cpkg list\n\nautoconf\n    url: https://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.xz\n    version: 2.69\n    build dependencies: m4\n\n\nautomake\n    url: https://ftp.gnu.org/gnu/automake/automake-1.16.1.tar.xz\n    version: 1.16.1\n    build dependencies: autoconf\n\n\nat-spi2-atk\n    url: http://ftp.gnome.org/pub/gnome/sources/at-spi2-atk/2.30/at-spi2-atk-2.30.0.tar.xz\n    version: 2.30.0\n    dependencies: at-spi2-core, atk, libxml2\n    build dependencies: meson, ninja\n\n\nat-spi2-core\n    url: http://ftp.gnome.org/pub/gnome/sources/at-spi2-core/2.30/at-spi2-core-2.30.0.tar.xz\n    version: 2.30.0\n    dependencies: libXtst, glib\n    build dependencies: meson, ninja\n\n\natk\n    url: https://ftp.gnome.org/pub/gnome/sources/atk/2.30/atk-2.30.0.tar.xz\n    version: 2.30.0\n    build dependencies: gobject-introspection\n⋮\n```\n\n\n## Example\n\nTo install `tar`:\n\n```\ncpkg install tar\n```\n\nTo install `emacs`:\n\n```\ncpkg install emacs\n```\n\n### Configuration\n\nHere is the configuration for Lua:\n\n```dhall\nlet prelude = https://raw.githubusercontent.com/vmchale/cpkg/master/dhall/cpkg-prelude.dhall\nin\n\nlet lua =\n  λ(v : List Natural) →\n    let printLuaOS =\n      λ(os : types.OS) →\n        merge\n          { FreeBSD   = λ(_ : {}) → \"freebsd\"\n          , OpenBSD   = λ(_ : {}) → \"bsd\"\n          , NetBSD    = λ(_ : {}) → \"bsd\"\n          , Solaris   = λ(_ : {}) → \"solaris\"\n          , Dragonfly = λ(_ : {}) → \"bsd\"\n          , Linux     = λ(_ : {}) → \"linux\"\n          , Darwin    = λ(_ : {}) → \"macosx\"\n          , Windows   = λ(_ : {}) → \"mingw\"\n          , Redox     = λ(_ : {}) → \"generic\"\n          , Haiku     = λ(_ : {}) → \"generic\"\n          , IOS       = λ(_ : {}) → \"generic\"\n          , AIX       = λ(_ : {}) → \"generic\"\n          , Hurd      = λ(_ : {}) → \"generic\"\n          , Android   = λ(_ : {}) → \"generic\"\n          , NoOs      = λ(_ : {}) → \"c89\"\n          }\n          os\n    in\n\n    let luaBuild =\n      λ(cfg : types.BuildVars) →\n        let cc = prelude.mkCCArg cfg\n        in\n\n        let ldflags =\n          (prelude.mkLDFlags cfg.linkDirs).value\n        in\n\n        let cflags =\n          (prelude.mkCFlags cfg.includeDirs).value\n        in\n\n        let os =\n          prelude.osCfg cfg\n        in\n\n        [ prelude.call (prelude.defaultCall ⫽ { program = \"make\"\n                                              , arguments = cc # [ printLuaOS os, \"MYLDFLAGS=${ldflags}\", \"MYCFLAGS=${cflags}\", \"MYLIBS=-lncurses\" ]\n                                              })\n        ]\n    in\n\n    let luaInstall =\n      λ(cfg : types.BuildVars) →\n        [ prelude.call (prelude.defaultCall ⫽ { program = \"make\"\n                                              , arguments = [ \"install\", \"INSTALL_TOP=${cfg.installDir}\" ]\n                                              }) ]\n          # prelude.symlinkBinaries [ \"bin/lua\", \"bin/luac\" ]\n    in\n\n    prelude.simplePackage { name = \"lua\", version = v } ⫽\n      { pkgUrl = \"http://www.lua.org/ftp/lua-${prelude.showVersion v}.tar.gz\"\n      , configureCommand = prelude.doNothing\n      , buildCommand = luaBuild\n      , installCommand = luaInstall\n      , pkgDeps = [ prelude.unbounded \"readline\"\n                  , prelude.unbounded \"ncurses\"\n                  ]\n      }\nin\n\nlua [5,3,5]\n```\n\n### Cabal Integration\n\nAfter running\n\n```\ncpkg install libX11 --target=arm-linux-gnueabihf\ncpkg install libXext --target=arm-linux-gnueabihf\ncpkg install libXrandr --target=arm-linux-gnueabihf\ncpkg install libXinerama --target=arm-linux-gnueabihf\ncpkg install libXScrnSaver --target=arm-linux-gnueabihf\n```\n\nYou can dump flags to be passed to cabal with\n\n```\ncpkg dump-cabal libX11 libXext libXrandr libXinerama libXScrnSaver --target=arm-linux-gnueabihf\n```\n\nwhich will produce something like\n\n```\n--extra-lib-dirs=/home/vanessa/.cpkg/arm-linux-gnueabihf/libX11-1.6.7-820c8166b4caadb/lib --extra-lib-dirs=/home/vanessa/.cpkg/arm-linux-gnueabihf/libXext-1.3.3-1bad0a89c6794a53/lib --extra-lib-dirs=/home/vanessa/.cpkg/arm-linux-gnueabihf/libXrandr-1.5.1-f58f951a622e5c2/lib --extra-lib-dirs=/home/vanessa/.cpkg/arm-linux-gnueabihf/libXinerama-1.1.4-516496f7e04d34be/lib --extra-lib-dirs=/home/vanessa/.cpkg/arm-linux-gnueabihf/libXScrnSaver-1.2.3-60f6993b79a87725/lib\n```\n\nThis could be used, for example, to cross-compile `xmonad`, viz.\n\n```\ncabal new-install xmonad --with-ghc arm-linux-gnueabihf-ghc --with-ghc-pkg arm-linux-gnueabihf-ghc-pkg $(cpkg dump-cabal libX11 libXext libXrandr libXinerama libXScrnSaver --target=arm-linux-gnueabihf)\n```\n\n### Dhall Prelude\n\nThere is\na [prelude](https://github.com/vmchale/cpkg/blob/master/dhall/cpkg-prelude.dhall)\navailable containing functions which simplify the process of writing package\ndescriptions. As an example, we can install `sed`\n\n```dhall\nlet prelude = https://raw.githubusercontent.com/vmchale/cpkg/master/dhall/cpkg-prelude.dhall\nin\n\nlet sed =\n  λ(v : List Natural) →\n    prelude.makeGnuExe { name = \"sed\", version = v }\nin\n\nsed [4,5]\n```\n\n## Known Deficiencies\n\n### Security\n\nThis tool is insecure.\n\n### Performance\n\nThis tool is not performant.\n\n### Dependency Solver\n\nCurrently, there is no dependency solver. It should be relatively easy to add\na version-based dependency solver to the code.\n\n### Garbage Collection\n\nCurrently, there is no garbage collector à la `$ nix-collect-garbage`. This will\n*not* be relatively easy to add, because it will require that the global package\nindex be re-implemented (ideally using a proper database).\n\n## Contents\n\nLovingly provided by [polyglot](https://github.com/vmchale/polyglot):\n\n```\n───────────────────────────────────────────────────────────────────────────────\n Language             Files       Lines         Code     Comments       Blanks\n───────────────────────────────────────────────────────────────────────────────\n Bash                     4          58           49            3            6\n Cabal                    1         165          147            0           18\n Cabal Project            1           4            3            0            1\n Dhall                    5        6412         5724            0          688\n Haskell                 32        1999         1643           37          319\n Makefile                 1          12            8            0            4\n Markdown                 3         556          448            0          108\n YAML                     4         114          110            0            4\n───────────────────────────────────────────────────────────────────────────────\n Total                   51        9320         8132           40         1148\n───────────────────────────────────────────────────────────────────────────────\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvmchale%2Fcpkg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvmchale%2Fcpkg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvmchale%2Fcpkg/lists"}