2026-03-05 16:19:06 +01:00
|
|
|
# SPDX-FileCopyrightText: 2026 Qyriad <qyriad@qyriad.me>
|
|
|
|
|
#
|
|
|
|
|
# SPDX-License-Identifier: EUPL-1.1
|
|
|
|
|
|
2026-01-21 15:23:04 +01:00
|
|
|
{
|
2026-02-17 20:17:39 +01:00
|
|
|
lib,
|
|
|
|
|
clangStdenv,
|
|
|
|
|
callPackage,
|
|
|
|
|
linkFarm,
|
2026-03-22 15:57:38 +01:00
|
|
|
llvmPackages,
|
2026-02-17 20:17:39 +01:00
|
|
|
rustHooks,
|
|
|
|
|
rustPackages,
|
|
|
|
|
versionCheckHook,
|
2026-03-22 15:57:38 +01:00
|
|
|
wrapBintoolsWith,
|
2026-02-16 18:02:39 +01:00
|
|
|
}: lib.callWith' rustPackages ({
|
2026-02-17 20:17:39 +01:00
|
|
|
rustPlatform,
|
|
|
|
|
cargo,
|
2026-01-21 15:23:04 +01:00
|
|
|
}: let
|
2026-03-22 15:57:38 +01:00
|
|
|
# Use LLD for faster link times.
|
|
|
|
|
stdenv = clangStdenv.override {
|
|
|
|
|
cc = clangStdenv.cc.override {
|
|
|
|
|
bintools = wrapBintoolsWith {
|
|
|
|
|
bintools = llvmPackages.bintools;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
2026-02-17 20:17:39 +01:00
|
|
|
cargoToml = lib.importTOML ./Cargo.toml;
|
|
|
|
|
cargoPackage = cargoToml.package;
|
2026-02-11 13:19:59 +01:00
|
|
|
in stdenv.mkDerivation (finalAttrs: let
|
2026-02-17 20:17:39 +01:00
|
|
|
self = finalAttrs.finalPackage;
|
2026-02-11 13:19:59 +01:00
|
|
|
in {
|
2026-02-17 20:17:39 +01:00
|
|
|
pname = cargoPackage.name;
|
|
|
|
|
version = cargoPackage.version;
|
|
|
|
|
|
|
|
|
|
strictDeps = true;
|
|
|
|
|
__structuredAttrs = true;
|
|
|
|
|
|
|
|
|
|
outputs = [ "out" "modules" ];
|
|
|
|
|
|
2026-03-11 14:26:59 +01:00
|
|
|
# These are propagated to sub-derivations.
|
2026-02-17 20:17:39 +01:00
|
|
|
doCheck = true;
|
|
|
|
|
doInstallCheck = true;
|
|
|
|
|
|
2026-03-11 14:26:59 +01:00
|
|
|
buildCommand = ''
|
2026-02-17 20:17:39 +01:00
|
|
|
mkdir -p "$out"
|
|
|
|
|
cp -r --reflink=auto "$dynixCommand/"* "$out/"
|
|
|
|
|
mkdir -p "$modules"
|
|
|
|
|
cp -r --reflink=auto "$dynixModules/"* "$modules/"
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# SUB-DERIVATONS
|
|
|
|
|
#
|
|
|
|
|
|
2026-03-05 15:44:58 +01:00
|
|
|
dynixCommand = stdenv.mkDerivation {
|
2026-02-17 20:17:39 +01:00
|
|
|
pname = "${self.pname}-command";
|
|
|
|
|
inherit (self) version;
|
|
|
|
|
inherit (self) strictDeps __structuredAttrs;
|
|
|
|
|
inherit (self) doCheck doInstallCheck;
|
|
|
|
|
|
2026-03-22 17:15:04 +01:00
|
|
|
outputs = [ "out" "doc" ];
|
|
|
|
|
|
2026-02-17 20:17:39 +01:00
|
|
|
src = lib.fileset.toSource {
|
|
|
|
|
root = ./.;
|
|
|
|
|
fileset = lib.fileset.unions [
|
|
|
|
|
./Cargo.toml
|
|
|
|
|
./Cargo.lock
|
|
|
|
|
./src
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
cargoDeps = rustPlatform.importCargoLock {
|
|
|
|
|
lockFile = ./Cargo.lock;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
nativeBuildInputs = rustHooks.asList ++ [
|
|
|
|
|
cargo
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
nativeInstallCheckInputs = [
|
|
|
|
|
versionCheckHook
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
|
mainProgram = "dynix";
|
2026-03-05 16:19:06 +01:00
|
|
|
description = "The Rust part of Dynix";
|
|
|
|
|
inherit (self.meta) license;
|
2026-02-17 20:17:39 +01:00
|
|
|
};
|
2026-03-05 15:44:58 +01:00
|
|
|
};
|
2026-02-17 20:17:39 +01:00
|
|
|
|
2026-03-05 15:44:58 +01:00
|
|
|
dynixModules = stdenv.mkDerivation {
|
2026-02-17 20:17:39 +01:00
|
|
|
pname = "${self.pname}-modules";
|
|
|
|
|
inherit (self) version;
|
|
|
|
|
inherit (self) strictDeps __structuredAttrs;
|
|
|
|
|
inherit (self) doCheck doInstallCheck;
|
|
|
|
|
|
|
|
|
|
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 ''
|
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
|
|
mkdir -p "$modulesOut"
|
|
|
|
|
cp -r "$src/"* "$modulesOut/"
|
|
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
|
'';
|
2026-03-05 16:19:06 +01:00
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
|
description = "The NixOS modules part of Dynix";
|
|
|
|
|
inherit (self.meta) license;
|
|
|
|
|
};
|
2026-03-05 15:44:58 +01:00
|
|
|
};
|
2026-02-17 20:17:39 +01:00
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
passthru.mkDevShell = {
|
|
|
|
|
path,
|
|
|
|
|
mkShell,
|
|
|
|
|
python3Packages,
|
|
|
|
|
fenixToolchain,
|
2026-03-10 19:56:41 +01:00
|
|
|
cargo,
|
2026-02-17 20:17:39 +01:00
|
|
|
}: let
|
|
|
|
|
mkShell' = mkShell.override { inherit stdenv; };
|
|
|
|
|
pyEnv = python3Packages.python.withPackages (p: [ p.beartype ]);
|
2026-03-10 19:56:41 +01:00
|
|
|
# Fenix's Cargo doesn't have completions, but Nixpkgs' does.
|
|
|
|
|
cargoCompletions = linkFarm "cargo-bash-completions" {
|
|
|
|
|
"share/bash-completion" = cargo + "/share/bash-completion";
|
|
|
|
|
};
|
2026-02-17 20:17:39 +01:00
|
|
|
in mkShell' {
|
|
|
|
|
name = "devshell-for-${self.name}";
|
|
|
|
|
inputsFrom = [ self ];
|
|
|
|
|
packages = [
|
|
|
|
|
pyEnv
|
|
|
|
|
stdenv.cc
|
|
|
|
|
fenixToolchain
|
2026-03-10 19:56:41 +01:00
|
|
|
cargoCompletions
|
2026-02-17 20:17:39 +01:00
|
|
|
];
|
|
|
|
|
env.PYTHONPATH = [
|
|
|
|
|
"${pyEnv}/${pyEnv.sitePackages}"
|
|
|
|
|
# Cursed.
|
|
|
|
|
"${path}/nixos/lib/test-driver/src"
|
|
|
|
|
] |> lib.concatStringsSep ":";
|
2026-03-10 19:56:41 +01:00
|
|
|
|
|
|
|
|
passthru = { inherit cargoCompletions; };
|
2026-02-17 20:17:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
passthru.modulesPath = self.modules + "/share/nixos/modules";
|
|
|
|
|
passthru.dynix = self.modulesPath + "/dynix";
|
|
|
|
|
|
|
|
|
|
passthru.tests = lib.fix (callPackage ./tests {
|
|
|
|
|
dynix = self;
|
|
|
|
|
}).packages;
|
|
|
|
|
|
|
|
|
|
passthru.allTests = linkFarm "dynix-all-tests" self.tests;
|
|
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
|
longDescription = lib.dedent ''
|
|
|
|
|
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 = [`.
|
|
|
|
|
'';
|
2026-03-05 16:19:06 +01:00
|
|
|
license = with lib.licenses; [ eupl12 ];
|
2026-02-17 20:17:39 +01:00
|
|
|
mainProgram = "dynix";
|
|
|
|
|
outputsToInstall = [ "out" "modules" ];
|
|
|
|
|
};
|
2026-02-16 18:02:39 +01:00
|
|
|
}))
|