From 8142ee203b9e5a56a89ee80398a08f4f5ac7bcfb Mon Sep 17 00:00:00 2001
From: Millian Poquet <millian.poquet@irit.fr>
Date: Wed, 5 Feb 2025 10:35:59 +0100
Subject: [PATCH] pkg, bs: meson+nix attempt (does not work)

---
 flake.lock  | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 flake.nix   | 25 ++++++++++++++++++++++
 meson.build | 48 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 134 insertions(+)
 create mode 100644 flake.lock
 create mode 100644 flake.nix
 create mode 100644 meson.build

diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..7fc3721
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,61 @@
+{
+  "nodes": {
+    "flake-utils": {
+      "inputs": {
+        "systems": "systems"
+      },
+      "locked": {
+        "lastModified": 1731533236,
+        "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "type": "github"
+      }
+    },
+    "nixpkgs": {
+      "locked": {
+        "lastModified": 1731603435,
+        "narHash": "sha256-CqCX4JG7UiHvkrBTpYC3wcEurvbtTADLbo3Ns2CEoL8=",
+        "owner": "nixos",
+        "repo": "nixpkgs",
+        "rev": "8b27c1239e5c421a2bbc2c65d52e4a6fbf2ff296",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nixos",
+        "ref": "branch-off-24.11",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "root": {
+      "inputs": {
+        "flake-utils": "flake-utils",
+        "nixpkgs": "nixpkgs"
+      }
+    },
+    "systems": {
+      "locked": {
+        "lastModified": 1681028828,
+        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+        "owner": "nix-systems",
+        "repo": "default",
+        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-systems",
+        "repo": "default",
+        "type": "github"
+      }
+    }
+  },
+  "root": "root",
+  "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..2f812a7
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,25 @@
+{
+  inputs = {
+    nixpkgs.url = "github:nixos/nixpkgs?ref=branch-off-24.11";
+    flake-utils.url = "github:numtide/flake-utils";
+  };
+
+  outputs = { self, nixpkgs, flake-utils }:
+    flake-utils.lib.eachDefaultSystem (system:
+      let
+        pkgs = import nixpkgs { inherit system; };
+      in rec {
+        packages = {
+          mojitos = pkgs.stdenv.mkDerivation rec {
+            name = "mojitos";
+            buildInputs = with pkgs; [
+              meson ninja pkg-config
+              cudaPackages.cuda_nvml_dev
+            ];
+            src = ./.;
+          };
+        };
+        devShells = {};
+      }
+    );
+}
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..9c20ed0
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,48 @@
+project('mojitos', 'c',
+    version: '0.2',
+    license: 'GPL-3.0',
+)
+
+nvml_dep = dependency('nvidia-ml')
+
+src = [
+  'lib/info_reader.c'
+, 'lib/info_reader.h'
+, 'lib/optparse.h'
+, 'src/amd_rapl.c'
+, 'src/amd_rapl.h'
+, 'src/counters.c'
+, 'src/counters.h'
+, 'src/infiniband.c'
+, 'src/infiniband.h'
+, 'src/likwid.c'
+, 'src/likwid.h'
+, 'src/load.c'
+, 'src/load.h'
+, 'src/memory.c'
+, 'src/memory_counters.c'
+, 'src/memory_counters.h'
+, 'src/memory.h'
+, 'src/memory_option.h'
+, 'src/mojitos.c'
+, 'src/network.c'
+, 'src/network.h'
+, 'src/nvidia_gpu.c'
+, 'src/nvidia_gpu.h'
+, 'src/rapl.c'
+, 'src/rapl.h'
+, 'src/sensors.h'
+, 'src/temperature.c'
+, 'src/temperature.h'
+, 'src/util.c'
+, 'src/util.h'
+]
+
+src_inc_dir = include_directories('src')
+lib_inc_dir = include_directories('lib')
+
+mojitos = executable('mojitos', src,
+    include_directories: [ src_inc_dir, lib_inc_dir ],
+    dependencies: [ nvml_dep ],
+    install: true
+)
-- 
GitLab