Skip to content

Commit 8c5ab79

Browse files
committed
Expose executables from Cabal packages
1 parent ffa9947 commit 8c5ab79

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

flake.nix

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,37 @@
144144
});
145145
};
146146

147+
apps = let ## TODO: Move these functions to the lib.
148+
## Define a single entry for flake `apps` from the path in the Nix store
149+
## for a Cabal package and executable defined in that package.
150+
cabalApp = package: executable: {
151+
program = "${inputs.self.packages.${system}."${defaultCompiler}_${package}"}/bin/${executable}";
152+
type = "app";
153+
};
154+
155+
## Given a path in the Nix store for a Cabal package and a list of
156+
## executables defined in the Cabal package, creates an AttrSet of apps,
157+
## one per listed executable.
158+
##
159+
## TODO: Somehow extract this, if possible, from `callCabal2nix` result.
160+
cabalApps = package: executables:
161+
builtins.listToAttrs
162+
(map (exe: {name = exe; value = cabalApp package exe;}) executables);
163+
164+
## Given an AttrSet with the keys being paths in the Nix store for Cabal
165+
## packages and the values being lists of executables defined in that
166+
## Cabal package, creates an AttrSet of apps, one per listed executable.
167+
##
168+
## TODO: Somehow extract this, if possible, from `cabalProject2nix`
169+
## result.
170+
cabalProjectApps = pkgs.lib.concatMapAttrs cabalApps;
171+
in cabalProjectApps {
172+
concat-graphics = ["graphics-examples" "graphics-trace"];
173+
## TODO: concat-hardware currently doesn’t build
174+
# concat-hardware = ["hardware-examples" "hardware-trace"];
175+
concat-plugin = ["misc-examples" "misc-trace"];
176+
};
177+
147178
# Nix code formatter, https://github.com/kamadorueda/alejandra#readme
148179
formatter = pkgs.alejandra;
149180
});

0 commit comments

Comments
 (0)