From 43502f82f90a38022dac2595316569384fd1a0f3 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Mon, 15 Jan 2024 17:07:55 +0100 Subject: [PATCH] Remove platform suffix from binary produced by default flake target --- flake.nix | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/flake.nix b/flake.nix index ab603ba..26134bf 100644 --- a/flake.nix +++ b/flake.nix @@ -57,7 +57,7 @@ {} supportedSystems; - # eachCrossSystem [system] (buildSystem: targetSystem: ...) + # eachCrossSystem [system] ({buildSystem, targetSystem, isDefault }: ...) # # Returns an attrset with a key "$buildSystem.cross-$targetSystem" for # every combination of the elements of the array of system strings. The @@ -72,13 +72,20 @@ pkgs = mkPkgs buildSystem null; crosses = builtins.foldl' (inner: targetSystem: inner // { - "cross-${targetSystem}" = callback buildSystem targetSystem; + "cross-${targetSystem}" = callback { + inherit buildSystem targetSystem; + isDefault = false; + }; }) - { default = callback buildSystem buildSystem; } + {} supportedSystems; in crosses // (rec { - default = callback buildSystem buildSystem; + default = callback { + inherit buildSystem; + targetSystem = buildSystem; + isDefault = true; + }; release = let bins = pkgs.symlinkJoin { name = "${default.name}-all-bins"; @@ -164,7 +171,7 @@ packages = eachCrossSystem (builtins.attrNames buildTargets) - (buildSystem: targetSystem: let + ({ buildSystem, targetSystem, isDefault }: let pkgs = mkPkgs buildSystem null; toolchain = mkToolchain buildSystem targetSystem; naersk-lib = pkgs.callPackage naersk { @@ -177,7 +184,7 @@ strictDeps = true; doCheck = false; release = true; - postInstall = '' + postInstall = if isDefault then "" else '' cd "$out"/bin for f in "$(ls)"; do if ext="$(echo "$f" | grep -oP '\.[a-z]+$')"; then @@ -193,7 +200,7 @@ devShells = eachCrossSystem (builtins.attrNames buildTargets) - (buildSystem: targetSystem: let + ({ buildSystem, targetSystem, isDefault }: let pkgs = mkPkgs buildSystem null; toolchain = mkToolchain buildSystem targetSystem; in