Skip to content

[WIP] Lorri #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions nix/packages.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ hlint, shellcheck, ormolu, hindent, cabal-fmt, canonix, elmPackages, niv
, gitAndTools, runCommand, writeText, writeScript, git, nixpkgs-fmt, nixfmt
, callPackage
, callPackage, lib
}:

let
Expand All @@ -14,6 +14,6 @@ in
tools // rec {
inherit niv;
inherit (gitAndTools) pre-commit;
run = import ./run.nix { inherit tools pre-commit runCommand writeText writeScript git; };
run = import ./run.nix { inherit tools pre-commit runCommand writeText writeScript git lib; };
pre-commit-check = run { src = ../.; };
}
34 changes: 28 additions & 6 deletions nix/run.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ tools, pre-commit, git, runCommand, writeText, writeScript }:
{ tools, pre-commit, git, runCommand, writeText, writeScript, lib }:

{ src
, hooks ? null
Expand Down Expand Up @@ -103,14 +103,36 @@ let
touch $out
[ $? -eq 0 ] && exit $exitcode
'';

srcStr = toString ( src.origSrc or src );
in
run // {
shellHook = ''
[ -L .pre-commit-hooks ] && unlink .pre-commit-hooks
ln -s ${hooks} .pre-commit-hooks
export PATH=$PATH:${pre-commit}/bin
pre-commit install
# this is needed as the hook repo configuration is cached
pre-commit clean
if ! type -t git >/dev/null; then
# This happens in pure shells, including lorri
echo 1>&2 "WARNING: nix-pre-commit-hooks: git command not found; skipping installation."
else
(
# We use srcStr to protect against installing pre-commit hooks
# in the wrong places such as for example ./. when invoking
# nix-shell ../../other-project/shell.nix
cd ${lib.escapeShellArg srcStr} && {
# Avoid filesystem churn. We may be watched!
# This prevents lorri from looping after every interactive shell command.
if readlink .pre-commit-hooks >/dev/null \
&& [[ $(readlink .pre-commit-hooks) == ${hooks} ]]; then
echo 1>&2 "nix-pre-commit-hooks: hooks up to date"
else
echo 1>&2 "nix-pre-commit-hooks: updating" ${lib.escapeShellArg srcStr}
[ -L .pre-commit-hooks ] && unlink .pre-commit-hooks
ln -s ${hooks} .pre-commit-hooks
pre-commit install
# this is needed as the hook repo configuration is cached
pre-commit clean
fi
}
)
fi
'';
}
139 changes: 70 additions & 69 deletions nix/sources.json
Original file line number Diff line number Diff line change
@@ -1,51 +1,63 @@
{
"haskell.nix": {
"homepage": "https://input-output-hk.github.io/haskell.nix",
"url": "https://github.com/input-output-hk/haskell.nix/archive/2c161d73b51f4c26adb95bd58a63e6e463bcba1c.tar.gz",
"owner": "input-output-hk",
"cabal-fmt": {
"branch": "master",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz",
"repo": "haskell.nix",
"type": "tarball",
"sha256": "18apq45lfnn1sgsccn0vi0dnq29zzzvi3naakd8xzdsfn0xp61g9",
"description": "Alternative Haskell Infrastructure for Nixpkgs",
"rev": "2c161d73b51f4c26adb95bd58a63e6e463bcba1c"
},
"nixpkgs": {
"homepage": "https://github.com/NixOS/nixpkgs",
"url": "https://github.com/NixOS/nixpkgs-channels/archive/8f84220eb292beae78b10e9e53a22d14221e3cbe.tar.gz",
"owner": "NixOS",
"branch": "nixos-unstable",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz",
"repo": "nixpkgs-channels",
"description": "An experiment of formatting .cabal files",
"homepage": null,
"owner": "phadej",
"repo": "cabal-fmt",
"rev": "177b4ca8a446682ee91c536a5492157c1e232864",
"sha256": "1yir989pl2aizlv9wsf5amrixdayf1rc97n8jwfy0f63szrw1rf9",
"type": "tarball",
"sha256": "1aq62igjnbv7hw94m8n9akj3kscfrfvb2csb26zzv2lvs5aamiam",
"description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
"rev": "8f84220eb292beae78b10e9e53a22d14221e3cbe"
"url": "https://github.com/phadej/cabal-fmt/archive/177b4ca8a446682ee91c536a5492157c1e232864.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"canonix": {
"branch": "master",
"description": "Experiment in Nix formatting",
"homepage": null,
"url": "https://github.com/hercules-ci/canonix/archive/530a869d73e1ee1142d0227cae62956ebd8b4cda.tar.gz",
"owner": "hercules-ci",
"branch": "master",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz",
"repo": "canonix",
"rev": "a3369542aef56366d3432e01e3e73374a310ca4a",
"sha256": "0bw17sahfn5vqcygvmabafq8i0qszjh9jxl2524k4b3mh12apivm",
"type": "tarball",
"sha256": "01yj7xvh02i2vh1mddb18d1pfnnzkk2si6mwhrmgb6nwc9z7f14f",
"description": "Experiment in Nix formatting",
"rev": "530a869d73e1ee1142d0227cae62956ebd8b4cda"
"url": "https://github.com/hercules-ci/canonix/archive/a3369542aef56366d3432e01e3e73374a310ca4a.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"cabal-fmt": {
"haskell.nix": {
"branch": "master",
"description": "Alternative Haskell Infrastructure for Nixpkgs",
"homepage": "https://input-output-hk.github.io/haskell.nix",
"owner": "input-output-hk",
"repo": "haskell.nix",
"rev": "2c161d73b51f4c26adb95bd58a63e6e463bcba1c",
"sha256": "18apq45lfnn1sgsccn0vi0dnq29zzzvi3naakd8xzdsfn0xp61g9",
"type": "tarball",
"url": "https://github.com/input-output-hk/haskell.nix/archive/2c161d73b51f4c26adb95bd58a63e6e463bcba1c.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"hindent": {
"branch": "master",
"description": "Haskell pretty printer",
"homepage": null,
"url": "https://github.com/phadej/cabal-fmt/archive/177b4ca8a446682ee91c536a5492157c1e232864.tar.gz",
"owner": "phadej",
"owner": "chrisdone",
"repo": "hindent",
"rev": "1583be4a8a01b765841f7306284528ae713abb7b",
"sha256": "sha256:1l8v3vq3yw7zr1yxyscfw8lggcf0klnyszhv18505c6myybp2dkp",
"type": "tarball",
"url": "https://github.com/chrisdone/hindent/archive/1583be4a8a01b765841f7306284528ae713abb7b.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"niv": {
"branch": "master",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz",
"repo": "cabal-fmt",
"description": "Easy dependency management for Nix projects",
"homepage": "https://github.com/nmattia/niv",
"owner": "nmattia",
"repo": "niv",
"rev": "5e9671a9a87c240b1c6ce981d04ad23ba4291451",
"sha256": "08j7msxkv452pyxnh0sgn6h9930i5mk9mszba49bj5401gzmfb8a",
"type": "tarball",
"sha256": "1yir989pl2aizlv9wsf5amrixdayf1rc97n8jwfy0f63szrw1rf9",
"description": "An experiment of formatting .cabal files",
"rev": "177b4ca8a446682ee91c536a5492157c1e232864"
"url": "https://github.com/nmattia/niv/archive/5e9671a9a87c240b1c6ce981d04ad23ba4291451.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixfmt": {
"branch": "master",
Expand All @@ -59,51 +71,40 @@
"url": "https://github.com/serokell/nixfmt/archive/9b178986e339f260d0c335aef6f4950327af85dc.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
"branch": "nixos-unstable",
"description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
"homepage": "https://github.com/NixOS/nixpkgs",
"owner": "NixOS",
"repo": "nixpkgs-channels",
"rev": "8f84220eb292beae78b10e9e53a22d14221e3cbe",
"sha256": "1aq62igjnbv7hw94m8n9akj3kscfrfvb2csb26zzv2lvs5aamiam",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs-channels/archive/8f84220eb292beae78b10e9e53a22d14221e3cbe.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs-fmt": {
"branch": "master",
"description": "Nix code formatter for nixpkgs [maintainer=@zimbatm]",
"homepage": "https://nix-community.github.io/nixpkgs-fmt/",
"url": "https://github.com/nix-community/nixpkgs-fmt/archive/b812c05cc22cd619cd771a0a5ba0bcee3c472c02.tar.gz",
"owner": "nix-community",
"branch": "master",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz",
"repo": "nixpkgs-fmt",
"type": "tarball",
"rev": "b812c05cc22cd619cd771a0a5ba0bcee3c472c02",
"sha256": "0p34gbrlyi4bcz332iwasdw4621qqmx1hr9had13p4drjmnfhypz",
"description": "Nix code formatter for nixpkgs [maintainer=@zimbatm]",
"rev": "b812c05cc22cd619cd771a0a5ba0bcee3c472c02"
"type": "tarball",
"url": "https://github.com/nix-community/nixpkgs-fmt/archive/b812c05cc22cd619cd771a0a5ba0bcee3c472c02.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"ormolu": {
"branch": "master",
"description": "A formatter for Haskell source code",
"homepage": null,
"url": "https://github.com/tweag/ormolu/archive/a7076c0f83e5c06ea9067b71171859fa2ba8afd9.tar.gz",
"owner": "tweag",
"branch": "master",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz",
"repo": "ormolu",
"type": "tarball",
"rev": "a7076c0f83e5c06ea9067b71171859fa2ba8afd9",
"sha256": "1p4n2ja4ciw3qfskn65ggpy37mvgf2sslxqmqn8s8jjarnqcyfny",
"description": "A formatter for Haskell source code",
"rev": "a7076c0f83e5c06ea9067b71171859fa2ba8afd9"
},
"hindent": {
"homepage": null,
"url": "https://github.com/chrisdone/hindent/archive/1583be4a8a01b765841f7306284528ae713abb7b.tar.gz",
"owner": "chrisdone",
"branch": "master",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz",
"repo": "hindent",
"type": "tarball",
"sha256": "sha256:1l8v3vq3yw7zr1yxyscfw8lggcf0klnyszhv18505c6myybp2dkp",
"description": "Haskell pretty printer",
"rev": "1583be4a8a01b765841f7306284528ae713abb7b"
},
"niv": {
"homepage": "https://github.com/nmattia/niv",
"url": "https://github.com/nmattia/niv/archive/8b7b70465c130d8d7a98fba1396ad1481daee518.tar.gz",
"owner": "nmattia",
"branch": "master",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz",
"repo": "niv",
"sha256": "0fgdrxn2vzpnzr6pxaiyn5zzbd812c6f7xjjhfir0kpzamjnxwwl",
"description": "Easy dependency management for Nix projects",
"rev": "8b7b70465c130d8d7a98fba1396ad1481daee518"
"url": "https://github.com/tweag/ormolu/archive/a7076c0f83e5c06ea9067b71171859fa2ba8afd9.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}