mirror of
https://github.com/nix-community/comma.git
synced 2026-01-12 17:28:26 +01:00
134 lines
3.6 KiB
Nix
134 lines
3.6 KiB
Nix
{
|
|
description = "runs programs without installing them";
|
|
|
|
inputs = {
|
|
naersk = {
|
|
url = "github:nix-community/naersk/master";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
utils.url = "github:numtide/flake-utils";
|
|
flake-compat = {
|
|
url = "github:edolstra/flake-compat";
|
|
flake = false;
|
|
};
|
|
};
|
|
|
|
outputs =
|
|
{
|
|
self,
|
|
nixpkgs,
|
|
utils,
|
|
naersk,
|
|
flake-compat,
|
|
}:
|
|
let
|
|
inherit (nixpkgs) lib;
|
|
commaLambda =
|
|
pkgs:
|
|
pkgs.callPackage (
|
|
{
|
|
stdenv,
|
|
callPackage,
|
|
nix,
|
|
fzy,
|
|
nix-index-unwrapped,
|
|
rustPackages,
|
|
installShellFiles,
|
|
buildPackages,
|
|
}:
|
|
let
|
|
naersk-lib = callPackage naersk { };
|
|
in
|
|
naersk-lib.buildPackage {
|
|
pname = "comma";
|
|
src = self;
|
|
|
|
nativeBuildInputs = [
|
|
installShellFiles
|
|
];
|
|
overrideMain = _: {
|
|
postPatch = ''
|
|
substituteInPlace ./src/main.rs \
|
|
--replace-fail '"nix-locate"' '"${lib.getExe' nix-index-unwrapped "nix-locate"}"' \
|
|
--replace-fail '"nix"' '"${lib.getExe nix}"' \
|
|
--replace-fail '"nix-env"' '"${lib.getExe' nix "nix-env"}"' \
|
|
--replace-fail '"fzy"' '"${lib.getExe fzy}"'
|
|
'';
|
|
|
|
postInstall = ''
|
|
ln -s $out/bin/comma $out/bin/,
|
|
|
|
mkdir -p $out/share/comma
|
|
|
|
cp $src/etc/command-not-found.sh $out/share/comma
|
|
cp $src/etc/command-not-found.nu $out/share/comma
|
|
cp $src/etc/command-not-found.fish $out/share/comma
|
|
|
|
patchShebangs $out/share/comma/command-not-found.sh
|
|
substituteInPlace \
|
|
"$out/share/comma/command-not-found.sh" \
|
|
"$out/share/comma/command-not-found.nu" \
|
|
"$out/share/comma/command-not-found.fish" \
|
|
--replace-fail "comma --ask" "$out/bin/comma --ask"
|
|
|
|
''
|
|
+ lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) ''
|
|
${stdenv.hostPlatform.emulator buildPackages} "$out/bin/comma" --mangen > comma.1
|
|
installManPage comma.1
|
|
'';
|
|
};
|
|
checkInputs = [ rustPackages.clippy ];
|
|
doCheck = true;
|
|
cargoTestCommands =
|
|
x:
|
|
x
|
|
++ [
|
|
''
|
|
cargo clippy --all --all-features --tests -- \
|
|
-D warnings || true''
|
|
];
|
|
}
|
|
) { };
|
|
in
|
|
utils.lib.eachDefaultSystem (
|
|
system:
|
|
let
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
in
|
|
{
|
|
packages = {
|
|
default = self.packages."${system}".comma;
|
|
comma = commaLambda pkgs;
|
|
};
|
|
|
|
apps.default = utils.lib.mkApp {
|
|
drv = self.packages."${system}".default;
|
|
};
|
|
|
|
devShells.default =
|
|
with pkgs;
|
|
mkShell {
|
|
nativeBuildInputs = [
|
|
cargo
|
|
cargo-edit
|
|
nix-index
|
|
rustc
|
|
rustfmt
|
|
rustPackages.clippy
|
|
fzy
|
|
];
|
|
RUST_SRC_PATH = rustPlatform.rustLibSrc;
|
|
};
|
|
|
|
formatter = pkgs.nixfmt-tree;
|
|
}
|
|
)
|
|
// {
|
|
overlays.default = (
|
|
final: prev: {
|
|
comma = commaLambda prev;
|
|
}
|
|
);
|
|
};
|
|
}
|