-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add ‘custom-sdist’ script in nix-shell configuration that prepares ‘README.md’ file for being published on Hackage, calls ‘hpack’ to make sure Cabal config is up-to-date and then calls ‘cabal sdist’ - Update version to 1.0.0 in project Cabal config file - Add more metadata to Cabal config file - Remove -O2 flag from GHC options as recommended by Hackage’s RC uploader - Wrap ‘hpack’, ‘cabal’ and ‘stack’ Haskell packages to ‘justStaticExecutables’ in ‘shell.nix’ configuration
- Loading branch information
Showing
4 changed files
with
175 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
let sources = import nix/sources.nix; in | ||
# This module is intended to be called with ‘nixpkgs.callPackage’ | ||
{ callPackage | ||
, haskellPackages | ||
, haskell | ||
, coreutils | ||
, utillinux | ||
|
||
# Overridable dependencies | ||
, __nix-utils ? callPackage sources.nix-utils {} | ||
}: | ||
let | ||
inherit (__nix-utils) esc writeCheckedExecutable shellCheckers; | ||
inherit (haskell.lib) justStaticExecutables; | ||
hp = haskellPackages; | ||
|
||
# Shortcuts for executables that are already escaped for Bash | ||
c = builtins.mapAttrs (n: v: esc v) executables; | ||
|
||
assetsCommit = "be365c601ad94a108967701c70042b994d7dd3f3"; | ||
|
||
staticAssetUrl = filePath: | ||
"https://raw.githubusercontent.com/unclechu/place-cursor-at/" + | ||
"${assetsCommit}/${filePath}"; | ||
|
||
gitHubUrl = filePath: | ||
"https://github.com/unclechu/place-cursor-at/blob/" + | ||
"${assetsCommit}/${filePath}"; | ||
|
||
executables = | ||
builtins.foldl' | ||
(acc: x: acc // { ${x} = "${coreutils}/bin/${x}"; }) | ||
{ | ||
hpack = "${justStaticExecutables hp.hpack}/bin/hpack"; | ||
cabal = "${justStaticExecutables hp.cabal-install}/bin/cabal"; | ||
column = "${utillinux}/bin/column"; | ||
} | ||
[ "cp" "mv" "mktemp" "basename" ]; | ||
in | ||
|
||
# Script that prepares ‘README.md’ file for being published on Hackage. | ||
# It replaces relative links to some files in the repo to links to GitHub static | ||
# content links relative to specific commit (so that content stays the same). | ||
writeCheckedExecutable "custom-sdist" '' | ||
${ | ||
builtins.concatStringsSep "\n" | ||
(builtins.map shellCheckers.fileIsExecutable | ||
(builtins.attrValues executables)) | ||
} | ||
'' '' | ||
set -Eeuxo pipefail || exit | ||
# Generate fresh ‘*.cabal’ file from ‘package.yaml’ | ||
${c.hpack} | ||
TMP_FILE_PATH=$(${c.mktemp} -ut 'README.md.bakXXXXXX') | ||
README_BAK_FILE_NAME=$(${c.basename} -- "$TMP_FILE_PATH") | ||
# Make a backup of ‘README.md’ before patching it | ||
${c.cp} README.md -- "$README_BAK_FILE_NAME" | ||
readarray -t LINES < README.md | ||
# Restore original ‘README.md’ from backup file | ||
restore-readme-backup() { | ||
set -Eeuxo pipefail || exit | ||
${c.mv} -f -- "$README_BAK_FILE_NAME" README.md | ||
} | ||
# Encapsulate ‘trap’ | ||
( | ||
trap restore-readme-backup EXIT | ||
> README.md # Empty the file first | ||
table= | ||
# Encapsulate stdout redirect and ‘set’ | ||
( | ||
exec >> README.md # Redirect stdout to the README file | ||
set +x # Too much noise | ||
for line in "''${LINES[@]}"; do | ||
# End of table, fix the table for Hackage and print it | ||
if [[ -n $table ]] && ! [[ $line =~ ^\| ]]; then | ||
echo '```' | ||
table=''${table//'`'/} | ||
table=''${table//'*'/} | ||
table=$(${c.column} -t -o ' ' <<< "$table") | ||
printf '%s\n' "$table" | ||
echo '```' | ||
table= | ||
continue | ||
# Save table into a variable | ||
elif [[ $line =~ ^\| ]]; then | ||
table="$table$line"$'\n' | ||
continue | ||
fi | ||
line=''${line//'(artwork/screenshot.png)'/(${ | ||
esc (staticAssetUrl "artwork/screenshot.png") | ||
})} | ||
line=''${line//'(artwork/logo/horizontal.svg)'/(${ | ||
esc (staticAssetUrl "artwork/logo/horizontal.svg") | ||
})} | ||
line=''${line//'(artwork/logo/horizontal.png)'/(${ | ||
esc (staticAssetUrl "artwork/logo/horizontal.png") | ||
})} | ||
line=''${line//'(artwork/logo/vertical.svg)'/(${ | ||
esc (staticAssetUrl "artwork/logo/vertical.svg") | ||
})} | ||
line=''${line//'(artwork/logo/vertical.png)'/(${ | ||
esc (staticAssetUrl "artwork/logo/vertical.png") | ||
})} | ||
line=''${line//'(artwork/logo/icon.svg)'/(${ | ||
esc (staticAssetUrl "artwork/logo/icon.svg") | ||
})} | ||
line=''${line//'(artwork/logo/icon.png)'/(${ | ||
esc (staticAssetUrl "artwork/logo/icon.png") | ||
})} | ||
line=''${line//'(LICENSE)'/(${esc (staticAssetUrl "LICENSE")})} | ||
line=''${line//': shell.nix'/: ${esc (gitHubUrl "shell.nix")}} | ||
line=''${line//': artwork/logo'/: ${esc (gitHubUrl "artwork/logo")}} | ||
printf '%s\n' "$line" | ||
done | ||
) | ||
${c.cabal} sdist | ||
) | ||
'' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,24 @@ | ||
name: place-cursor-at | ||
synopsis: A utility for X11 that moves the mouse cursor using the keyboard | ||
version: 1.0.0 | ||
license: GPL-3 | ||
license-file: LICENSE | ||
author: Viacheslav Lotsmanov | ||
maintainer: <[email protected]> | ||
category: System | ||
copyright: Copyright © 2017–2021 Viacheslav Lotsmanov | ||
maintainer: Viacheslav Lotsmanov <[email protected]> | ||
category: Utility, GUI, Desktop, Desktop Environment, X11 | ||
github: unclechu/place-cursor-at | ||
|
||
extra-source-files: README.md | ||
|
||
tested-with: GHC ==8.10.4 || ==8.8.4 || ==8.6.4 | ||
|
||
dependencies: | ||
- base >= 4.12 && < 5 | ||
- base-unicode-symbols ^>= 0.2 | ||
- X11 >= 1.9 && < 2 | ||
|
||
ghc-options: | ||
- -O2 | ||
- -threaded | ||
|
||
extra-libraries: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,36 @@ | ||
cabal-version: 1.12 | ||
|
||
-- This file has been generated from package.yaml by hpack version 0.33.0. | ||
-- This file has been generated from package.yaml by hpack version 0.34.2. | ||
-- | ||
-- see: https://github.com/sol/hpack | ||
-- | ||
-- hash: c1b0beb883ff043c4ac58f466cef84ebb5ce6669706a4a0a44334c7bca6acab4 | ||
-- hash: 66d39f7b6b91273a09289c622d5c81b8bb6f010ee69d032997ed77412a1f96f5 | ||
|
||
name: place-cursor-at | ||
version: 0.0.0 | ||
category: System | ||
version: 1.0.0 | ||
synopsis: A utility for X11 that moves the mouse cursor using the keyboard | ||
category: Utility, GUI, Desktop, Desktop Environment, X11 | ||
homepage: https://github.com/unclechu/place-cursor-at#readme | ||
bug-reports: https://github.com/unclechu/place-cursor-at/issues | ||
author: Viacheslav Lotsmanov | ||
maintainer: <[email protected]> | ||
maintainer: Viacheslav Lotsmanov <[email protected]> | ||
copyright: Copyright © 2017–2021 Viacheslav Lotsmanov | ||
license: GPL-3 | ||
license-file: LICENSE | ||
tested-with: GHC ==8.10.4 || ==8.8.4 || ==8.6.4 | ||
build-type: Simple | ||
extra-source-files: | ||
README.md | ||
|
||
source-repository head | ||
type: git | ||
location: https://github.com/unclechu/place-cursor-at | ||
|
||
executable place-cursor-at | ||
main-is: place-cursor-at.hs | ||
hs-source-dirs: | ||
src | ||
ghc-options: -O2 -threaded | ||
ghc-options: -threaded | ||
extra-libraries: | ||
Xinerama | ||
build-depends: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters