Skip to content

Commit

Permalink
Distribution.Nixpkgs.Haskell.FromCabal: emit mainProgram
Browse files Browse the repository at this point in the history
If a there is a single executable, it is obviously the mainProgram.
We'll see a lot of example binaries this way, of course, but these being
built is not exactly a new problem.

Fixes: NixOS#541
  • Loading branch information
sternenseemann committed May 28, 2022
1 parent 755b7dd commit 7008e8b
Show file tree
Hide file tree
Showing 43 changed files with 51 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Distribution/Nixpkgs/Haskell/FromCabal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ fromPackageDescription haskellResolver nixpkgsResolver missingDeps flags Package
& Nix.platforms .~ Nothing
& Nix.badPlatforms .~ Nothing
& Nix.hydraPlatforms .~ (if isFreeLicense nixLicense then Nothing else Just Set.empty)
& Nix.mainProgram .~ nixMainProgram
& Nix.maintainers .~ mempty
& Nix.broken .~ not (null missingDeps)
)
Expand All @@ -144,6 +145,14 @@ fromPackageDescription haskellResolver nixpkgsResolver missingDeps flags Package
nixLicense :: Nix.License
nixLicense = either fromSPDXLicense fromCabalLicense licenseRaw

-- return the name of the executable if there is exactly one. If more,
-- it is hard to decide automatically which should be the default/main one.
nixMainProgram :: Maybe String
nixMainProgram =
case executables of
[mainProgram] -> Just $ unUnqualComponentName $ exeName mainProgram
_ -> Nothing

resolveInHackage :: Identifier -> Binding
resolveInHackage i | (i^.ident) `elem` [ unPackageName n | (Dependency n _ _) <- missingDeps ] = bindNull i
| otherwise = binding # (i, path # ["self",i]) -- TODO: "self" shouldn't be hardcoded.
Expand Down
1 change: 1 addition & 0 deletions test/golden-test-cases/HTF.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ mkDerivation {
homepage = "https://github.com/skogsbaer/HTF/";
description = "The Haskell Test Framework";
license = "LGPL";
mainProgram = "htfpp";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/ReadArgs.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ mkDerivation {
homepage = "http://github.com/rampion/ReadArgs";
description = "Simple command line argument parsing";
license = lib.licenses.bsd3;
mainProgram = "ReadArgsEx";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/aeson-pretty.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ mkDerivation {
homepage = "http://github.com/informatikr/aeson-pretty";
description = "JSON pretty-printing library and command-line tool";
license = lib.licenses.bsd3;
mainProgram = "aeson-pretty";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/apply-refact.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ mkDerivation {
];
description = "Perform refactorings specified by the refact library";
license = lib.licenses.bsd3;
mainProgram = "refactor";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/benchpress.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ mkDerivation {
homepage = "https://github.com/WillSewell/benchpress";
description = "Micro-benchmarking with detailed statistics";
license = lib.licenses.bsd3;
mainProgram = "example";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/blosum.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ mkDerivation {
homepage = "http://github.com/GregorySchwartz/blosum#readme";
description = "BLOSUM generator";
license = lib.licenses.gpl2Only;
mainProgram = "blosum";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/brittany.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ mkDerivation {
homepage = "https://github.com/lspitzner/brittany/";
description = "Haskell source code formatter";
license = lib.licenses.agpl3Only;
mainProgram = "brittany";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/colorize-haskell.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ mkDerivation {
homepage = "http://github.com/yav/colorize-haskell";
description = "Highligt Haskell source";
license = lib.licenses.bsd3;
mainProgram = "hscolor";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/cpu.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ mkDerivation {
homepage = "http://github.com/vincenthz/hs-cpu";
description = "Cpu information and properties helpers";
license = lib.licenses.bsd3;
mainProgram = "cpuid";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/criterion.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ mkDerivation {
homepage = "http://www.serpentine.com/criterion";
description = "Robust, reliable performance measurement and analysis";
license = lib.licenses.bsd3;
mainProgram = "criterion-report";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/data-msgpack.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ mkDerivation {
homepage = "http://msgpack.org/";
description = "A Haskell implementation of MessagePack";
license = lib.licenses.bsd3;
mainProgram = "msgpack-parser";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/dhall-bash.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ mkDerivation {
];
description = "Compile Dhall to Bash";
license = lib.licenses.bsd3;
mainProgram = "dhall-to-bash";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/dotenv.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ mkDerivation {
homepage = "https://github.com/stackbuilders/dotenv-hs";
description = "Loads environment variables from dotenv files";
license = lib.licenses.mit;
mainProgram = "dotenv";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/file-modules.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ mkDerivation {
homepage = "https://github.com/yamadapc/stack-run-auto";
description = "Takes a Haskell source-code file and outputs its modules";
license = lib.licenses.mit;
mainProgram = "file-modules";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/ghcid.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ mkDerivation {
homepage = "https://github.com/ndmitchell/ghcid#readme";
description = "GHCi based bare bones IDE";
license = lib.licenses.bsd3;
mainProgram = "ghcid";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/giphy-api.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ mkDerivation {
homepage = "http://github.com/passy/giphy-api#readme";
description = "Giphy HTTP API wrapper and CLI search tool";
license = lib.licenses.bsd3;
mainProgram = "giphy-search";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/hakyll.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ mkDerivation {
homepage = "http://jaspervdj.be/hakyll";
description = "A static website compiler library";
license = lib.licenses.bsd3;
mainProgram = "hakyll-init";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/happy.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ mkDerivation {
homepage = "https://www.haskell.org/happy/";
description = "Happy is a parser generator for Haskell";
license = lib.licenses.bsd2;
mainProgram = "happy";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/haskell-tools-debug.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ mkDerivation {
homepage = "https://github.com/haskell-tools/haskell-tools";
description = "Debugging Tools for Haskell-tools";
license = lib.licenses.bsd3;
mainProgram = "ht-debug";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/highlighting-kate.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ mkDerivation {
homepage = "http://github.com/jgm/highlighting-kate";
description = "Syntax highlighting";
license = "GPL";
mainProgram = "highlighting-kate";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/hit.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ mkDerivation {
homepage = "http://github.com/vincenthz/hit";
description = "Git operations in haskell";
license = lib.licenses.bsd3;
mainProgram = "Hit";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/hoogle.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ mkDerivation {
homepage = "http://hoogle.haskell.org/";
description = "Haskell API Search";
license = lib.licenses.bsd3;
mainProgram = "hoogle";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/hsinstall.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ mkDerivation {
executableHaskellDepends = [ base directory filepath ];
description = "Install Haskell software";
license = lib.licenses.isc;
mainProgram = "an-app";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/hsyslog.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ mkDerivation {
homepage = "http://github.com/peti/hsyslog";
description = "FFI interface to syslog(3) from POSIX.1-2001";
license = lib.licenses.bsd3;
mainProgram = "hsyslog-example";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/intero.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ mkDerivation {
homepage = "https://github.com/commercialhaskell/intero";
description = "Complete interactive development program for Haskell";
license = lib.licenses.bsd3;
mainProgram = "intero";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/jose.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ mkDerivation {
homepage = "https://github.com/frasertweedale/hs-jose";
description = "Javascript Object Signing and Encryption and JSON Web Token library";
license = lib.licenses.asl20;
mainProgram = "example";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/katydid.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ mkDerivation {
homepage = "https://github.com/katydid/katydid-haskell";
description = "A haskell implementation of Katydid";
license = lib.licenses.bsd3;
mainProgram = "katydid-exe";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/lazy-csv.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ mkDerivation {
homepage = "http://code.haskell.org/lazy-csv";
description = "Efficient lazy parsers for CSV (comma-separated values)";
license = lib.licenses.bsd3;
mainProgram = "csvSelect";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/mole.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ mkDerivation {
];
description = "A glorified string replacement tool";
license = lib.licenses.mit;
mainProgram = "mole";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/nvim-hs.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ mkDerivation {
homepage = "https://github.com/neovimhaskell/nvim-hs";
description = "Haskell plugin backend for neovim";
license = lib.licenses.asl20;
mainProgram = "nvim-hs";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/pager.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ mkDerivation {
homepage = "https://github.com/pharpend/pager";
description = "Open up a pager, like 'less' or 'more'";
license = lib.licenses.bsd2;
mainProgram = "hs-pager-test-pager";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/pathtype.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ mkDerivation {
homepage = "http://hub.darcs.net/thielema/pathtype/";
description = "Type-safe replacement for System.FilePath etc";
license = lib.licenses.bsd3;
mainProgram = "create-pathtype-test";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/persistent-mysql-haskell.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ mkDerivation {
homepage = "http://www.yesodweb.com/book/persistent";
description = "A pure haskell backend for the persistent library using MySQL database server";
license = lib.licenses.mit;
mainProgram = "persistent-mysql-haskell-example";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/profiterole.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ mkDerivation {
homepage = "https://github.com/ndmitchell/profiterole#readme";
description = "Restructure GHC profile reports";
license = lib.licenses.bsd3;
mainProgram = "profiterole";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/rasterific-svg.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ mkDerivation {
];
description = "SVG renderer based on Rasterific";
license = lib.licenses.bsd3;
mainProgram = "svgrender";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/soxlib.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ mkDerivation {
homepage = "http://www.haskell.org/haskellwiki/Sox";
description = "Write, read, convert audio signals using libsox";
license = lib.licenses.bsd3;
mainProgram = "soxlib-demo";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/taggy.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ mkDerivation {
homepage = "http://github.com/alpmestan/taggy";
description = "Efficient and simple HTML/XML parsing library";
license = lib.licenses.bsd3;
mainProgram = "taggy";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/terminal-progress-bar.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ mkDerivation {
homepage = "https://github.com/roelvandijk/terminal-progress-bar";
description = "A simple progress bar in the terminal";
license = lib.licenses.bsd3;
mainProgram = "example";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/texmath.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ mkDerivation {
homepage = "http://github.com/jgm/texmath";
description = "Conversion between formats used to represent mathematics";
license = "GPL";
mainProgram = "texmath";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/turtle-options.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ mkDerivation {
homepage = "https://github.com/elaye/turtle-options#readme";
description = "Collection of command line options and parsers for these options";
license = lib.licenses.bsd3;
mainProgram = "example";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/unlit.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ mkDerivation {
executableHaskellDepends = [ base directory text ];
description = "Tool to convert literate code between styles or to code";
license = lib.licenses.bsd3;
mainProgram = "unlit";
}
1 change: 1 addition & 0 deletions test/golden-test-cases/wai-middleware-auth.nix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ mkDerivation {
];
description = "Authentication middleware that secures WAI application";
license = lib.licenses.mit;
mainProgram = "wai-auth";
}

0 comments on commit 7008e8b

Please sign in to comment.