File tree Expand file tree Collapse file tree 2 files changed +29
-4
lines changed Expand file tree Collapse file tree 2 files changed +29
-4
lines changed Original file line number Diff line number Diff line change 208208 } ;
209209 } ;
210210 } ;
211+ cabal2nix = mkOption {
212+ description = "cabal2nix hook" ;
213+ type = types . submodule {
214+ imports = [ hookModule ] ;
215+ options . settings = {
216+ outputFilename =
217+ mkOption {
218+ type = types . str ;
219+ description = "The name of the output file generated after running `cabal2nix`." ;
220+ default = "default.nix" ;
221+ } ;
222+ } ;
223+ } ;
224+ } ;
211225 clippy = mkOption {
212226 description = "clippy hook" ;
213227 type = types . submodule
20342048 cabal2nix =
20352049 {
20362050 name = "cabal2nix" ;
2037- description = "Run `cabal2nix` on all `*.cabal` files to generate corresponding `default .nix` files" ;
2051+ description = "Run `cabal2nix` on all `*.cabal` files to generate corresponding `.nix` files" ;
20382052 package = tools . cabal2nix-dir ;
2039- entry = "${ hooks . cabal2nix . package } /bin/cabal2nix-dir" ;
2053+ entry = "${ hooks . cabal2nix . package } /bin/cabal2nix-dir --outputFileName= ${ hooks . cabal2nix . settings . outputFilename } " ;
20402054 files = "\\ .cabal$" ;
20412055 after = [ "hpack" ] ;
20422056 } ;
Original file line number Diff line number Diff line change 22
33writeScriptBin "cabal2nix-dir" ''#!/usr/bin/env bash
44 projectdir="$(pwd)"
5- for cabalFile in "'' $@"; do
5+ outputFileName=""
6+ cabalFiles=()
7+
8+ for arg in "$@"; do
9+ if [[ "$arg" == --outputFileName=* ]]; then
10+ outputFileName="'' ${arg#--outputFileName=}"
11+ else
12+ cabalFiles+=("$arg")
13+ fi
14+ done
15+
16+ for cabalFile in "'' ${cabalFiles[@]}"; do
617 echo "$cabalFile"
718 dir="$(dirname $cabalFile)"
819 cd "$projectdir/$dir"
9- ${ cabal2nix } /bin/cabal2nix --no-hpack . > default.nix
20+ ${ cabal2nix } /bin/cabal2nix --no-hpack . > "$outputFileName"
1021 done
1122''
You can’t perform that action at this time.
0 commit comments