snix/users/Profpatsch/my-tools/default.nix
Profpatsch b21d538a27 feat(users/Profpatsch/my-tools): init
It’s kitchen-sink time!

Change-Id: Ieb4f9e642920c3e0619475095e19005bcaf558bc
Reviewed-on: https://cl.tvl.fyi/c/depot/+/13265
Reviewed-by: Profpatsch <mail@profpatsch.de>
Tested-by: BuildkiteCI
2025-03-15 16:32:01 +00:00

48 lines
1.5 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{ depot, pkgs, lib, ... }:
let
exes = [ "copy" ];
drv = pkgs.haskellPackages.mkDerivation {
pname = "my-tools";
version = "0.0.1-unreleased";
src = depot.users.Profpatsch.exactSource ./. [
./my-tools.cabal
./src/MyTools.hs
./exe/Copy.hs
];
isLibrary = false;
libraryHaskellDepends = [
depot.users.Profpatsch.my-prelude
pkgs.haskellPackages.optparse-simple
];
# I copied this from `__generateOptparseApplicativeCompletion` because I cant be bothered
# to figure out how the haskellPackages override callPackage bs really works.
postInstall = lib.concatMapStringsSep "\n"
(exeName: ''
bashCompDir="''${!outputBin}/share/bash-completion/completions"
zshCompDir="''${!outputBin}/share/zsh/vendor-completions"
fishCompDir="''${!outputBin}/share/fish/vendor_completions.d"
mkdir -p "$bashCompDir" "$zshCompDir" "$fishCompDir"
"''${!outputBin}/bin/${exeName}" --bash-completion-script "''${!outputBin}/bin/${exeName}" >"$bashCompDir/${exeName}"
"''${!outputBin}/bin/${exeName}" --zsh-completion-script "''${!outputBin}/bin/${exeName}" >"$zshCompDir/_${exeName}"
"''${!outputBin}/bin/${exeName}" --fish-completion-script "''${!outputBin}/bin/${exeName}" >"$fishCompDir/${exeName}.fish"
# Sanity check
grep -F ${exeName} <$bashCompDir/${exeName} >/dev/null || {
echo 'Could not find ${exeName} in completion script.'
exit 1
}
'')
exes;
license = lib.licenses.mit;
};
in
drv