q.sh/flake.nix

82 lines
1.9 KiB
Nix

{
description = "Nix q.sh dev environment";
# Flake inputs
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
};
# Flake outputs
outputs = { self, nixpkgs }:
let
# Systems supported
allSystems = [
"x86_64-linux" # 64-bit Intel/AMD Linux
"aarch64-linux" # 64-bit ARM Linux
"x86_64-darwin" # 64-bit Intel macOS
"aarch64-darwin" # 64-bit ARM macOS
];
# Helper to provide system-specific attributes
forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
pkgs = import nixpkgs { inherit system; };
});
make_package = pkgs: pkgs.stdenv.mkDerivation rec {
name = "q-sh";
src = self;
installPhase = ''
mkdir -p $out/bin
cp q $out/bin
cp q-* $out/bin
echo "OUT " $out
'';
dontStrip = true;
nativeBuildInputs = [pkgs.makeWrapper];
wrapperPath = pkgs.lib.makeBinPath ( with pkgs; [
fzf
findutils
gnused
gawk
bc
pass
coreutils
wl-clipboard
xdg-utils
]
);
postFixup = ''
substituteInPlace $out/bin/q \
--replace 'ENV_q="''${0##*/}"' "ENV_q=$out/bin/q"
# Ensure all dependencies are in PATH
for fn in $out/bin/q*; do
echo "wrapping $fn"
wrapProgram $fn \
--prefix PATH : "${wrapperPath}"
done
'';
};
in
{
devShells = forAllSystems ({ pkgs }: {
default = pkgs.mkShell {
packages = with pkgs; [
fzf
pass
bc
wl-clipboard
xdg-utils
];
};
});
packages = forAllSystems({ pkgs }: {"q-sh" = make_package pkgs;});
overlays.default = final: prev: {
q-sh = make_package prev;
};
};
}