{"id":16337127,"url":"https://github.com/justinwoo/psc-package2nix","last_synced_at":"2025-03-22T23:32:28.161Z","repository":{"id":149405676,"uuid":"155574938","full_name":"justinwoo/psc-package2nix","owner":"justinwoo","description":"Tool to derive a Nix expression from a psc-package.json configuration.","archived":false,"fork":false,"pushed_at":"2020-01-18T04:48:07.000Z","size":105,"stargazers_count":13,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T15:48:37.749Z","etag":null,"topics":["nix","psc-package","purescript","spacchetti"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/justinwoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"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-10-31T14:53:01.000Z","updated_at":"2020-01-18T04:48:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"2005e51b-e94f-4632-b3a9-7fd704851f2c","html_url":"https://github.com/justinwoo/psc-package2nix","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinwoo%2Fpsc-package2nix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinwoo%2Fpsc-package2nix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinwoo%2Fpsc-package2nix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinwoo%2Fpsc-package2nix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/justinwoo","download_url":"https://codeload.github.com/justinwoo/psc-package2nix/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245036127,"owners_count":20550662,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["nix","psc-package","purescript","spacchetti"],"created_at":"2024-10-10T23:45:57.965Z","updated_at":"2025-03-22T23:32:28.146Z","avatar_url":"https://github.com/justinwoo.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Psc-Package2Nix\n\n[![Build Status](https://travis-ci.com/justinwoo/psc-package2nix.svg?branch=master)](https://travis-ci.com/justinwoo/psc-package2nix)\n\n## Double Warning\n\nIf you actually want to use this, you probably should look at \u003chttps://github.com/justinwoo/soba\u003e. You can refer to the notes here for more literature.\n\n## Warning\n\nYou probably will want to use \u003chttps://github.com/spacchetti/spago\u003e and \u003chttps://github.com/justinwoo/spago2nix\u003e instead.\n\n-----\n\nA tool to generate a Nix expression from Psc-Package configuration. *You could also probably use Spago by using `spago psc-package-insdhall`.* Works by prefetching Git SHAs of the dependencies you depend on.\n\nRead the blog post about this project here: \u003chttps://qiita.com/kimagure/items/85a64437f9af78398638\u003e. There's also a post about this whole setup (going from Bower): \u003chttps://qiita.com/kimagure/items/aec640d0047d08d2ce90\u003e.\n\nI (Justin) gave a talk about Psc-Package2Nix in the Helsinki Haskell meetup a while ago: \u003chttps://speakerdeck.com/justinwoo/nix-ify-your-psc-package-dependencies\u003e. The talk is a little bit out of date but the core ideas are the same.\n\n## Spago users\n\nSpago users should look at this project: https://twitter.com/jusrin00/status/1142419083255787526\n\n## Show me the code!\n\nSee [test-build](./test-build). However, this will in many ways not be what you want for development, so you might end up with using `pp2n install; pp2n build` in development.\n\n## Usage example\n\nFirst, you should include psc-package2nix in some way. One way to do this would be to use my [Easy-PureScript-Nix](https://github.com/justinwoo/easy-purescript-nix) derivations, but otherwise you could use this repository directly as a source.\n\n```nix\n{ pkgs ? import \u003cnixpkgs\u003e {} }:\n\nlet\n  pp2n = import (pkgs.fetchFromGitHub {\n    owner = \"justinwoo\";\n    repo = \"psc-package2nix\";\n    rev = \"cc48ccd64862366a44b4185a79de321f93755782\";\n    sha256 = \"0cvd1v3d376jiwh4rfhlyijxw3j6jp9rkm9hdb7k7sjxqs1dsviv\";\n  }) { inherit pkgs; };\n\n  easy-ps = import (pkgs.fetchFromGitHub {\n    owner = \"justinwoo\";\n    repo = \"easy-purescript-nix\";\n    rev = \"5d8808480436f178ccdc6593744cb6ca642cbb6c\";\n    sha256 = \"0r80d4dmagvkgm44rpjszl84xwgcwdbks2x9inad7akcpmkc8nnh\";\n  });\n\nin pkgs.stdenv.mkDerivation {\n  name = \"pp2n-test-shell\";\n  buildInputs = [pp2n easy-ps.purs];\n}\n```\n\nIn a project where you have a `psc-package.json` file, you should now be able to run `pp2n psc-package2nix`:\n\n```json\n{\n  \"name\": \"pp2n-test\",\n  \"set\": \"psc-0.12.3\",\n  \"source\": \"https://github.com/purescript/package-sets.git\",\n  \"depends\": [\n    \"prelude\"\n  ]\n}\n```\n\n```\n\u003e pp2n psc-package2nix\n/nix/store/vcxj8hd3xjsqlpv45d0cwb44lz5h4zby-package-sets\nbuilt package set to .psc-package/psc-0.12.3/.set\nfetching .psc-package2nix/prelude-v4.1.0\nwrote packages.nix\n```\n\nNote that the package set is built by `nix-build` to the package set location (see package-sets README for more explanation). The hashes for all dependencies (including transitive dependencies in the package set) are then solved for and their hashes are stored as flat files in `.psc-package2nix/` for usage in generating `packages.nix`.\n\nWith the `packages.nix` generated, now you can install your dependencies into your nix store and have them automatically copied to `.psc-package` under the correct psc-package directories. This you can accomplish with the various setsups in the test directories. And while you can edit `packages.nix` to your liking, you will find that the problem comes up that Psc-Package will not know how to find new packages, because it uses the package set file to resolve that information. You could try to use `pp2n` in place of Psc-Package for most operations you need, but it's still likely that you will instead want to provide for the package set file being available. If you truly must edit the contents of your package set often, you might consider combining this tool with Spago's psc-package insdhall tools.\n\nBut really, you can do almost anything you want with this. You might mix and match some various parts of what is here to fit your own needs.\n\n## Project development workflow with pp2n\n\nBy default, `pp2n` will install dependencies in a way that Psc-Package can also use.\n\n```\n\u003e pp2n install\nInstalling .psc-package/psc-0.12.3/prelude/v4.1.0.\n```\n\nNow you can build either using `pp2n build` or using plain old `psc-package build`.\n\n```\n\u003e pp2n build\nCompiling Data.Symbol\nCompiling Record.Unsafe\n...\n```\n\nSee the example repo here: \u003chttps://github.com/justinwoo/pp2n-test\u003e\n\n## More Information\n\nIf you need more information on how Psc-Package works, you might see the Package-Sets README: \u003chttps://github.com/purescript/package-sets\u003e\n\n## Complaints\n\nPRs welcome\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinwoo%2Fpsc-package2nix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustinwoo%2Fpsc-package2nix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinwoo%2Fpsc-package2nix/lists"}