mirror of
https://github.com/nmattia/snack.git
synced 2024-10-26 12:38:49 +03:00
Merge pull request #104 from nmattia/nm-exe-name
Force and infer executable names
This commit is contained in:
commit
443bb89c5b
@ -27,15 +27,19 @@ rec {
|
||||
buildLibrary = ghcWith: modSpecs:
|
||||
buildModulesRec ghcWith {} modSpecs;
|
||||
|
||||
linkMainModule = ghcWith: mod: # main module
|
||||
linkMainModule =
|
||||
{ ghcWith
|
||||
, moduleSpec # The module to build
|
||||
, name # The name to give the executable
|
||||
}:
|
||||
let
|
||||
objAttrs = buildMain ghcWith mod;
|
||||
objAttrs = buildMain ghcWith moduleSpec;
|
||||
objList = lib.attrsets.mapAttrsToList (x: y: y) objAttrs;
|
||||
deps = allTransitiveDeps [mod];
|
||||
deps = allTransitiveDeps [moduleSpec];
|
||||
ghc = ghcWith deps;
|
||||
ghcOptsArgs = lib.strings.escapeShellArgs mod.moduleGhcOpts;
|
||||
ghcOptsArgs = lib.strings.escapeShellArgs moduleSpec.moduleGhcOpts;
|
||||
packageList = map (p: "-package ${p}") deps;
|
||||
relExePath = "bin/${lib.strings.toLower mod.moduleName}";
|
||||
relExePath = "bin/${name}";
|
||||
drv = runCommand "linker" {}
|
||||
''
|
||||
mkdir -p $out/bin
|
||||
|
@ -41,7 +41,10 @@ let
|
||||
buildLibrary ghcWith (libraryModSpecs pkgSpec);
|
||||
|
||||
buildAsExecutable = pkgSpec:
|
||||
let drv = linkMainModule ghcWith (executableMainModSpec pkgSpec);
|
||||
let
|
||||
moduleSpec = executableMainModSpec pkgSpec;
|
||||
name = pkgSpec.packageName;
|
||||
drv = linkMainModule { inherit moduleSpec name ghcWith; };
|
||||
in
|
||||
{ out = drv.out;
|
||||
exe_path = "${drv.out}/${drv.relExePath}";
|
||||
|
@ -18,8 +18,16 @@ rec {
|
||||
, extra-directories ? []
|
||||
, packages ? []
|
||||
}:
|
||||
with
|
||||
rec {
|
||||
isExe = ! builtins.isNull main;
|
||||
pName =
|
||||
if isExe && builtins.isNull name
|
||||
then lib.strings.toLower main
|
||||
else name;
|
||||
};
|
||||
{ packageIsExe = ! builtins.isNull main;
|
||||
packageName = name;
|
||||
packageName = pName;
|
||||
packageMain = main;
|
||||
packageSourceDirs =
|
||||
if builtins.isList src
|
||||
|
Loading…
Reference in New Issue
Block a user