diff --git a/.gitignore b/.gitignore index 9d2e425..dea9875 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ /bin/index.mjs /.vscode /output-es/ +/result diff --git a/CHANGELOG.d/feature_nix.md b/CHANGELOG.d/feature_nix.md new file mode 100644 index 0000000..892684e --- /dev/null +++ b/CHANGELOG.d/feature_nix.md @@ -0,0 +1,3 @@ +* Added nix flake +* Updated README with nix example +* Merged internal bin package with root to allow nix build diff --git a/README.md b/README.md index a7ce57e..ae72948 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A port of the work done in [`purescript/purescript#4392`](https://github.com/pur ![ci badge](https://github.com/purescript-contrib/uplog/actions/workflows/ci.yml/badge.svg) -## Install +## Getting started The first working release is `v0.5.1`. @@ -12,6 +12,10 @@ The first working release is `v0.5.1`. npm i chnglg ``` +```sh +nix run github:purescript-contrib/chnglg +``` + ## Why To make it easier to keep a good changelog that diff --git a/bin/index.dev.js b/bin/index.dev.js new file mode 100644 index 0000000..7e98576 --- /dev/null +++ b/bin/index.dev.js @@ -0,0 +1,2 @@ +#!/usr/bin/env node +import("../output/Main/index.js").then(m => m.main()) diff --git a/bin/spago.dhall b/bin/spago.dhall deleted file mode 100644 index 141c771..0000000 --- a/bin/spago.dhall +++ /dev/null @@ -1,38 +0,0 @@ -{ name = "my-project" -, dependencies = - [ "aff" - , "argonaut-codecs" - , "argparse-basic" - , "arrays" - , "bifunctors" - , "console" - , "control" - , "datetime" - , "effect" - , "either" - , "exceptions" - , "fetch" - , "filterable" - , "foldable-traversable" - , "foreign" - , "formatters" - , "integers" - , "maybe" - , "newtype" - , "node-buffer" - , "node-fs" - , "node-execa" - , "node-path" - , "node-process" - , "nullable" - , "parsing" - , "precise-datetime" - , "prelude" - , "strings" - , "transformers" - , "tuples" - , "versions" - ] -, packages = ../packages.dhall -, sources = [ "src/**/*.purs", "bin/**/*.purs" ] -} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..a3d533b --- /dev/null +++ b/flake.lock @@ -0,0 +1,181 @@ +{ + "nodes": { + "easy-ps": { + "inputs": { + "flake-utils": "flake-utils" + }, + "locked": { + "lastModified": 1696584097, + "narHash": "sha256-a9Hhqf/Fi0FkjRTcQr3pYDhrO9A9tdOkaeVgD23Cdrk=", + "owner": "justinwoo", + "repo": "easy-purescript-nix", + "rev": "d5fe5f4b210a0e4bac42ae0c159596a49c5eb016", + "type": "github" + }, + "original": { + "owner": "justinwoo", + "repo": "easy-purescript-nix", + "type": "github" + } + }, + "easy-purescript-nix": { + "flake": false, + "locked": { + "lastModified": 1670198178, + "narHash": "sha256-5KkyNpPakv4xIP2ba0S5GX+dcmd3AcO9kPhwa482BbA=", + "owner": "justinwoo", + "repo": "easy-purescript-nix", + "rev": "7a4cb3cd6ca53566ea1675692eab0aa13907ff09", + "type": "github" + }, + "original": { + "owner": "justinwoo", + "repo": "easy-purescript-nix", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "locked": { + "lastModified": 1618217525, + "narHash": "sha256-WGrhVczjXTiswQaoxQ+0PTfbLNeOQM6M36zvLn78AYg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c6169a2772643c4a93a0b5ac1c61e296cba68544", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1697730408, + "narHash": "sha256-Ww//zzukdTrwTrCUkaJA/NsaLEfUfQpWZXBdXBYfhak=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ff0a5a776b56e0ca32d47a4a47695452ec7f7d80", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1670507980, + "narHash": "sha256-riNZa0xzM1it3pzxciwALeMs+0CsBMWIW2FqulzK8vM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2787fc7d1e51404678614bf0fe92fc296746eec0", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "easy-ps": "easy-ps", + "nixpkgs": "nixpkgs", + "spago2nix": "spago2nix", + "utils": "utils" + } + }, + "spago2nix": { + "inputs": { + "easy-purescript-nix": "easy-purescript-nix", + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1696845391, + "narHash": "sha256-l/uUg0mxh9HVCPcciMlFt2xk6Ue/qOP9TSgLp9g4EPk=", + "owner": "justinwoo", + "repo": "spago2nix", + "rev": "f8712693764f318d61123e1c9eac6b37ef4ca270", + "type": "github" + }, + "original": { + "owner": "justinwoo", + "repo": "spago2nix", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "utils": { + "inputs": { + "flake-utils": "flake-utils_3" + }, + "locked": { + "lastModified": 1658606827, + "narHash": "sha256-3kSWTDpV4+uApt/Xd0kv2m7TR1Y6A7SgYUeX86/qYuU=", + "owner": "ursi", + "repo": "flake-utils", + "rev": "faec5f7431da6747a69957a9cd65e35b5173e10a", + "type": "github" + }, + "original": { + "owner": "ursi", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..9ced500 --- /dev/null +++ b/flake.nix @@ -0,0 +1,52 @@ +{ + nixConfig.sandbox = "relaxed"; + + description = "A maintainer and contributor-friendly tool for generating a human-readable CHANGELOG.md"; + + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + utils.url = "github:ursi/flake-utils"; + easy-ps.url = "github:justinwoo/easy-purescript-nix"; + spago2nix.url = "github:justinwoo/spago2nix"; + }; + + outputs = { self, utils, ... }@inputs: + utils.apply-systems + { inherit inputs; } + ({ system, pkgs, easy-ps, spago2nix, ... }: + let + chnglg = pkgs.stdenv.mkDerivation + { + name = "chnglg"; + src = pkgs.nix-gitignore.gitignoreSource [ ".git" ] ./.; + nativeBuildInputs = [ + easy-ps.purs + ] ++ ( + spago2nix.spago2nix_nativeBuildInputs { + srcs-dhall = [ + ./spago.dhall + ./packages.dhall + ]; + } + ); + unpackPhase = '' + cp -r $src/{src,bin} . + install-spago-style + ''; + buildInputs = with pkgs; [ nodejs ]; + buildPhase = '' + mkdir -p $out/bin + build-spago-style "./src/**/*.purs" "./bin/**/*.purs" + mv output $out/ + install $src/bin/index.dev.js $out/bin/$name + ''; + }; + in + { + packages = { + inherit chnglg; + default = self.packages.${system}.chnglg; + }; + }); +} diff --git a/spago.dhall b/spago.dhall index 7bc7eee..ef43c38 100644 --- a/spago.dhall +++ b/spago.dhall @@ -2,7 +2,10 @@ , dependencies = [ "aff" , "argonaut-codecs" + , "argparse-basic" , "arrays" + , "bifunctors" + , "console" , "control" , "datetime" , "effect" @@ -20,6 +23,7 @@ , "node-execa" , "node-fs" , "node-path" + , "node-process" , "nullable" , "parsing" , "precise-datetime" @@ -30,5 +34,5 @@ , "versions" ] , packages = ./packages.dhall -, sources = [ "src/**/*.purs" ] +, sources = [ "src/**/*.purs", "bin/**/*.purs" ] }