From f46c2a9934d57b8d418c97e99e43b84991a70760 Mon Sep 17 00:00:00 2001 From: Qyriad Date: Mon, 16 Feb 2026 18:02:39 +0100 Subject: [PATCH] packaging: convert split derivation to hybrid split/multi-derivation --- package.nix | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/package.nix b/package.nix index a336a2e..0252d88 100644 --- a/package.nix +++ b/package.nix @@ -27,13 +27,6 @@ in { doCheck = true; doInstallCheck = true; - modulesSrc = lib.fileset.toSource { - root = ./modules/dynamicism; - fileset = lib.fileset.unions [ - ./modules/dynamicism - ]; - }; - src = lib.fileset.toSource { root = ./.; 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 { lockFile = ./Cargo.lock; }; @@ -55,11 +68,9 @@ in { versionCheckHook ]; - modulesOut = "${placeholder "modules"}/share/nixos/modules/dynix"; - - postInstall = lib.dedent '' - mkdir -p "$modulesOut" - cp -r "$modulesSrc/"* "$modulesOut/" + postFixup = lib.dedent '' + mkdir -p "$modules" + cp -r --reflink=auto "$dynixModules/"* "$modules/" ''; passthru.mkDevShell = { @@ -97,8 +108,10 @@ in { meta = { 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 `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"; outputsToInstall = [ "out" "modules" ];