From 6d2914c62c5ca27276b75f1cc75e11356984cb0b Mon Sep 17 00:00:00 2001 From: Jason Yundt Date: Mon, 23 Sep 2024 12:39:13 -0400 Subject: [PATCH] Add binlore for disko and disko-install MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Consider this flake: { description = "Helper for reproducing a disko-related problem"; inputs = { disko.url = "github:nix-community/disko/b1d6bed240abef5f5373e88fc7909f493013e557"; nixpkgs.follows = "disko/nixpkgs"; }; outputs = { self, disko, nixpkgs, }: let system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages."${system}"; in { packages."${system}".default = pkgs.resholve.writeScript "disko-install-binlore-test" { inputs = [ disko.packages."${system}".default ]; interpreter = "${pkgs.lib.getExe pkgs.bash}"; } '' disko --help disko-install --help ''; }; } That flake will fail to build because resholve thinks that disko and disko-install might be able to execute their arguments. This commit fixes that problem. Co-authored-by: Jörg Thalheim --- package.nix | 61 +++++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/package.nix b/package.nix index f089be4..e71d52f 100644 --- a/package.nix +++ b/package.nix @@ -1,29 +1,36 @@ -{ stdenvNoCC, makeWrapper, lib, path, nix, coreutils, nixos-install-tools }: +{ stdenvNoCC, makeWrapper, lib, path, nix, coreutils, nixos-install-tools, binlore }: -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 +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" \ - --prefix PATH : ${lib.makeBinPath [ nix coreutils nixos-install-tools ]} \ - --prefix NIX_PATH : "nixpkgs=${path}" - done - ''; - 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; - }; -}) + 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" \ + --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