From 323b2407e8fe9426cd7cede5048be150b81b2a24 Mon Sep 17 00:00:00 2001 From: vidur2 Date: Wed, 4 Sep 2024 23:24:51 -0400 Subject: [PATCH 1/5] added nix flake bac --- Vidur/flake.nix | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Vidur/flake.nix diff --git a/Vidur/flake.nix b/Vidur/flake.nix new file mode 100644 index 0000000..c7a9a1c --- /dev/null +++ b/Vidur/flake.nix @@ -0,0 +1,15 @@ +{ + description = "A very basic flake"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + }; + + outputs = { self, nixpkgs }: { + + packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello; + + packages.x86_64-linux.default = self.packages.x86_64-linux.hello; + + }; +} From 2293aa4df6d195839867ee8edba45e8f32019101 Mon Sep 17 00:00:00 2001 From: vidur2 Date: Thu, 12 Sep 2024 17:29:22 -0400 Subject: [PATCH 2/5] initial --- .gitignore | 2 ++ Vidur/{ => Part-1}/CMakeLists.txt | 4 ++- Vidur/Part-1/default.nix | 10 ++++++ Vidur/Part-1/flake.nix | 34 +++++++++++++++++++++ Vidur/{ => Part-1}/include/hello_world.h | 0 Vidur/{ => Part-1}/src/hello_world.cpp | 0 Vidur/{ => Part-1}/src/main.cpp | 0 Vidur/Part-2/default.nix | 10 ++++++ Vidur/Part-2/flake.nix | 34 +++++++++++++++++++++ Vidur/Part-2/helloapp/CMakeLists.txt | 10 ++++++ Vidur/Part-2/helloapp/main.cpp | 6 ++++ Vidur/Part-2/hellolib/CMakeLists.txt | 0 Vidur/Part-2/hellolib/include/hello_world.h | 9 ++++++ Vidur/Part-2/hellolib/src/hello_world.cpp | 6 ++++ Vidur/flake.nix | 15 --------- 15 files changed, 124 insertions(+), 16 deletions(-) rename Vidur/{ => Part-1}/CMakeLists.txt (68%) create mode 100644 Vidur/Part-1/default.nix create mode 100644 Vidur/Part-1/flake.nix rename Vidur/{ => Part-1}/include/hello_world.h (100%) rename Vidur/{ => Part-1}/src/hello_world.cpp (100%) rename Vidur/{ => Part-1}/src/main.cpp (100%) create mode 100644 Vidur/Part-2/default.nix create mode 100644 Vidur/Part-2/flake.nix create mode 100644 Vidur/Part-2/helloapp/CMakeLists.txt create mode 100644 Vidur/Part-2/helloapp/main.cpp create mode 100644 Vidur/Part-2/hellolib/CMakeLists.txt create mode 100644 Vidur/Part-2/hellolib/include/hello_world.h create mode 100644 Vidur/Part-2/hellolib/src/hello_world.cpp delete mode 100644 Vidur/flake.nix diff --git a/.gitignore b/.gitignore index a155045..7b98774 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ ShangEn/build/* BenHall/lab1/build RishiB/build/* Ujaan/Lab-2/Part-1/build/* +/.vscode +Vidur/*/result diff --git a/Vidur/CMakeLists.txt b/Vidur/Part-1/CMakeLists.txt similarity index 68% rename from Vidur/CMakeLists.txt rename to Vidur/Part-1/CMakeLists.txt index 7d74d29..b35a819 100644 --- a/Vidur/CMakeLists.txt +++ b/Vidur/Part-1/CMakeLists.txt @@ -11,4 +11,6 @@ target_include_directories(helloworld_lib PUBLIC include) add_executable(HelloWorld src/main.cpp) -target_link_libraries(HelloWorld PUBLIC helloworld_lib) \ No newline at end of file +target_link_libraries(HelloWorld PUBLIC helloworld_lib) + +install(TARGETS HelloWorld DESTINATION ${CMAKE_INSTALL_BINDIR}) \ No newline at end of file diff --git a/Vidur/Part-1/default.nix b/Vidur/Part-1/default.nix new file mode 100644 index 0000000..bbf9610 --- /dev/null +++ b/Vidur/Part-1/default.nix @@ -0,0 +1,10 @@ +let + pkgs = import {}; +in +pkgs.stdenv.mkDerivation rec { + pname = "HelloWorld"; + version = "1.0.0"; + src = ./.; + + nativeBuildInputs = [ pkgs.cmake ]; +} \ No newline at end of file diff --git a/Vidur/Part-1/flake.nix b/Vidur/Part-1/flake.nix new file mode 100644 index 0000000..d1e92ea --- /dev/null +++ b/Vidur/Part-1/flake.nix @@ -0,0 +1,34 @@ +{ +#does not impact functionality +  description = "part 1 flake"; +#the requirements for the nix flake to be built, this will be more important in part 3 when not everything is local + +  inputs = { +    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; +  }; +#this defines what the nix flake will build (pretty self explanatory as outputs) + +  outputs = { self, nixpkgs }: +  let +#technically an overlay is not necessary for this specific flake, but understanding and using it now will make part 2 easier +#They will allow us to make a more complex output through the linking of two local derivations in the next part, plus it is necessary for #the workflow used by hytech +    hello_lib_overlay = final: prev: { +#this is the really important line for this part as it defines the hello_lib as the derivation defined in default.nix +      hello_lib = final.callPackage ./default.nix { }; +    }; +#this list would be used to add multiple overlays into the pkg set, but in this case theres only one, this is an important definition for the #in part of the flake +    my_overlays = [ hello_lib_overlay ]; + + +    pkgs = import nixpkgs { +      system = "x86_64-linux"; +#another important definition for the in part of flake, which will allow us to add to the nix package set, which is the point of the flake +      overlays = [ self.overlays.default ]; +    };   +  in +  {       +    packages.x86_64-linux.default = pkgs.hello_lib; +#this is where the overlays compiled into the list would actually be added to the package set +    overlays.default = nixpkgs.lib.composeManyExtensions my_overlays; +  }; +} \ No newline at end of file diff --git a/Vidur/include/hello_world.h b/Vidur/Part-1/include/hello_world.h similarity index 100% rename from Vidur/include/hello_world.h rename to Vidur/Part-1/include/hello_world.h diff --git a/Vidur/src/hello_world.cpp b/Vidur/Part-1/src/hello_world.cpp similarity index 100% rename from Vidur/src/hello_world.cpp rename to Vidur/Part-1/src/hello_world.cpp diff --git a/Vidur/src/main.cpp b/Vidur/Part-1/src/main.cpp similarity index 100% rename from Vidur/src/main.cpp rename to Vidur/Part-1/src/main.cpp diff --git a/Vidur/Part-2/default.nix b/Vidur/Part-2/default.nix new file mode 100644 index 0000000..bbf9610 --- /dev/null +++ b/Vidur/Part-2/default.nix @@ -0,0 +1,10 @@ +let + pkgs = import {}; +in +pkgs.stdenv.mkDerivation rec { + pname = "HelloWorld"; + version = "1.0.0"; + src = ./.; + + nativeBuildInputs = [ pkgs.cmake ]; +} \ No newline at end of file diff --git a/Vidur/Part-2/flake.nix b/Vidur/Part-2/flake.nix new file mode 100644 index 0000000..d1e92ea --- /dev/null +++ b/Vidur/Part-2/flake.nix @@ -0,0 +1,34 @@ +{ +#does not impact functionality +  description = "part 1 flake"; +#the requirements for the nix flake to be built, this will be more important in part 3 when not everything is local + +  inputs = { +    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; +  }; +#this defines what the nix flake will build (pretty self explanatory as outputs) + +  outputs = { self, nixpkgs }: +  let +#technically an overlay is not necessary for this specific flake, but understanding and using it now will make part 2 easier +#They will allow us to make a more complex output through the linking of two local derivations in the next part, plus it is necessary for #the workflow used by hytech +    hello_lib_overlay = final: prev: { +#this is the really important line for this part as it defines the hello_lib as the derivation defined in default.nix +      hello_lib = final.callPackage ./default.nix { }; +    }; +#this list would be used to add multiple overlays into the pkg set, but in this case theres only one, this is an important definition for the #in part of the flake +    my_overlays = [ hello_lib_overlay ]; + + +    pkgs = import nixpkgs { +      system = "x86_64-linux"; +#another important definition for the in part of flake, which will allow us to add to the nix package set, which is the point of the flake +      overlays = [ self.overlays.default ]; +    };   +  in +  {       +    packages.x86_64-linux.default = pkgs.hello_lib; +#this is where the overlays compiled into the list would actually be added to the package set +    overlays.default = nixpkgs.lib.composeManyExtensions my_overlays; +  }; +} \ No newline at end of file diff --git a/Vidur/Part-2/helloapp/CMakeLists.txt b/Vidur/Part-2/helloapp/CMakeLists.txt new file mode 100644 index 0000000..d8669c0 --- /dev/null +++ b/Vidur/Part-2/helloapp/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.15...3.30) + +project( + Lab1FollowAlong + VERSION 1.0 + LANGUAGES CXX) + +add_library(helloworld_lib STATIC src/hello_world.cpp) + +target_include_directories(helloworld_lib PUBLIC include) \ No newline at end of file diff --git a/Vidur/Part-2/helloapp/main.cpp b/Vidur/Part-2/helloapp/main.cpp new file mode 100644 index 0000000..69873b3 --- /dev/null +++ b/Vidur/Part-2/helloapp/main.cpp @@ -0,0 +1,6 @@ +#include "hello_world.h" + +int main(void) { + Hello hello; + hello.hello_world(); +} \ No newline at end of file diff --git a/Vidur/Part-2/hellolib/CMakeLists.txt b/Vidur/Part-2/hellolib/CMakeLists.txt new file mode 100644 index 0000000..e69de29 diff --git a/Vidur/Part-2/hellolib/include/hello_world.h b/Vidur/Part-2/hellolib/include/hello_world.h new file mode 100644 index 0000000..eb32732 --- /dev/null +++ b/Vidur/Part-2/hellolib/include/hello_world.h @@ -0,0 +1,9 @@ +#ifndef _HELLO_WORLD_CLASS_H_ +#define _HELLO_WORLD_CLASS_H_ + +class Hello { + public: + void hello_world(); +}; + +#endif \ No newline at end of file diff --git a/Vidur/Part-2/hellolib/src/hello_world.cpp b/Vidur/Part-2/hellolib/src/hello_world.cpp new file mode 100644 index 0000000..c69b6f2 --- /dev/null +++ b/Vidur/Part-2/hellolib/src/hello_world.cpp @@ -0,0 +1,6 @@ +#include "hello_world.h" +#include + +void Hello::hello_world() { + std::cout << "Hello, World!\n"; +} \ No newline at end of file diff --git a/Vidur/flake.nix b/Vidur/flake.nix deleted file mode 100644 index c7a9a1c..0000000 --- a/Vidur/flake.nix +++ /dev/null @@ -1,15 +0,0 @@ -{ - description = "A very basic flake"; - - inputs = { - nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; - }; - - outputs = { self, nixpkgs }: { - - packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello; - - packages.x86_64-linux.default = self.packages.x86_64-linux.hello; - - }; -} From a77d40738a9472c49019b90969c32f56a15e8dcb Mon Sep 17 00:00:00 2001 From: vidur2 Date: Thu, 12 Sep 2024 17:40:11 -0400 Subject: [PATCH 3/5] finished l2 p1 --- Vidur/Part-2/default.nix | 10 ------ Vidur/Part-2/flake.nix | 34 --------------------- Vidur/Part-2/helloapp/CMakeLists.txt | 10 ------ Vidur/Part-2/helloapp/main.cpp | 6 ---- Vidur/Part-2/hellolib/CMakeLists.txt | 0 Vidur/Part-2/hellolib/include/hello_world.h | 9 ------ Vidur/Part-2/hellolib/src/hello_world.cpp | 6 ---- 7 files changed, 75 deletions(-) delete mode 100644 Vidur/Part-2/default.nix delete mode 100644 Vidur/Part-2/flake.nix delete mode 100644 Vidur/Part-2/helloapp/CMakeLists.txt delete mode 100644 Vidur/Part-2/helloapp/main.cpp delete mode 100644 Vidur/Part-2/hellolib/CMakeLists.txt delete mode 100644 Vidur/Part-2/hellolib/include/hello_world.h delete mode 100644 Vidur/Part-2/hellolib/src/hello_world.cpp diff --git a/Vidur/Part-2/default.nix b/Vidur/Part-2/default.nix deleted file mode 100644 index bbf9610..0000000 --- a/Vidur/Part-2/default.nix +++ /dev/null @@ -1,10 +0,0 @@ -let - pkgs = import {}; -in -pkgs.stdenv.mkDerivation rec { - pname = "HelloWorld"; - version = "1.0.0"; - src = ./.; - - nativeBuildInputs = [ pkgs.cmake ]; -} \ No newline at end of file diff --git a/Vidur/Part-2/flake.nix b/Vidur/Part-2/flake.nix deleted file mode 100644 index d1e92ea..0000000 --- a/Vidur/Part-2/flake.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ -#does not impact functionality -  description = "part 1 flake"; -#the requirements for the nix flake to be built, this will be more important in part 3 when not everything is local - -  inputs = { -    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; -  }; -#this defines what the nix flake will build (pretty self explanatory as outputs) - -  outputs = { self, nixpkgs }: -  let -#technically an overlay is not necessary for this specific flake, but understanding and using it now will make part 2 easier -#They will allow us to make a more complex output through the linking of two local derivations in the next part, plus it is necessary for #the workflow used by hytech -    hello_lib_overlay = final: prev: { -#this is the really important line for this part as it defines the hello_lib as the derivation defined in default.nix -      hello_lib = final.callPackage ./default.nix { }; -    }; -#this list would be used to add multiple overlays into the pkg set, but in this case theres only one, this is an important definition for the #in part of the flake -    my_overlays = [ hello_lib_overlay ]; - - -    pkgs = import nixpkgs { -      system = "x86_64-linux"; -#another important definition for the in part of flake, which will allow us to add to the nix package set, which is the point of the flake -      overlays = [ self.overlays.default ]; -    };   -  in -  {       -    packages.x86_64-linux.default = pkgs.hello_lib; -#this is where the overlays compiled into the list would actually be added to the package set -    overlays.default = nixpkgs.lib.composeManyExtensions my_overlays; -  }; -} \ No newline at end of file diff --git a/Vidur/Part-2/helloapp/CMakeLists.txt b/Vidur/Part-2/helloapp/CMakeLists.txt deleted file mode 100644 index d8669c0..0000000 --- a/Vidur/Part-2/helloapp/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -cmake_minimum_required(VERSION 3.15...3.30) - -project( - Lab1FollowAlong - VERSION 1.0 - LANGUAGES CXX) - -add_library(helloworld_lib STATIC src/hello_world.cpp) - -target_include_directories(helloworld_lib PUBLIC include) \ No newline at end of file diff --git a/Vidur/Part-2/helloapp/main.cpp b/Vidur/Part-2/helloapp/main.cpp deleted file mode 100644 index 69873b3..0000000 --- a/Vidur/Part-2/helloapp/main.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "hello_world.h" - -int main(void) { - Hello hello; - hello.hello_world(); -} \ No newline at end of file diff --git a/Vidur/Part-2/hellolib/CMakeLists.txt b/Vidur/Part-2/hellolib/CMakeLists.txt deleted file mode 100644 index e69de29..0000000 diff --git a/Vidur/Part-2/hellolib/include/hello_world.h b/Vidur/Part-2/hellolib/include/hello_world.h deleted file mode 100644 index eb32732..0000000 --- a/Vidur/Part-2/hellolib/include/hello_world.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _HELLO_WORLD_CLASS_H_ -#define _HELLO_WORLD_CLASS_H_ - -class Hello { - public: - void hello_world(); -}; - -#endif \ No newline at end of file diff --git a/Vidur/Part-2/hellolib/src/hello_world.cpp b/Vidur/Part-2/hellolib/src/hello_world.cpp deleted file mode 100644 index c69b6f2..0000000 --- a/Vidur/Part-2/hellolib/src/hello_world.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "hello_world.h" -#include - -void Hello::hello_world() { - std::cout << "Hello, World!\n"; -} \ No newline at end of file From a94f3b1f488e97608a882c1f95569cc00c7ed87b Mon Sep 17 00:00:00 2001 From: vidur2 Date: Thu, 12 Sep 2024 18:17:52 -0400 Subject: [PATCH 4/5] finished lab part 2 --- Vidur/Part-2/default.nix | 12 +++++ Vidur/Part-2/flake.nix | 34 +++++++++++++ Vidur/Part-2/helloapp/CMakeLists.txt | 10 ++++ Vidur/Part-2/helloapp/main.cpp | 6 +++ Vidur/Part-2/hellolib.nix | 9 ++++ Vidur/Part-2/hellolib/CMakeLists.txt | 49 +++++++++++++++++++ Vidur/Part-2/hellolib/cmake/hellolib.cmake.in | 10 ++++ Vidur/Part-2/hellolib/include/hello_world.h | 9 ++++ Vidur/Part-2/hellolib/src/hello_world.cpp | 6 +++ 9 files changed, 145 insertions(+) create mode 100644 Vidur/Part-2/default.nix create mode 100644 Vidur/Part-2/flake.nix create mode 100644 Vidur/Part-2/helloapp/CMakeLists.txt create mode 100644 Vidur/Part-2/helloapp/main.cpp create mode 100644 Vidur/Part-2/hellolib.nix create mode 100644 Vidur/Part-2/hellolib/CMakeLists.txt create mode 100644 Vidur/Part-2/hellolib/cmake/hellolib.cmake.in create mode 100644 Vidur/Part-2/hellolib/include/hello_world.h create mode 100644 Vidur/Part-2/hellolib/src/hello_world.cpp diff --git a/Vidur/Part-2/default.nix b/Vidur/Part-2/default.nix new file mode 100644 index 0000000..3ea0036 --- /dev/null +++ b/Vidur/Part-2/default.nix @@ -0,0 +1,12 @@ +let + pkgs = import {}; + hellolib = pkgs.callPackage ./hellolib.nix {}; +in +pkgs.stdenv.mkDerivation rec { + pname = "HelloWorld"; + version = "1.0.0"; + src = ./helloapp; + + nativeBuildInputs = [ pkgs.cmake ]; + buildInputs = [ hellolib ]; +} \ No newline at end of file diff --git a/Vidur/Part-2/flake.nix b/Vidur/Part-2/flake.nix new file mode 100644 index 0000000..d1e92ea --- /dev/null +++ b/Vidur/Part-2/flake.nix @@ -0,0 +1,34 @@ +{ +#does not impact functionality +  description = "part 1 flake"; +#the requirements for the nix flake to be built, this will be more important in part 3 when not everything is local + +  inputs = { +    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; +  }; +#this defines what the nix flake will build (pretty self explanatory as outputs) + +  outputs = { self, nixpkgs }: +  let +#technically an overlay is not necessary for this specific flake, but understanding and using it now will make part 2 easier +#They will allow us to make a more complex output through the linking of two local derivations in the next part, plus it is necessary for #the workflow used by hytech +    hello_lib_overlay = final: prev: { +#this is the really important line for this part as it defines the hello_lib as the derivation defined in default.nix +      hello_lib = final.callPackage ./default.nix { }; +    }; +#this list would be used to add multiple overlays into the pkg set, but in this case theres only one, this is an important definition for the #in part of the flake +    my_overlays = [ hello_lib_overlay ]; + + +    pkgs = import nixpkgs { +      system = "x86_64-linux"; +#another important definition for the in part of flake, which will allow us to add to the nix package set, which is the point of the flake +      overlays = [ self.overlays.default ]; +    };   +  in +  {       +    packages.x86_64-linux.default = pkgs.hello_lib; +#this is where the overlays compiled into the list would actually be added to the package set +    overlays.default = nixpkgs.lib.composeManyExtensions my_overlays; +  }; +} \ No newline at end of file diff --git a/Vidur/Part-2/helloapp/CMakeLists.txt b/Vidur/Part-2/helloapp/CMakeLists.txt new file mode 100644 index 0000000..6d4ce49 --- /dev/null +++ b/Vidur/Part-2/helloapp/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.24) +project(hello_app LANGUAGES CXX) + +find_package(hellolib REQUIRED) + +add_executable(hello_app main.cpp) + +target_link_libraries(hello_app PUBLIC hellolib::hellolib) + +install(TARGETS hello_app DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) \ No newline at end of file diff --git a/Vidur/Part-2/helloapp/main.cpp b/Vidur/Part-2/helloapp/main.cpp new file mode 100644 index 0000000..69873b3 --- /dev/null +++ b/Vidur/Part-2/helloapp/main.cpp @@ -0,0 +1,6 @@ +#include "hello_world.h" + +int main(void) { + Hello hello; + hello.hello_world(); +} \ No newline at end of file diff --git a/Vidur/Part-2/hellolib.nix b/Vidur/Part-2/hellolib.nix new file mode 100644 index 0000000..2826dcb --- /dev/null +++ b/Vidur/Part-2/hellolib.nix @@ -0,0 +1,9 @@ +{ stdenv, cmake }: + +stdenv.mkDerivation rec { + pname = "hellolib"; + version = "1.0.0"; + src = ./hellolib; # Path to your source directory + + nativeBuildInputs = [ cmake ]; +} \ No newline at end of file diff --git a/Vidur/Part-2/hellolib/CMakeLists.txt b/Vidur/Part-2/hellolib/CMakeLists.txt new file mode 100644 index 0000000..08bc948 --- /dev/null +++ b/Vidur/Part-2/hellolib/CMakeLists.txt @@ -0,0 +1,49 @@ +cmake_minimum_required(VERSION 3.24) +project(hellolib LANGUAGES CXX) + +add_library(hellolib STATIC src/hello_world.cpp) + +# be sure that you use the generator expressions +# ($ + $ +) + +include(GNUInstallDirs) +install(TARGETS hellolib + EXPORT hellolibTargets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + PUBLIC_HEADER DESTINATION include +) + +# NAMESPACE sets the namespace that your target will live within. +# you can have multiple targets under the same namespace +install(EXPORT hellolibTargets + FILE hellolibTargets.cmake + NAMESPACE hellolib:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/hellolib +) + +# this looks for your .cmake.in file that you created in step 1. +# if you set the directory differently you may need to handle this differently +include(CMakePackageConfigHelpers) +configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/hellolib.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/hellolibConfig.cmake" + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/hellolib +) + +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/hellolibConfig.cmake" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/hellolib +) + + +# actually install your header files +install( + DIRECTORY include/ + DESTINATION ${CMAKE_INSTALL_PREFIX}/include + FILES_MATCHING PATTERN "*.h*" +) \ No newline at end of file diff --git a/Vidur/Part-2/hellolib/cmake/hellolib.cmake.in b/Vidur/Part-2/hellolib/cmake/hellolib.cmake.in new file mode 100644 index 0000000..08c5275 --- /dev/null +++ b/Vidur/Part-2/hellolib/cmake/hellolib.cmake.in @@ -0,0 +1,10 @@ +@PACKAGE_INIT@ + +# if you have find_package calls, use find_dependency() here with the package +# that you need to find_package() for. this handles transitive dep finding so +# your downstream cmake doesnt have to `find_package()` it instead gets done +# upon package configuration + +include("${CMAKE_CURRENT_LIST_DIR}/hellolibTargets.cmake") + +check_required_components(hellolib) \ No newline at end of file diff --git a/Vidur/Part-2/hellolib/include/hello_world.h b/Vidur/Part-2/hellolib/include/hello_world.h new file mode 100644 index 0000000..eb32732 --- /dev/null +++ b/Vidur/Part-2/hellolib/include/hello_world.h @@ -0,0 +1,9 @@ +#ifndef _HELLO_WORLD_CLASS_H_ +#define _HELLO_WORLD_CLASS_H_ + +class Hello { + public: + void hello_world(); +}; + +#endif \ No newline at end of file diff --git a/Vidur/Part-2/hellolib/src/hello_world.cpp b/Vidur/Part-2/hellolib/src/hello_world.cpp new file mode 100644 index 0000000..c69b6f2 --- /dev/null +++ b/Vidur/Part-2/hellolib/src/hello_world.cpp @@ -0,0 +1,6 @@ +#include "hello_world.h" +#include + +void Hello::hello_world() { + std::cout << "Hello, World!\n"; +} \ No newline at end of file From ae182448905f0c9087f31b2948c9bdf6f5e7888c Mon Sep 17 00:00:00 2001 From: vidur2 Date: Thu, 12 Sep 2024 20:02:24 -0400 Subject: [PATCH 5/5] fixed flake.nix + fixed part 3 --- Vidur/Part-1/default.nix | 13 +++-- Vidur/Part-1/flake.lock | 27 +++++++++++ Vidur/Part-1/flake.nix | 49 ++++++++----------- Vidur/Part-2/default.nix | 18 ++++--- Vidur/Part-2/flake.lock | 27 +++++++++++ Vidur/Part-2/flake.nix | 49 ++++++++----------- Vidur/Part-3/CMakeLists.txt | 10 ++++ Vidur/Part-3/default.nix | 10 ++++ Vidur/Part-3/flake.lock | 96 +++++++++++++++++++++++++++++++++++++ Vidur/Part-3/flake.nix | 25 ++++++++++ Vidur/Part-3/main.cpp | 6 +++ 11 files changed, 255 insertions(+), 75 deletions(-) create mode 100644 Vidur/Part-1/flake.lock create mode 100644 Vidur/Part-2/flake.lock create mode 100644 Vidur/Part-3/CMakeLists.txt create mode 100644 Vidur/Part-3/default.nix create mode 100644 Vidur/Part-3/flake.lock create mode 100644 Vidur/Part-3/flake.nix create mode 100644 Vidur/Part-3/main.cpp diff --git a/Vidur/Part-1/default.nix b/Vidur/Part-1/default.nix index bbf9610..4853960 100644 --- a/Vidur/Part-1/default.nix +++ b/Vidur/Part-1/default.nix @@ -1,10 +1,9 @@ -let - pkgs = import {}; -in -pkgs.stdenv.mkDerivation rec { - pname = "HelloWorld"; +{ stdenv, cmake }: + +stdenv.mkDerivation rec { + pname = "helloapp"; version = "1.0.0"; - src = ./.; + src = ./.; # Path to your source directory - nativeBuildInputs = [ pkgs.cmake ]; + nativeBuildInputs = [ cmake ]; } \ No newline at end of file diff --git a/Vidur/Part-1/flake.lock b/Vidur/Part-1/flake.lock new file mode 100644 index 0000000..db42797 --- /dev/null +++ b/Vidur/Part-1/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1725983898, + "narHash": "sha256-4b3A9zPpxAxLnkF9MawJNHDtOOl6ruL0r6Og1TEDGCE=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "1355a0cbfeac61d785b7183c0caaec1f97361b43", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/Vidur/Part-1/flake.nix b/Vidur/Part-1/flake.nix index d1e92ea..4a8b32c 100644 --- a/Vidur/Part-1/flake.nix +++ b/Vidur/Part-1/flake.nix @@ -1,34 +1,25 @@ { -#does not impact functionality -  description = "part 1 flake"; -#the requirements for the nix flake to be built, this will be more important in part 3 when not everything is local + description = "part 1 flake"; -  inputs = { -    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; -  }; -#this defines what the nix flake will build (pretty self explanatory as outputs) + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + }; + outputs = { self, nixpkgs }: + let + hellolib_overlay = final: prev: { + hellolib = final.callPackage ./default.nix { }; + }; + my_overlays = [ hellolib_overlay ]; -  outputs = { self, nixpkgs }: -  let -#technically an overlay is not necessary for this specific flake, but understanding and using it now will make part 2 easier -#They will allow us to make a more complex output through the linking of two local derivations in the next part, plus it is necessary for #the workflow used by hytech -    hello_lib_overlay = final: prev: { -#this is the really important line for this part as it defines the hello_lib as the derivation defined in default.nix -      hello_lib = final.callPackage ./default.nix { }; -    }; -#this list would be used to add multiple overlays into the pkg set, but in this case theres only one, this is an important definition for the #in part of the flake -    my_overlays = [ hello_lib_overlay ]; - -    pkgs = import nixpkgs { -      system = "x86_64-linux"; -#another important definition for the in part of flake, which will allow us to add to the nix package set, which is the point of the flake -      overlays = [ self.overlays.default ]; -    };   -  in -  {       -    packages.x86_64-linux.default = pkgs.hello_lib; -#this is where the overlays compiled into the list would actually be added to the package set -    overlays.default = nixpkgs.lib.composeManyExtensions my_overlays; -  }; + pkgs = import nixpkgs { + system = "aarch64-darwin"; + overlays = [ self.overlays.default ]; + }; + in + { + packages.x86_64-linux.default = pkgs.hellolib; + packages.aarch64-darwin.default = pkgs.hellolib; + overlays.default = nixpkgs.lib.composeManyExtensions my_overlays; + }; } \ No newline at end of file diff --git a/Vidur/Part-2/default.nix b/Vidur/Part-2/default.nix index 3ea0036..9ec75e5 100644 --- a/Vidur/Part-2/default.nix +++ b/Vidur/Part-2/default.nix @@ -1,12 +1,10 @@ -let - pkgs = import {}; - hellolib = pkgs.callPackage ./hellolib.nix {}; -in -pkgs.stdenv.mkDerivation rec { - pname = "HelloWorld"; - version = "1.0.0"; - src = ./helloapp; +{ stdenv, cmake, hellolib }: - nativeBuildInputs = [ pkgs.cmake ]; - buildInputs = [ hellolib ]; +stdenv.mkDerivation rec { + pname = "helloapp"; + version = "1.0.0"; + src = ./helloapp; # Path to your source directory + + nativeBuildInputs = [ cmake ]; + buildInputs = [hellolib]; } \ No newline at end of file diff --git a/Vidur/Part-2/flake.lock b/Vidur/Part-2/flake.lock new file mode 100644 index 0000000..db42797 --- /dev/null +++ b/Vidur/Part-2/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1725983898, + "narHash": "sha256-4b3A9zPpxAxLnkF9MawJNHDtOOl6ruL0r6Og1TEDGCE=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "1355a0cbfeac61d785b7183c0caaec1f97361b43", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/Vidur/Part-2/flake.nix b/Vidur/Part-2/flake.nix index d1e92ea..b7ba019 100644 --- a/Vidur/Part-2/flake.nix +++ b/Vidur/Part-2/flake.nix @@ -1,34 +1,25 @@ { -#does not impact functionality -  description = "part 1 flake"; -#the requirements for the nix flake to be built, this will be more important in part 3 when not everything is local + description = "part 1 flake"; -  inputs = { -    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; -  }; -#this defines what the nix flake will build (pretty self explanatory as outputs) + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + }; + outputs = { self, nixpkgs }: + let + helloapp_overlay = final: prev: rec { + hellolib = final.callPackage ./hellolib.nix { }; + helloapp = final.callPackage ./default.nix { inherit hellolib; }; + }; + my_overlays = [ helloapp_overlay ]; -  outputs = { self, nixpkgs }: -  let -#technically an overlay is not necessary for this specific flake, but understanding and using it now will make part 2 easier -#They will allow us to make a more complex output through the linking of two local derivations in the next part, plus it is necessary for #the workflow used by hytech -    hello_lib_overlay = final: prev: { -#this is the really important line for this part as it defines the hello_lib as the derivation defined in default.nix -      hello_lib = final.callPackage ./default.nix { }; -    }; -#this list would be used to add multiple overlays into the pkg set, but in this case theres only one, this is an important definition for the #in part of the flake -    my_overlays = [ hello_lib_overlay ]; - -    pkgs = import nixpkgs { -      system = "x86_64-linux"; -#another important definition for the in part of flake, which will allow us to add to the nix package set, which is the point of the flake -      overlays = [ self.overlays.default ]; -    };   -  in -  {       -    packages.x86_64-linux.default = pkgs.hello_lib; -#this is where the overlays compiled into the list would actually be added to the package set -    overlays.default = nixpkgs.lib.composeManyExtensions my_overlays; -  }; + pkgs = import nixpkgs { + system = "aarch64-darwin"; + overlays = [ helloapp_overlay ]; + }; + in + { + packages.aarch64-darwin.default = pkgs.helloapp; + overlays.default = nixpkgs.lib.composeManyExtensions my_overlays; + }; } \ No newline at end of file diff --git a/Vidur/Part-3/CMakeLists.txt b/Vidur/Part-3/CMakeLists.txt new file mode 100644 index 0000000..6d4ce49 --- /dev/null +++ b/Vidur/Part-3/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.24) +project(hello_app LANGUAGES CXX) + +find_package(hellolib REQUIRED) + +add_executable(hello_app main.cpp) + +target_link_libraries(hello_app PUBLIC hellolib::hellolib) + +install(TARGETS hello_app DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) \ No newline at end of file diff --git a/Vidur/Part-3/default.nix b/Vidur/Part-3/default.nix new file mode 100644 index 0000000..758f635 --- /dev/null +++ b/Vidur/Part-3/default.nix @@ -0,0 +1,10 @@ +{ stdenv, cmake, hellolib }: + +stdenv.mkDerivation rec { + pname = "helloapp"; + version = "1.0.0"; + src = ./.; # Path to your source directory + + nativeBuildInputs = [ cmake ]; + buildInputs = [hellolib]; +} \ No newline at end of file diff --git a/Vidur/Part-3/flake.lock b/Vidur/Part-3/flake.lock new file mode 100644 index 0000000..f01a6da --- /dev/null +++ b/Vidur/Part-3/flake.lock @@ -0,0 +1,96 @@ +{ + "nodes": { + "hellolib": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1726185169, + "narHash": "sha256-LdZb724SpbPji9rn4JTip4Dmzxc/9wxiF0W9ON0lbsQ=", + "owner": "vidur2", + "repo": "vidur-lab2", + "rev": "1978e383317785127fbf7ffdc553f13b1d3c83ad", + "type": "github" + }, + "original": { + "owner": "vidur2", + "repo": "vidur-lab2", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1704290814, + "narHash": "sha256-LWvKHp7kGxk/GEtlrGYV68qIvPHkU9iToomNFGagixU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "70bdadeb94ffc8806c0570eb5c2695ad29f0e421", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1704290814, + "narHash": "sha256-LWvKHp7kGxk/GEtlrGYV68qIvPHkU9iToomNFGagixU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "70bdadeb94ffc8806c0570eb5c2695ad29f0e421", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "hellolib": "hellolib", + "nixpkgs": "nixpkgs_2", + "utils": "utils" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/Vidur/Part-3/flake.nix b/Vidur/Part-3/flake.nix new file mode 100644 index 0000000..ba497d4 --- /dev/null +++ b/Vidur/Part-3/flake.nix @@ -0,0 +1,25 @@ +{ + description = "part 1 flake"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05"; + utils.url = "github:numtide/flake-utils"; + hellolib.url = "github:vidur2/vidur-lab2"; + }; + + outputs = { self, nixpkgs, hellolib, utils }: + let + pkgs = import nixpkgs { + system = "aarch64-darwin"; + overlays = [ hellolib.overlays.default ]; + }; + + + + + in + { + packages.aarch64-darwin.default = pkgs.callPackage ./default.nix { + }; + }; +} \ No newline at end of file diff --git a/Vidur/Part-3/main.cpp b/Vidur/Part-3/main.cpp new file mode 100644 index 0000000..69873b3 --- /dev/null +++ b/Vidur/Part-3/main.cpp @@ -0,0 +1,6 @@ +#include "hello_world.h" + +int main(void) { + Hello hello; + hello.hello_world(); +} \ No newline at end of file