having a look at https://github.com/ryran/xsos
got a nix package working for it :-)…
However it also comes with a bash completion script, how does one build that into a package, is there an example anywhere.
Also…
These seems to be a few ways to package shell scripts, I’m currently using wrapProgram, but there are other wrappers like makeWrapper, can someone explain the difference?
1 Like
nativeBuildInputs = [ installShellFiles ];
postInstall = ''
installShellCompletion xsos-bash-completion.bash
'';
(Though you may have to rename xsos-bash-completion.bash
to xsos.bash
, try it
.)
installShellFiles
is also described in the following section of the nixpkgs manual:
https://nixos.org/manual/nixpkgs/stable/#ssec-setup-hooks
2 Likes
Ok, I’ve got my nix install script working, it builds!!!
and works.
I can’t get InstallShellCompletion to work, either by changing it’s name.
If I run a nix-shell to debug…, then i can see that that postInstall hook is there but it doesn’t appear on the nix-shell path.hmmmmmm…
any idea’s…
my default.nix code so far.
# nix-build -E 'with import <nixpkgs> {}; callPackage ./default.nix {}'
# nix-shell -E 'with import <nixpkgs> {}; callPackage ./default.nix {}'
{ stdenv, lib, fetchFromGitHub, makeWrapper, installShellFiles, dmidecode, ethtool, pciutils, multipath-tools, iproute }:
stdenv.mkDerivation rec {
pname = "xsos";
version = "v0.7.19";
src = fetchFromGitHub {
owner = "ryran";
repo = "xsos";
rev = version;
sha256 = "11cc8z3pz4gl0mwl2fc701mn4cgx50fybygx0rvs9bhvb0jnphay";
};
nativeBuildInputs = [ makeWrapper installShellFiles];
installPhase = ''
mkdir -p $out/bin
cp -a xsos $out/bin
mv xsos-bash-completion.bash xsos.bash
wrapProgram "$out/bin/xsos" --prefix PATH : "${
stdenv.lib.makeBinPath [
dmidecode
ethtool
pciutils
multipath-tools
iproute
]}"
'';
postInstall = ''
installShellCompletion xsos.bash
'';
meta = with stdenv.lib; {
description = "xsos diagonstic script";
homepage = "https://nothing.sh/";
license = licenses.gpl3;
maintainers = [ maintainers.nobodyyet ];
};
}