disko/package.nix
Felix Uhl aee84b5fb3 disko cli: add --version command
Fixes #745

This adds a script to create a release. Running it will create two
commits that would appear like this in `git log --oneline`:

    67b5fff (master) release: reset released flag
    0b808f3 (tag: v1.8.1) release: v1.8.1
    100d2f3 docs: last change before release

It also re-creates the `version.nix` file, which is used by the flake
to determine the final version the disko CLI will print.

If `disko --version` is run from exactly the commit tagged `v1.8.1`, it
will print `1.8.1`. If it is run from any commit past that (like
master), it will print `1.8.1-67b5fff`, and if it is run from a local
folder with uncommitted changes, it will print `1.8.1-67b5fff-dirty`.
2024-10-11 15:14:56 +00:00

38 lines
1.3 KiB
Nix

{ stdenvNoCC, makeWrapper, lib, path, nix, coreutils, nixos-install-tools, binlore, diskoVersion }:
let
self = stdenvNoCC.mkDerivation (finalAttrs: {
name = "disko";
src = ./.;
nativeBuildInputs = [
makeWrapper
];
installPhase = ''
mkdir -p $out/bin $out/share/disko
cp -r install-cli.nix cli.nix default.nix disk-deactivate lib $out/share/disko
for i in disko disko-install; do
sed -e "s|libexec_dir=\".*\"|libexec_dir=\"$out/share/disko\"|" "$i" > "$out/bin/$i"
chmod 755 "$out/bin/$i"
wrapProgram "$out/bin/$i" \
--set DISKO_VERSION "${diskoVersion}" \
--prefix PATH : ${lib.makeBinPath [ nix coreutils nixos-install-tools ]} \
--prefix NIX_PATH : "nixpkgs=${path}"
done
'';
# Otherwise resholve thinks that disko and disko-install might be able to execute their arguments
passthru.binlore.out = binlore.synthesize self ''
execer cannot bin/.disko-wrapped
execer cannot bin/.disko-install-wrapped
'';
meta = with lib; {
description = "Format disks with nix-config";
homepage = "https://github.com/nix-community/disko";
license = licenses.mit;
maintainers = with maintainers; [ lassulus ];
platforms = platforms.linux;
mainProgram = finalAttrs.name;
};
});
in
self