From 858f4937023925f9056879d3639d6144fbdac292 Mon Sep 17 00:00:00 2001
From: Guilhem Saurel <guilhem.saurel@laas.fr>
Date: Fri, 28 Jun 2024 15:45:16 +0200
Subject: [PATCH] nix: package

---
 default.nix | 38 ++++++++++++++++++++++++++++++++++++++
 flake.lock  | 41 ++++++++++++++++++++++++++++-------------
 flake.nix   | 45 +++++++++++++++++++++------------------------
 3 files changed, 87 insertions(+), 37 deletions(-)
 create mode 100644 default.nix

diff --git a/default.nix b/default.nix
new file mode 100644
index 0000000..669890e
--- /dev/null
+++ b/default.nix
@@ -0,0 +1,38 @@
+{
+  lib,
+  stdenv,
+  fetchFromGitHub,
+  cmake,
+  hpp-util,
+}:
+
+stdenv.mkDerivation {
+  pname = "hpp-statistics";
+  version = "5.0.0";
+
+  src = lib.fileset.toSource {
+    root = ./.;
+    fileset = lib.fileset.unions [
+      ./CMakeLists.txt
+      ./doc
+      ./include
+      ./package.xml
+      ./src
+      ./tests
+    ];
+  };
+
+  strictDeps = true;
+
+  nativeBuildInputs = [ cmake ];
+  propagatedBuildInputs = [ hpp-util ];
+
+  doCheck = true;
+
+  meta = {
+    description = "Classes for doing statistics";
+    homepage = "https://github.com/humanoid-path-planner/hpp-statistics";
+    license = lib.licenses.bsd2;
+    maintainers = [ lib.maintainers.nim65s ];
+  };
+}
diff --git a/flake.lock b/flake.lock
index 5ac9fdc..2095685 100644
--- a/flake.lock
+++ b/flake.lock
@@ -2,7 +2,9 @@
   "nodes": {
     "flake-parts": {
       "inputs": {
-        "nixpkgs-lib": "nixpkgs-lib"
+        "nixpkgs-lib": [
+          "nixpkgs"
+        ]
       },
       "locked": {
         "lastModified": 1717285511,
@@ -18,6 +20,30 @@
         "type": "github"
       }
     },
+    "hpp-util": {
+      "inputs": {
+        "flake-parts": [
+          "flake-parts"
+        ],
+        "nixpkgs": [
+          "nixpkgs"
+        ]
+      },
+      "locked": {
+        "lastModified": 1719580825,
+        "narHash": "sha256-trfl8A+P7a1gnACnTXNK98TYWWDAOM3PKfkXxpC3X/8=",
+        "owner": "humanoid-path-planner",
+        "repo": "hpp-util",
+        "rev": "0504f15818a92c7a257cd6b60cd8b6092bd6dbfa",
+        "type": "github"
+      },
+      "original": {
+        "owner": "humanoid-path-planner",
+        "ref": "release/5.1.0",
+        "repo": "hpp-util",
+        "type": "github"
+      }
+    },
     "nixpkgs": {
       "locked": {
         "lastModified": 1719575122,
@@ -34,21 +60,10 @@
         "type": "github"
       }
     },
-    "nixpkgs-lib": {
-      "locked": {
-        "lastModified": 1717284937,
-        "narHash": "sha256-lIbdfCsf8LMFloheeE6N31+BMIeixqyQWbSr2vk79EQ=",
-        "type": "tarball",
-        "url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz"
-      },
-      "original": {
-        "type": "tarball",
-        "url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz"
-      }
-    },
     "root": {
       "inputs": {
         "flake-parts": "flake-parts",
+        "hpp-util": "hpp-util",
         "nixpkgs": "nixpkgs"
       }
     }
diff --git a/flake.nix b/flake.nix
index 94c479c..180b9ee 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,21 +1,28 @@
 {
-  description = "Description for the project";
+  description = "Classes for doing statistics";
+
+  nixConfig = {
+    extra-substituters = [ "https://gepetto.cachix.org" ];
+    extra-trusted-public-keys = [ "gepetto.cachix.org-1:toswMl31VewC0jGkN6+gOelO2Yom0SOHzPwJMY2XiDY=" ];
+  };
 
   inputs = {
-    flake-parts.url = "github:hercules-ci/flake-parts";
     nixpkgs.url = "github:nim65s/nixpkgs/gepetto";
+    flake-parts = {
+      url = "github:hercules-ci/flake-parts";
+      inputs.nixpkgs-lib.follows = "nixpkgs";
+    };
+    hpp-util = {
+      url = "github:humanoid-path-planner/hpp-util/release/5.1.0";
+      inputs.nixpkgs.follows = "nixpkgs";
+      inputs.flake-parts.follows = "flake-parts";
+    };
   };
 
   outputs =
     inputs@{ flake-parts, ... }:
     flake-parts.lib.mkFlake { inherit inputs; } {
-      imports = [
-        # To import a flake module
-        # 1. Add foo to inputs
-        # 2. Add foo as a parameter to the outputs function
-        # 3. Add here: foo.flakeModule
-
-      ];
+      imports = [ ];
       systems = [
         "x86_64-linux"
         "aarch64-linux"
@@ -24,26 +31,16 @@
       ];
       perSystem =
         {
-          config,
           self',
-          inputs',
-          pkgs,
           system,
+          pkgs,
           ...
         }:
         {
-          # Per-system attributes can be defined here. The self' and inputs'
-          # module parameters provide easy access to attributes of the same
-          # system.
-
-          # Equivalent to  inputs'.nixpkgs.legacyPackages.hello;
-          packages.default = pkgs.hello;
+          packages.default = pkgs.callPackage ./. {
+            hpp-util = inputs.hpp-util.packages.${system}.default;
+          };
+          devShells.default = pkgs.mkShell { inputsFrom = [ self'.packages.default ]; };
         };
-      flake = {
-        # The usual flake attributes can be defined here, including system-
-        # agnostic ones like nixosModule and system-enumerating ones, although
-        # those are more easily expressed in perSystem.
-
-      };
     };
 }
-- 
GitLab