q.sh/flake.nix

83 lines
1.9 KiB
Nix
Raw Permalink Normal View History

{
2023-05-14 19:24:27 +00:00
description = "Nix q.sh dev environment";
2023-05-14 19:24:27 +00:00
# Flake inputs
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
};
2023-05-14 19:24:27 +00:00
# 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; };
});
2024-08-19 22:52:14 +00:00
make_package = pkgs: pkgs.stdenv.mkDerivation rec {
2023-05-14 19:24:27 +00:00
name = "q-sh";
src = self;
installPhase = ''
mkdir -p $out/bin
cp q $out/bin
cp q-* $out/bin
echo "OUT " $out
'';
2024-08-19 22:52:14 +00:00
dontStrip = true;
nativeBuildInputs = [pkgs.makeWrapper];
wrapperPath = pkgs.lib.makeBinPath ( with pkgs; [
fzf
findutils
gnused
gawk
bc
pass
coreutils
wl-clipboard
xdg-utils
]
);
2023-05-14 19:24:27 +00:00
postFixup = ''
2024-08-19 22:52:14 +00:00
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
'';
2023-05-14 19:24:27 +00:00
};
in
{
devShells = forAllSystems ({ pkgs }: {
default = pkgs.mkShell {
packages = with pkgs; [
fzf
pass
bc
wl-clipboard
xdg-utils
];
};
2023-05-14 19:24:27 +00:00
});
packages = forAllSystems({ pkgs }: {"q-sh" = make_package pkgs;});
2023-05-14 19:33:41 +00:00
overlays.default = final: prev: {
q-sh = make_package prev;
};
2023-05-14 19:24:27 +00:00
};
}