nix: splice the package properly (#234)

Use callPackage on the wrapper as well. Fixes #232.

That change also breaks the public interface a bit to keep things
simple.
This commit is contained in:
Jonas Chevalier 2025-05-22 10:52:50 +02:00 committed by GitHub
parent 64ca98a15b
commit 94f1c8d9c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 34 additions and 37 deletions

View file

@ -4,5 +4,5 @@
}: }:
{ {
lib = import ./nix/lib.nix { inherit nixpkgs; }; lib = import ./nix/lib.nix { inherit nixpkgs; };
system-manager = pkgs.callPackage ./package.nix { };
} }
// import ./packages.nix { inherit pkgs; }

View file

@ -34,21 +34,17 @@
{ {
lib = import ./nix/lib.nix { inherit nixpkgs; }; lib = import ./nix/lib.nix { inherit nixpkgs; };
# The unwrapped version takes nix from the PATH, it will fail if nix
# cannot be found.
# The wrapped version has a reference to the nix store path, so nix is
# part of its runtime closure.
packages = eachSystem ( packages = eachSystem (
{ pkgs, system }: { pkgs, system }:
import ./packages.nix { inherit pkgs; } {
// { default = pkgs.callPackage ./package.nix { };
default = self.packages.${system}.system-manager;
} }
); );
overlays = { overlays = {
packages = final: _prev: import ./packages.nix { pkgs = final; }; default = final: _prev: {
default = self.overlays.packages; system-manager = final.callPackage ./package.nix { };
};
}; };
# Only useful for quick tests # Only useful for quick tests
@ -70,7 +66,7 @@
(eachSystem ( (eachSystem (
{ system, ... }: { system, ... }:
{ {
system-manager = self.packages.${system}.system-manager; system-manager = self.packages.${system}.default;
} }
)) ))
{ {

View file

@ -61,9 +61,7 @@ let
}; };
# Pass the wrapped system-manager binary down # Pass the wrapped system-manager binary down
# TODO: Use nixpkgs version by default. # TODO: Use nixpkgs version by default.
inherit (import ../packages.nix { inherit pkgs; }) system-manager = pkgs.callPackage ../package.nix { };
system-manager
;
}; };
}; };

View file

@ -1,18 +1,19 @@
{ {
pkgs ? import <nixpkgs> { }, lib,
lib ? pkgs.lib,
rustPlatform,
cargo,
dbus,
pkg-config,
nix,
clippy,
runCommand,
makeBinaryWrapper,
}: }:
let let
cargoManifest = (pkgs.lib.importTOML ./Cargo.toml).package; cargoManifest = (lib.importTOML ./Cargo.toml).package;
system-manager-unwrapped = pkgs.callPackage ( system-manager-unwrapped = rustPlatform.buildRustPackage {
{
rustPlatform,
dbus,
pkg-config,
nix,
clippy,
}:
rustPlatform.buildRustPackage {
pname = "system-manager"; pname = "system-manager";
version = cargoManifest.version; version = cargoManifest.version;
src = lib.fileset.toSource { src = lib.fileset.toSource {
@ -37,27 +38,29 @@ let
]; ];
preCheck = '' preCheck = ''
${lib.getExe pkgs.cargo} clippy ${lib.getExe cargo} clippy
# Stop the Nix command from trying to create /nix/var/nix/profiles. # Stop the Nix command from trying to create /nix/var/nix/profiles.
# #
# https://nix.dev/manual/nix/2.24/command-ref/new-cli/nix3-profile#profiles # https://nix.dev/manual/nix/2.24/command-ref/new-cli/nix3-profile#profiles
export NIX_STATE_DIR=$TMPDIR export NIX_STATE_DIR=$TMPDIR
''; '';
} };
) { };
in in
{ runCommand "system-manager"
inherit system-manager-unwrapped;
system-manager =
pkgs.runCommand "system-manager"
{ {
nativeBuildInputs = [ pkgs.pkgsBuildHost.makeBinaryWrapper ]; nativeBuildInputs = [ makeBinaryWrapper ];
passthru = {
# The unwrapped version takes nix from the PATH, it will fail if nix
# cannot be found.
# The wrapped version has a reference to the nix store path, so nix is
# part of its runtime closure.
unwrapped = system-manager-unwrapped;
};
} }
'' ''
makeWrapper \ makeWrapper \
${system-manager-unwrapped}/bin/system-manager \ ${system-manager-unwrapped}/bin/system-manager \
$out/bin/system-manager \ $out/bin/system-manager \
--prefix PATH : ${lib.makeBinPath [ pkgs.nix ]} --prefix PATH : ${lib.makeBinPath [ nix ]}
''; ''
}