packaging: convert split derivation to hybrid split/multi-derivation

This commit is contained in:
Qyriad 2026-02-16 18:02:39 +01:00
parent 4aac9a8dba
commit f46c2a9934

View file

@ -27,13 +27,6 @@ in {
doCheck = true; doCheck = true;
doInstallCheck = true; doInstallCheck = true;
modulesSrc = lib.fileset.toSource {
root = ./modules/dynamicism;
fileset = lib.fileset.unions [
./modules/dynamicism
];
};
src = lib.fileset.toSource { src = lib.fileset.toSource {
root = ./.; root = ./.;
fileset = lib.fileset.unions [ fileset = lib.fileset.unions [
@ -43,6 +36,26 @@ in {
]; ];
}; };
dynixModules = stdenv.mkDerivation (modulesSelf: {
pname = "dynix-modules";
inherit (self) version;
src = lib.fileset.toSource {
root = ./modules/dynamicism;
fileset = lib.fileset.unions [
./modules/dynamicism
];
};
phases = [ "unpackPhase" "patchPhase" "installPhase" ];
modulesOut = "${placeholder "out"}/share/nixos/modules/dynix";
installPhase = lib.dedent ''
mkdir -p "$modulesOut"
cp -r "$src/"* "$modulesOut/"
'';
});
cargoDeps = rustPlatform.importCargoLock { cargoDeps = rustPlatform.importCargoLock {
lockFile = ./Cargo.lock; lockFile = ./Cargo.lock;
}; };
@ -55,11 +68,9 @@ in {
versionCheckHook versionCheckHook
]; ];
modulesOut = "${placeholder "modules"}/share/nixos/modules/dynix"; postFixup = lib.dedent ''
mkdir -p "$modules"
postInstall = lib.dedent '' cp -r --reflink=auto "$dynixModules/"* "$modules/"
mkdir -p "$modulesOut"
cp -r "$modulesSrc/"* "$modulesOut/"
''; '';
passthru.mkDevShell = { passthru.mkDevShell = {
@ -97,8 +108,10 @@ in {
meta = { meta = {
longDescription = lib.dedent '' longDescription = lib.dedent ''
Default output contains the modules at top-level, meant for `import`. Default output contains the Rust binary.
The `modules` output contains the modules prefixed under `/share/nixos/modules/dynix`. The `modules` output contains the modules prefixed under `/share/nixos/modules/dynix`.
The `dynix` passthru attr is a shortcut for the modules output *with* the modules prefix,
and thus `dynix.dynix` can be passed directly to `imports = [`.
''; '';
mainProgram = "dynix"; mainProgram = "dynix";
outputsToInstall = [ "out" "modules" ]; outputsToInstall = [ "out" "modules" ];