From 2713dd4d9785f1e1a62fee98e71d75a3513d370b Mon Sep 17 00:00:00 2001 From: Petar Kirov Date: Thu, 10 Apr 2025 14:00:28 +0300 Subject: [PATCH 1/7] Revert "fix(mcl): Only build mcl on x86_64-linux" This reverts commit a26a713258be7a0ea603e56b01ab79b4722c1391. --- packages/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/default.nix b/packages/default.nix index 1b0bb64c..a817f514 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -9,7 +9,7 @@ let inherit (lib) optionalAttrs versionAtLeast; inherit (pkgs) system; - inherit (pkgs.hostPlatform) isLinux; + inherit (pkgs.hostPlatform) isLinux isDarwin isx86; in rec { legacyPackages = { @@ -65,7 +65,7 @@ // optionalAttrs isLinux { folder-size-metrics = pkgs.callPackage ./folder-size-metrics { }; } - // optionalAttrs (system == "x86_64-linux") rec { + // optionalAttrs ((isLinux && isx86) || isDarwin) rec { mcl = pkgs.callPackage ./mcl { buildDubPackage = inputs'.dlang-nix.legacyPackages.buildDubPackage.override { dCompiler = inputs'.dlang-nix.packages."ldc-binary-1_38_0"; From f23f8933a537b7c5cda9a1a8e6f60ddd743d4ba8 Mon Sep 17 00:00:00 2001 From: Petar Kirov Date: Thu, 10 Apr 2025 14:00:28 +0300 Subject: [PATCH 2/7] Revert "build(flake/inputs): update dlang.nix" This reverts commit 92040c440c54c12b076ad18deffa4caf27c5d697. --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 9925fcb5..d5a1fd44 100644 --- a/flake.lock +++ b/flake.lock @@ -203,11 +203,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1744030092, - "narHash": "sha256-EwKNnBBTpjgNH20nfhJocGh6rZQJji0/8i1qsaviiGQ=", + "lastModified": 1719092179, + "narHash": "sha256-/4jxq5+pDkVMao5RzOm27C2AfANjisTuvsycA0pbBCg=", "owner": "PetarKirov", "repo": "dlang.nix", - "rev": "ab6b8f72d7b56bfd0b12e189fc4dfaed9d46de76", + "rev": "21b1b3b18b3b635a43b319612aff529d26b1863b", "type": "github" }, "original": { From 861675891fab56abd038faef62533e3539d27472 Mon Sep 17 00:00:00 2001 From: Petar Kirov Date: Thu, 10 Apr 2025 14:00:28 +0300 Subject: [PATCH 3/7] Revert "fix(mcl): Fix curl library issues\nrefactor(packages): pre-commit-hook compliance" This reverts commit ddcfae77ca2900d19f93ab177be1200c74753789. --- packages/default.nix | 1 + packages/mcl/default.nix | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/default.nix b/packages/default.nix index a817f514..f9ab5ef3 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -75,3 +75,4 @@ }; }; } + diff --git a/packages/mcl/default.nix b/packages/mcl/default.nix index 998abcfd..fb0e9947 100644 --- a/packages/mcl/default.nix +++ b/packages/mcl/default.nix @@ -26,7 +26,6 @@ let alejandra openssh cachix - curl ]) ++ lib.optionals (isLinux && isx86) [ dmidecode @@ -62,7 +61,7 @@ buildDubPackage rec { nativeBuildInputs = [ pkgs.makeWrapper ] ++ deps; postFixup = '' - wrapProgram $out/bin/${pname} --set PATH "${lib.makeBinPath deps}" --set LD_LIBRARY_PATH "${lib.makeLibraryPath deps}" + wrapProgram $out/bin/${pname} --set PATH "${lib.makeBinPath deps}" ''; dubBuildFlags = [ From 831a0f86e5dad3c474e3cb826d8b36b124a732c4 Mon Sep 17 00:00:00 2001 From: Petar Kirov Date: Thu, 10 Apr 2025 14:00:28 +0300 Subject: [PATCH 4/7] Revert "fix(mcl/host_info): awk command syntax changed" This reverts commit 96685d0deec25e706f899e80adb9f2d5063bd925. --- packages/mcl/src/src/mcl/commands/host_info.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mcl/src/src/mcl/commands/host_info.d b/packages/mcl/src/src/mcl/commands/host_info.d index 4fc139a0..852dc632 100644 --- a/packages/mcl/src/src/mcl/commands/host_info.d +++ b/packages/mcl/src/src/mcl/commands/host_info.d @@ -395,7 +395,7 @@ string getDistribution() if (exists("/etc/os-release")) { foreach (line; execute([ - "awk", "-F", "=", "/^NAME=/ {print $2}", "/etc/os-release" + "awk", "-F", "=", "'/^NAME=/ {print $2}'", "/etc/os-release" ], false).split("\n")) { distribution = line; @@ -418,7 +418,7 @@ string getDistributionVersion() if (exists("/etc/os-release")) { foreach (line; execute([ - "awk", "-F", "=", "/^VERSION=/ {print $2}", "/etc/os-release" + "awk", "-F", "=", "'/^VERSION=/ {print $2}'", "/etc/os-release" ], false).split("\n")) { distributionVersion = line.strip("\""); From b29f64cbc640daab79e585bc6726948219085653 Mon Sep 17 00:00:00 2001 From: Petar Kirov Date: Thu, 10 Apr 2025 14:00:28 +0300 Subject: [PATCH 5/7] Revert "feat(mcl): Make linux-only dependencies optional" This reverts commit 9776e62960b8e1b73c74e7633546da0800c3302d. --- packages/default.nix | 7 +++---- packages/mcl/default.nix | 19 ++++++------------- packages/mcl/src/src/mcl/commands/host_info.d | 2 ++ 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/packages/default.nix b/packages/default.nix index f9ab5ef3..02d9f68d 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -9,7 +9,7 @@ let inherit (lib) optionalAttrs versionAtLeast; inherit (pkgs) system; - inherit (pkgs.hostPlatform) isLinux isDarwin isx86; + inherit (pkgs.hostPlatform) isLinux; in rec { legacyPackages = { @@ -65,14 +65,13 @@ // optionalAttrs isLinux { folder-size-metrics = pkgs.callPackage ./folder-size-metrics { }; } - // optionalAttrs ((isLinux && isx86) || isDarwin) rec { + // optionalAttrs (system == "x86_64-linux") { mcl = pkgs.callPackage ./mcl { buildDubPackage = inputs'.dlang-nix.legacyPackages.buildDubPackage.override { - dCompiler = inputs'.dlang-nix.packages."ldc-binary-1_38_0"; + ldc = inputs'.dlang-nix.packages."ldc-binary-1_34_0"; }; inherit (legacyPackages.inputs.nixpkgs) cachix nix nix-eval-jobs; }; }; }; } - diff --git a/packages/mcl/default.nix b/packages/mcl/default.nix index fb0e9947..f99c12b9 100644 --- a/packages/mcl/default.nix +++ b/packages/mcl/default.nix @@ -7,9 +7,7 @@ ... }: let - inherit (pkgs.hostPlatform) isLinux isx86; deps = - with pkgs; [ nix nix-eval-jobs @@ -17,25 +15,18 @@ let ++ (with pkgs; [ gitMinimal gawk + dmidecode jc edid-decode coreutils-full util-linux xorg.xrandr - perl - alejandra - openssh - cachix - ]) - ++ lib.optionals (isLinux && isx86) [ - dmidecode glxinfo - nixos-install-tools - systemd - ]; + cachix + ]); excludedTests = ( lib.concatStringsSep "|" [ - "(nix\\.(build|run|eval))" + "(nix\\.(build|run))" "fetchJson|(coda\.)" "checkPackage" "generateShardMatrix" @@ -65,11 +56,13 @@ buildDubPackage rec { ''; dubBuildFlags = [ + "--compiler=dmd" "-b" "debug" ]; dubTestFlags = [ + "--compiler=dmd" "--" "-e" excludedTests diff --git a/packages/mcl/src/src/mcl/commands/host_info.d b/packages/mcl/src/src/mcl/commands/host_info.d index 852dc632..38f7554a 100644 --- a/packages/mcl/src/src/mcl/commands/host_info.d +++ b/packages/mcl/src/src/mcl/commands/host_info.d @@ -178,6 +178,8 @@ Info getInfo() return info; } + + struct Info { SoftwareInfo softwareInfo; From a238a4be43e820f0bf75e6afa9f5165836c4d425 Mon Sep 17 00:00:00 2001 From: Petar Kirov Date: Thu, 10 Apr 2025 14:00:28 +0300 Subject: [PATCH 6/7] Revert "feat(mcl/host_info): Upload results to Coda" This reverts commit f8109b468a0d579b3e9c43a0d960030040123247. --- packages/mcl/src/src/mcl/commands/host_info.d | 97 +------------------ packages/mcl/src/src/mcl/utils/coda.d | 12 +-- packages/mcl/src/src/mcl/utils/process.d | 1 - 3 files changed, 5 insertions(+), 105 deletions(-) diff --git a/packages/mcl/src/src/mcl/commands/host_info.d b/packages/mcl/src/src/mcl/commands/host_info.d index 38f7554a..1e45ff40 100644 --- a/packages/mcl/src/src/mcl/commands/host_info.d +++ b/packages/mcl/src/src/mcl/commands/host_info.d @@ -9,7 +9,7 @@ import std.stdio : writeln; import std.conv : to; import std.string : strip, indexOf, isNumeric; import std.array : split, join, array, replace; -import std.algorithm : map, filter, startsWith, joiner, any, sum, find; +import std.algorithm : map, filter, startsWith, joiner, any, sum; import std.file : exists, write, readText, readLink, dirEntries, SpanMode; import std.path : baseName; import std.json; @@ -22,7 +22,6 @@ import mcl.utils.process : execute, isRoot; import mcl.utils.number : humanReadableSize; import mcl.utils.array : uniqIfSame; import mcl.utils.nix : Literal; -import mcl.utils.coda; // enum InfoFormat // { @@ -35,12 +34,10 @@ struct Params { // @optional() // InfoFormat format = InfoFormat.JSON; - @optional() string codaApiToken; void setup() { } } -Params params; string[string] cpuinfo; @@ -67,7 +64,7 @@ string[string] getProcInfo(string fileOrData, bool file = true) export void host_info() { - params = parseEnv!Params; + const params = parseEnv!Params; Info info = getInfo(); @@ -82,8 +79,6 @@ Info getInfo() meminfo = getProcInfo("/proc/meminfo"); Info info; - info.softwareInfo.hostid = execute("hostid", false); - info.softwareInfo.hostname = execute("cat /etc/hostname", false); info.softwareInfo.operatingSystemInfo = getOperatingSystemInfo(); info.softwareInfo.opensshInfo = getOpenSSHInfo(); info.softwareInfo.machineConfigInfo = getMachineConfigInfo(); @@ -95,91 +90,9 @@ Info getInfo() info.hardwareInfo.displayInfo = getDisplayInfo(); info.hardwareInfo.graphicsProcessorInfo = getGraphicsProcessorInfo(); - if (params.codaApiToken) { - auto docId = "0rz18jyJ1M"; - auto hostTableId = "grid-b3MAjem325"; - auto cpuTableId = "grid-mCI3x3nEIE"; - auto memoryTableId = "grid-o7o2PeB4rz"; - auto motherboardTableId = "grid-270PlzmA8K"; - auto gpuTableId = "grid-ho6EPztvni"; - auto storageTableId = "grid-JvXFbttMNz"; - auto osTableId = "grid-ora7n98-ls"; - auto coda = CodaApiClient(params.codaApiToken); - - auto hostValues = RowValues([ - CodaCell("Host Name", info.softwareInfo.hostname), - CodaCell("Host ID", info.softwareInfo.hostid), - CodaCell("OpenSSH Public Key", info.softwareInfo.opensshInfo.publicKey), - CodaCell("JSON", info.toJSON(true).toPrettyString(JSONOptions.doNotEscapeSlashes)) - ]); - - coda.updateOrInsertRow(docId, hostTableId, hostValues); - - auto cpuValues = RowValues([ - CodaCell("Host Name", info.softwareInfo.hostname), - CodaCell("Vendor", info.hardwareInfo.processorInfo.vendor), - CodaCell("Model", info.hardwareInfo.processorInfo.model), - CodaCell("Architecture", info.hardwareInfo.processorInfo.architectureInfo.architecture), - CodaCell("Flags", info.hardwareInfo.processorInfo.architectureInfo.flags), - ]); - coda.updateOrInsertRow(docId, cpuTableId, cpuValues); - - auto memoryValues = RowValues([ - CodaCell("Host Name", info.softwareInfo.hostname), - CodaCell("Vendor", info.hardwareInfo.memoryInfo.vendor), - CodaCell("Part Number", info.hardwareInfo.memoryInfo.partNumber), - CodaCell("Serial", info.hardwareInfo.memoryInfo.serial), - CodaCell("Generation", info.hardwareInfo.memoryInfo.type), - CodaCell("Slots", info.hardwareInfo.memoryInfo.slots == 0 ? "Soldered" : info.hardwareInfo.memoryInfo.count.to!string ~ "/" ~ info.hardwareInfo.memoryInfo.slots.to!string), - CodaCell("Total", info.hardwareInfo.memoryInfo.total), - CodaCell("Speed", info.hardwareInfo.memoryInfo.speed), - ]); - coda.updateOrInsertRow(docId, memoryTableId, memoryValues); - - auto motherboardValues = RowValues([ - CodaCell("Host Name", info.softwareInfo.hostname), - CodaCell("Vendor", info.hardwareInfo.motherboardInfo.vendor), - CodaCell("Model", info.hardwareInfo.motherboardInfo.model), - CodaCell("Revision", info.hardwareInfo.motherboardInfo.version_), - CodaCell("Serial", info.hardwareInfo.motherboardInfo.serial), - CodaCell("BIOS Vendor", info.hardwareInfo.motherboardInfo.biosInfo.vendor), - CodaCell("BIOS Version", info.hardwareInfo.motherboardInfo.biosInfo.version_), - CodaCell("BIOS Release", info.hardwareInfo.motherboardInfo.biosInfo.release), - CodaCell("BIOS Date", info.hardwareInfo.motherboardInfo.biosInfo.date) - ]); - coda.updateOrInsertRow(docId, motherboardTableId, motherboardValues); - - auto gpuValues = RowValues([ - CodaCell("Host Name", info.softwareInfo.hostname), - CodaCell("Vendor", info.hardwareInfo.graphicsProcessorInfo.vendor), - CodaCell("Model", info.hardwareInfo.graphicsProcessorInfo.model), - CodaCell("VRam", info.hardwareInfo.graphicsProcessorInfo.vram) - ]); - coda.updateOrInsertRow(docId, gpuTableId, gpuValues); - - auto osValues = RowValues([ - CodaCell("Host Name", info.softwareInfo.hostname), - CodaCell("Distribution", info.softwareInfo.operatingSystemInfo.distribution), - CodaCell("Distribution Version", info.softwareInfo.operatingSystemInfo.distributionVersion), - CodaCell("Kernel", info.softwareInfo.operatingSystemInfo.kernel), - CodaCell("Kernel Version", info.softwareInfo.operatingSystemInfo.kernelVersion) - ]); - coda.updateOrInsertRow(docId, osTableId, osValues); - - auto storageValues = RowValues([ - CodaCell("Host Name", info.softwareInfo.hostname), - CodaCell("Count", info.hardwareInfo.storageInfo.devices.length.to!string), - CodaCell("Total", info.hardwareInfo.storageInfo.total), - CodaCell("JSON", info.hardwareInfo.storageInfo.toJSON(true).toPrettyString(JSONOptions.doNotEscapeSlashes)) - ]); - coda.updateOrInsertRow(docId, storageTableId, storageValues); - } - return info; } - - struct Info { SoftwareInfo softwareInfo; @@ -188,8 +101,6 @@ struct Info struct SoftwareInfo { - string hostname; - string hostid; OperatingSystemInfo operatingSystemInfo; OpenSSHInfo opensshInfo; MachineConfigInfo machineConfigInfo; @@ -397,7 +308,7 @@ string getDistribution() if (exists("/etc/os-release")) { foreach (line; execute([ - "awk", "-F", "=", "'/^NAME=/ {print $2}'", "/etc/os-release" + "awk", "-F", "=", "/^NAME=/ {print $2}", "/etc/os-release" ], false).split("\n")) { distribution = line; @@ -420,7 +331,7 @@ string getDistributionVersion() if (exists("/etc/os-release")) { foreach (line; execute([ - "awk", "-F", "=", "'/^VERSION=/ {print $2}'", "/etc/os-release" + "awk", "-F", "=", "/^VERSION=/ {print $2}", "/etc/os-release" ], false).split("\n")) { distributionVersion = line.strip("\""); diff --git a/packages/mcl/src/src/mcl/utils/coda.d b/packages/mcl/src/src/mcl/utils/coda.d index 3970d9f2..b2809216 100644 --- a/packages/mcl/src/src/mcl/utils/coda.d +++ b/packages/mcl/src/src/mcl/utils/coda.d @@ -31,7 +31,7 @@ import std.traits : isArray; import mcl.utils.json : toJSON, fromJSON; import std.process : environment; import std.stdio : writeln, writefln; -import std.algorithm : map, filter, find; +import std.algorithm : map, filter; import std.exception : assertThrown; import std.sumtype : SumType; import core.thread; @@ -527,16 +527,6 @@ struct CodaApiClient coda.deleteRow("dEJJPwdxcw", tables[0].id, resp[0]); } - void updateOrInsertRow(string docId, string tableId, RowValues values) { - auto table = listRows(docId, tableId); - auto rows = find!(row => row.name == values.cells[0].value)(table); - if (rows.length > 0) { - updateRow(docId, tableId, rows[0].id, values); - } - else { - insertRows(docId, tableId, [values]); - } - } struct PushButtonResponse { string requestId; string rowId; diff --git a/packages/mcl/src/src/mcl/utils/process.d b/packages/mcl/src/src/mcl/utils/process.d index b7518ad0..c0d55ad3 100644 --- a/packages/mcl/src/src/mcl/utils/process.d +++ b/packages/mcl/src/src/mcl/utils/process.d @@ -24,7 +24,6 @@ T execute(T = string)(string[] args, bool printCommand = true, bool returnErr = import std.array : join; import std.algorithm : map; import std.conv : to; - import std.stdio : writeln; auto cmd = args.map!escapeShellCommand.join(" "); From 937b67a5bef912cd5a5e6b3740d7982a2a785d74 Mon Sep 17 00:00:00 2001 From: Petar Kirov Date: Thu, 10 Apr 2025 14:00:28 +0300 Subject: [PATCH 7/7] Revert "build(flake/inputs): update dlang.nix to feat/build-dub-package branch" This reverts commit 20ad2bd66406aa58d484e668b887c5ef58ce8d11. --- flake.lock | 8 ++++---- flake.nix | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index d5a1fd44..ace8a3f2 100644 --- a/flake.lock +++ b/flake.lock @@ -203,17 +203,17 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1719092179, - "narHash": "sha256-/4jxq5+pDkVMao5RzOm27C2AfANjisTuvsycA0pbBCg=", + "lastModified": 1714055636, + "narHash": "sha256-8LCyIPAK4/4ge03ohCIWpoJrMGgoCaOriALzt7gPxHE=", "owner": "PetarKirov", "repo": "dlang.nix", - "rev": "21b1b3b18b3b635a43b319612aff529d26b1863b", + "rev": "dab4c199ad644dc23b0b9481e2e5a063e9492b84", "type": "github" }, "original": { "owner": "PetarKirov", - "ref": "feat/build-dub-package", "repo": "dlang.nix", + "rev": "dab4c199ad644dc23b0b9481e2e5a063e9492b84", "type": "github" } }, diff --git a/flake.nix b/flake.nix index 79392ba7..cb69384f 100644 --- a/flake.nix +++ b/flake.nix @@ -197,7 +197,7 @@ }; dlang-nix = { - url = "github:PetarKirov/dlang.nix/feat/build-dub-package"; + url = "github:PetarKirov/dlang.nix?branch=feat/build-dub-package&rev=dab4c199ad644dc23b0b9481e2e5a063e9492b84"; inputs = { flake-compat.follows = "flake-compat"; flake-parts.follows = "flake-parts";