diff --git a/dhruv/lab1/CMakeLists.txt b/dhruv/lab1/CMakeLists.txt new file mode 100644 index 0000000..430fdaf --- /dev/null +++ b/dhruv/lab1/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.15...3.30) +project(part1 LANGUAGES CXX) +add_executable(test src/main.cpp) \ No newline at end of file diff --git a/dhruv/lab1/src/main.cpp b/dhruv/lab1/src/main.cpp new file mode 100644 index 0000000..28d35bc --- /dev/null +++ b/dhruv/lab1/src/main.cpp @@ -0,0 +1,6 @@ +#include + +int main() +{ + std::cout << "Hello, World!\n"; +} \ No newline at end of file diff --git a/dhruv/lab1p2/CMakeLists.txt b/dhruv/lab1p2/CMakeLists.txt new file mode 100644 index 0000000..1fb1a36 --- /dev/null +++ b/dhruv/lab1p2/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15...3.30) +project(lab1p2 LANGUAGES CXX) + +add_library(part2lib SHARED src/hello_world.cpp) +target_include_directories(part2lib PUBLIC include) + +add_executable(part2 src/main.cpp) +target_link_libraries(part2 PUBLIC part2lib) \ No newline at end of file diff --git a/dhruv/lab1p2/include/hello_world.hpp b/dhruv/lab1p2/include/hello_world.hpp new file mode 100644 index 0000000..a6201c0 --- /dev/null +++ b/dhruv/lab1p2/include/hello_world.hpp @@ -0,0 +1,14 @@ +#ifndef HelloWorld +#define HelloWorld +#include + +class HelloWorldLib +{ + public: + HelloWorldLib() = default; + void hello(); + +}; + +#endif + diff --git a/dhruv/lab1p2/src/hello_world.cpp b/dhruv/lab1p2/src/hello_world.cpp new file mode 100644 index 0000000..82fed0c --- /dev/null +++ b/dhruv/lab1p2/src/hello_world.cpp @@ -0,0 +1,6 @@ +#include +#include + +void HelloWorldLib::hello() { + std::cout << "Hello, World again\n"; +} \ No newline at end of file diff --git a/dhruv/lab1p2/src/main.cpp b/dhruv/lab1p2/src/main.cpp new file mode 100644 index 0000000..11a2c1c --- /dev/null +++ b/dhruv/lab1p2/src/main.cpp @@ -0,0 +1,8 @@ +#include + +int main() { + HelloWorldLib obj; + obj.hello(); + + return 0; +} \ No newline at end of file diff --git a/dhruv/lab2p1/.gitignore b/dhruv/lab2p1/.gitignore new file mode 100644 index 0000000..9b4c10b --- /dev/null +++ b/dhruv/lab2p1/.gitignore @@ -0,0 +1 @@ +/result/ \ No newline at end of file diff --git a/dhruv/lab2p1/CMakeLists.txt b/dhruv/lab2p1/CMakeLists.txt new file mode 100644 index 0000000..6eab423 --- /dev/null +++ b/dhruv/lab2p1/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.15...3.30) +project(lab2p1 LANGUAGES CXX) + +add_library(HelloWorldLib STATIC src/hello_world.cpp) +target_include_directories(HelloWorldLib PUBLIC include) + +add_executable(HelloWorld src/main.cpp) +target_link_libraries(HelloWorld PUBLIC HelloWorldLib) + +install(TARGETS HelloWorld DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) \ No newline at end of file diff --git a/dhruv/lab2p1/default.nix b/dhruv/lab2p1/default.nix new file mode 100644 index 0000000..cdbb495 --- /dev/null +++ b/dhruv/lab2p1/default.nix @@ -0,0 +1,8 @@ +{stdenv, cmake}: +#instructions on how to build the nix package +stdenv.mkDerivation rec { + pname = "HelloLib"; + version = "0.1.0"; + src = ./.; + nativeBuildInputs = [ cmake ]; +} \ No newline at end of file diff --git a/dhruv/lab2p1/flake.lock b/dhruv/lab2p1/flake.lock new file mode 100644 index 0000000..66f72d1 --- /dev/null +++ b/dhruv/lab2p1/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1725634671, + "narHash": "sha256-v3rIhsJBOMLR8e/RNWxr828tB+WywYIoajrZKFM+0Gg=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "574d1eac1c200690e27b8eb4e24887f8df7ac27c", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/dhruv/lab2p1/flake.nix b/dhruv/lab2p1/flake.nix new file mode 100644 index 0000000..fb8a994 --- /dev/null +++ b/dhruv/lab2p1/flake.nix @@ -0,0 +1,29 @@ +{ + description = "flakep1"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + }; + + outputs = {self, nixpkgs}: + + let + HelloLib_overlay = final: prev: { #Overlays in Nix are functions that accept two arguments (usually called final and prev) and return a set of packages + HelloLib = final.callPackage ./default.nix {}; #this makes "HelloLib" a package or sets it as a package here? + }; + + my_overlays = [ HelloLib_overlay ]; #so this is where I would add multiple overlays if needed + #HelloLib_overlay returns packages? + + pkgs = import nixpkgs { + system = "x86_64-linux"; + overlays = [ self.overlays.default ]; #are the self.overlays what I set earlier? + }; + + in + { + packages.x86_64-linux.default = pkgs.HelloLib; + overlays.default = nixpkgs.lib.composeManyExtensions my_overlays; + }; + +} \ No newline at end of file diff --git a/dhruv/lab2p1/include/hello_world.hpp b/dhruv/lab2p1/include/hello_world.hpp new file mode 100644 index 0000000..62ab384 --- /dev/null +++ b/dhruv/lab2p1/include/hello_world.hpp @@ -0,0 +1,11 @@ +#ifndef HelloWorld +#define HelloWorld +#include + +class HelloWorldLib { + public: + HelloWorldLib() = default; + void hello(); +}; + +#endif \ No newline at end of file diff --git a/dhruv/lab2p1/result b/dhruv/lab2p1/result new file mode 120000 index 0000000..20810fe --- /dev/null +++ b/dhruv/lab2p1/result @@ -0,0 +1 @@ +/nix/store/dinw5kxp8f9dcrfyr9igvpp96fd6mizf-HelloLib-0.1.0 \ No newline at end of file diff --git a/dhruv/lab2p1/src/hello_world.cpp b/dhruv/lab2p1/src/hello_world.cpp new file mode 100644 index 0000000..19b8342 --- /dev/null +++ b/dhruv/lab2p1/src/hello_world.cpp @@ -0,0 +1,6 @@ +#include +#include + +void HelloWorldLib::hello() { + std::cout << "hi"; +} \ No newline at end of file diff --git a/dhruv/lab2p1/src/main.cpp b/dhruv/lab2p1/src/main.cpp new file mode 100644 index 0000000..8bc1e7b --- /dev/null +++ b/dhruv/lab2p1/src/main.cpp @@ -0,0 +1,9 @@ +#include +#include + +int main() { + HelloWorldLib obj; + obj.hello(); + + return 0; +} \ No newline at end of file diff --git a/dhruv/lab2p2/.gitignore b/dhruv/lab2p2/.gitignore new file mode 100644 index 0000000..9b4c10b --- /dev/null +++ b/dhruv/lab2p2/.gitignore @@ -0,0 +1 @@ +/result/ \ No newline at end of file diff --git a/dhruv/lab2p2/default.nix b/dhruv/lab2p2/default.nix new file mode 100644 index 0000000..e33b23f --- /dev/null +++ b/dhruv/lab2p2/default.nix @@ -0,0 +1,9 @@ +{ stdenv, cmake, hellolib }: + +stdenv.mkDerivation rec { + pname = "hellolib_exe"; + version = "0.1.0"; + src = ./hellolib_exe; + nativeBuildInputs = [ cmake ]; + buildInputs = [ hellolib ]; +} \ No newline at end of file diff --git a/dhruv/lab2p2/flake.lock b/dhruv/lab2p2/flake.lock new file mode 100644 index 0000000..34dde40 --- /dev/null +++ b/dhruv/lab2p2/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1726243404, + "narHash": "sha256-sjiGsMh+1cWXb53Tecsm4skyFNag33GPbVgCdfj3n9I=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "345c263f2f53a3710abe117f28a5cb86d0ba4059", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/dhruv/lab2p2/flake.nix b/dhruv/lab2p2/flake.nix new file mode 100644 index 0000000..c93146e --- /dev/null +++ b/dhruv/lab2p2/flake.nix @@ -0,0 +1,27 @@ +{ + description = "lab2p2 flake"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + }; + + outputs = { self, nixpkgs }: + let + pkgs = import nixpkgs { + system = "x86_64-linux"; + overlays = [ self.overlays.default ]; + }; + + hellolib_overlay = final: prev: { + hellolib = final.callPackage ./hellolib.nix { }; + hellolib_exe = final.callPackage ./default.nix { }; + }; + my_overlays = [ hellolib_overlay ]; + + + in + { + packages.x86_64-linux.default = pkgs.hellolib; + overlays.default = nixpkgs.lib.composeManyExtensions my_overlays; + }; +} \ No newline at end of file diff --git a/dhruv/lab2p2/hellolib.nix b/dhruv/lab2p2/hellolib.nix new file mode 100644 index 0000000..5c98fcb --- /dev/null +++ b/dhruv/lab2p2/hellolib.nix @@ -0,0 +1,8 @@ +{ stdenv, cmake, hellolib }: + +stdenv.mkDerivation rec { + pname = "hellolib"; + version = "0.1.0"; + src = ./hellolib; + nativeBuildInputs = [ cmake ]; +} \ No newline at end of file diff --git a/dhruv/lab2p2/hellolib/CMakeLists.txt b/dhruv/lab2p2/hellolib/CMakeLists.txt new file mode 100644 index 0000000..4e662e4 --- /dev/null +++ b/dhruv/lab2p2/hellolib/CMakeLists.txt @@ -0,0 +1,45 @@ +cmake_minimum_required(VERSION 3.15...3.30) + +project(HelloLib LANGUAGES CXX) + +add_library(HelloLib SHARED src/hellolib.cpp) +target_include_directories(HelloLib PUBLIC + $ + $ +) + +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/HelloLibConfig.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 +) + +install( + DIRECTORY include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + FILES_MATCHING PATTERN "*.hpp" +) \ No newline at end of file diff --git a/dhruv/lab2p2/hellolib/cmake/HelloLibConfig.cmake.in b/dhruv/lab2p2/hellolib/cmake/HelloLibConfig.cmake.in new file mode 100644 index 0000000..edabb1c --- /dev/null +++ b/dhruv/lab2p2/hellolib/cmake/HelloLibConfig.cmake.in @@ -0,0 +1,11 @@ +@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 + +find_dependency(Boost) +include("${CMAKE_CURRENT_LIST_DIR}/HelloLibTargets.cmake") + +check_required_components(HelloLib) \ No newline at end of file diff --git a/dhruv/lab2p2/hellolib/include/hellolib.hpp b/dhruv/lab2p2/hellolib/include/hellolib.hpp new file mode 100644 index 0000000..061d811 --- /dev/null +++ b/dhruv/lab2p2/hellolib/include/hellolib.hpp @@ -0,0 +1,11 @@ +#ifndef HelloWorld +#define HelloWorld +#include + +class HelloWorldLib { + public: + HelloWorldLib() = default; + void hello(); +}; + +#endif \ No newline at end of file diff --git a/dhruv/lab2p2/hellolib/src/hellolib.cpp b/dhruv/lab2p2/hellolib/src/hellolib.cpp new file mode 100644 index 0000000..1d73e91 --- /dev/null +++ b/dhruv/lab2p2/hellolib/src/hellolib.cpp @@ -0,0 +1,6 @@ +#include +#include + +void HelloWorldLib::hello() { + std::cout << "Hello, world l2p2" << std::endl; +} \ No newline at end of file diff --git a/dhruv/lab2p2/hellolib_exe/CMakeLists.txt b/dhruv/lab2p2/hellolib_exe/CMakeLists.txt new file mode 100644 index 0000000..0038d17 --- /dev/null +++ b/dhruv/lab2p2/hellolib_exe/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.15...3.30) +project(lab2p2 LANGUAGES CXX) + +find_package(hellolib REQUIRED) + +add_executable(HelloWorld main.cpp) + +target_link_directories(HelloWorld PUBLIC HelloLib::HelloLib) + +install(TARGETS HelloWorld RUNTIME DESTINATION bin) + + + diff --git a/dhruv/lab2p2/hellolib_exe/main.cpp b/dhruv/lab2p2/hellolib_exe/main.cpp new file mode 100644 index 0000000..a291b78 --- /dev/null +++ b/dhruv/lab2p2/hellolib_exe/main.cpp @@ -0,0 +1,8 @@ +#include + +int main() { + HelloWorldLib test; + test.hello(); + + return 0; +} \ No newline at end of file diff --git a/dhruv/lab2p2/result b/dhruv/lab2p2/result new file mode 120000 index 0000000..e385a5e --- /dev/null +++ b/dhruv/lab2p2/result @@ -0,0 +1 @@ +/nix/store/9c45sablrf4cgqysi7d53r1b2f6h98j7-hellolib-0.1.0 \ No newline at end of file diff --git a/dhruv/lab2p3/.gitignore b/dhruv/lab2p3/.gitignore new file mode 100644 index 0000000..98793f7 --- /dev/null +++ b/dhruv/lab2p3/.gitignore @@ -0,0 +1 @@ +/result/ diff --git a/dhruv/lab2p3/CMakeLists.txt b/dhruv/lab2p3/CMakeLists.txt new file mode 100644 index 0000000..2baea72 --- /dev/null +++ b/dhruv/lab2p3/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.15...3.30) +project(lab2p2 LANGUAGES CXX) + +find_package(hellolib REQUIRED) + +add_executable(HelloWorld main.cpp) + +target_link_directories(HelloWorld PUBLIC HelloLib::HelloLib) + +install(TARGETS HelloWorld RUNTIME ${CMAKE_INSTALL_PREFIX}/bin) + + + diff --git a/dhruv/lab2p3/default.nix b/dhruv/lab2p3/default.nix new file mode 100644 index 0000000..0b17b93 --- /dev/null +++ b/dhruv/lab2p3/default.nix @@ -0,0 +1,9 @@ +{ stdenv, cmake, hellolib }: + +stdenv.mkDerivation rec { + pname = "hellolib_exe"; + version = "0.1.0"; + src = ./.; + nativeBuildInputs = [ cmake ]; + buildInputs = [ hellolib ]; +} \ No newline at end of file diff --git a/dhruv/lab2p3/flake.lock b/dhruv/lab2p3/flake.lock new file mode 100644 index 0000000..3e82479 --- /dev/null +++ b/dhruv/lab2p3/flake.lock @@ -0,0 +1,62 @@ +{ + "nodes": { + "hellolib": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1726465823, + "narHash": "sha256-K2EuxuAVQEZc+j5niFhOgS2zbS6tKMtkzuLyuPLSQXY=", + "owner": "dhruvgowda987", + "repo": "hellolibgit", + "rev": "8f4b1709d506a1198bdc3da8f39615bc4d86254e", + "type": "github" + }, + "original": { + "owner": "dhruvgowda987", + "repo": "hellolibgit", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1726243404, + "narHash": "sha256-sjiGsMh+1cWXb53Tecsm4skyFNag33GPbVgCdfj3n9I=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "345c263f2f53a3710abe117f28a5cb86d0ba4059", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1726243404, + "narHash": "sha256-sjiGsMh+1cWXb53Tecsm4skyFNag33GPbVgCdfj3n9I=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "345c263f2f53a3710abe117f28a5cb86d0ba4059", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "hellolib": "hellolib", + "nixpkgs": "nixpkgs_2" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/dhruv/lab2p3/flake.nix b/dhruv/lab2p3/flake.nix new file mode 100644 index 0000000..fe34f4a --- /dev/null +++ b/dhruv/lab2p3/flake.nix @@ -0,0 +1,27 @@ +{ + description = "lab2p3 flake2"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + hellolib.url = "github:dhruvgowda987/hellolibgit"; + }; + + outputs = { self, nixpkgs, hellolib }: + let + pkgs = import nixpkgs { + system = "x86_64-linux"; + overlays = [ self.overlays.default hellolib.overlays.default ]; + }; + + hellolib_overlay = final: prev: { + hellolib_exe = final.callPackage ./default.nix { }; + }; + my_overlays = [ hellolib_overlay ]; + + + in + { + packages.x86_64-linux.default = pkgs.hellolib; + overlays.default = nixpkgs.lib.composeManyExtensions my_overlays; + }; +} \ No newline at end of file diff --git a/dhruv/lab2p3/result b/dhruv/lab2p3/result new file mode 120000 index 0000000..f28e47c --- /dev/null +++ b/dhruv/lab2p3/result @@ -0,0 +1 @@ +/nix/store/dmgn0lgsshmchn2h3jga656ciprr6xq5-hellolib-0.1.0 \ No newline at end of file diff --git a/dhruv/lab2p3/src/main.cpp b/dhruv/lab2p3/src/main.cpp new file mode 100644 index 0000000..a291b78 --- /dev/null +++ b/dhruv/lab2p3/src/main.cpp @@ -0,0 +1,8 @@ +#include + +int main() { + HelloWorldLib test; + test.hello(); + + return 0; +} \ No newline at end of file