From b51aeba804640e09f13d45cfebcd6131933b1b21 Mon Sep 17 00:00:00 2001 From: Evy Garden <evysgarden@protonmail.com> Date: Fri, 1 Dec 2023 15:34:23 +0100 Subject: [PATCH] added initial cpp version --- day01cpp/.envrc | 1 + day01cpp/CMakeLists.txt | 9 ++++++ day01cpp/flake.lock | 61 +++++++++++++++++++++++++++++++++++++++++ day01cpp/flake.nix | 37 +++++++++++++++++++++++++ day01cpp/main.cpp | 1 + day01cpp/result | 1 + flake.lock | 60 +++++++++++++++++++++++++++++++++++++--- flake.nix | 14 ++++++++-- result | 2 +- 9 files changed, 178 insertions(+), 8 deletions(-) create mode 100644 day01cpp/.envrc create mode 100644 day01cpp/CMakeLists.txt create mode 100644 day01cpp/flake.lock create mode 100644 day01cpp/flake.nix create mode 100644 day01cpp/main.cpp create mode 120000 day01cpp/result diff --git a/day01cpp/.envrc b/day01cpp/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/day01cpp/.envrc @@ -0,0 +1 @@ +use flake diff --git a/day01cpp/CMakeLists.txt b/day01cpp/CMakeLists.txt new file mode 100644 index 0000000..47607ac --- /dev/null +++ b/day01cpp/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.0) + +set(CMAKE_CXX_STANDARD 20) + +project(day01 LANGUAGES CXX VERSION 1.0.0) + +add_executable(main + ${PROJECT_SOURCE_DIR}/main.cpp +) \ No newline at end of file diff --git a/day01cpp/flake.lock b/day01cpp/flake.lock new file mode 100644 index 0000000..e3173f7 --- /dev/null +++ b/day01cpp/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1701268161, + "narHash": "sha256-hL4jGGwMHHmyx6G9wi6IrYa8RLkoEtzCb4zWITH1B40=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "67be70a859530f6f7c358568eaa6ab0d84b36b01", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "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": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/day01cpp/flake.nix b/day01cpp/flake.nix new file mode 100644 index 0000000..0f54674 --- /dev/null +++ b/day01cpp/flake.nix @@ -0,0 +1,37 @@ +{ + description = "AoC 2023 - day 01 cpp"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05"; + utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, utils, ... }: + utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + }; + buildInputs = with pkgs; [ + ninja + cmake + ]; + in + { + defaultPackage = pkgs.stdenv.mkDerivation { + name = "main"; + inherit buildInputs; + src = ./.; + installPhase = '' + runHook preInstall + mkdir -p $out/bin + cp ./main $out/bin/ + runHook postInstall + ''; + }; + devShell = with pkgs; mkShell { + buildInputs = buildInputs ++ [ clang-tools lldb ]; + }; + } + ); +} diff --git a/day01cpp/main.cpp b/day01cpp/main.cpp new file mode 100644 index 0000000..237c8ce --- /dev/null +++ b/day01cpp/main.cpp @@ -0,0 +1 @@ +int main() {} diff --git a/day01cpp/result b/day01cpp/result new file mode 120000 index 0000000..80f9da7 --- /dev/null +++ b/day01cpp/result @@ -0,0 +1 @@ +/nix/store/jq765ilimf52jh2jbllj7l67b1cq00gv-main \ No newline at end of file diff --git a/flake.lock b/flake.lock index 3c57e54..ffb9556 100644 --- a/flake.lock +++ b/flake.lock @@ -10,12 +10,30 @@ }, "locked": { "lastModified": 1, - "narHash": "sha256-Skcd0y3BZ27ycrNGxmHcMyGRPat8mYU0IXM1Lc/174I=", - "path": "/nix/store/lylqmpv4yipaapna82jpnmsxd7r4m82q-source/day01", + "narHash": "sha256-tY3L0BwQAOShopkV4HZ+v9zwM16Yj+joLr+5xi6Bwx8=", + "path": "/nix/store/wl49h89zff154wpqbagplgk7sw1z74ds-source/day01", "type": "path" }, "original": { - "path": "/nix/store/lylqmpv4yipaapna82jpnmsxd7r4m82q-source/day01", + "path": "/nix/store/wl49h89zff154wpqbagplgk7sw1z74ds-source/day01", + "type": "path" + } + }, + "day01cpp": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "utils": "utils_2" + }, + "locked": { + "lastModified": 1, + "narHash": "sha256-gwH89EDWFx3eparAlrWPU/9GnsltYgNk0Kia2ZwycgI=", + "path": "/nix/store/wl49h89zff154wpqbagplgk7sw1z74ds-source/day01cpp", + "type": "path" + }, + "original": { + "path": "/nix/store/wl49h89zff154wpqbagplgk7sw1z74ds-source/day01cpp", "type": "path" } }, @@ -81,9 +99,10 @@ "root": { "inputs": { "day01": "day01", + "day01cpp": "day01cpp", "naersk": "naersk_2", "nixpkgs": "nixpkgs", - "utils": "utils_2" + "utils": "utils_3" } }, "systems": { @@ -116,6 +135,21 @@ "type": "github" } }, + "systems_3": { + "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" @@ -151,6 +185,24 @@ "repo": "flake-utils", "type": "github" } + }, + "utils_3": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index aa76ced..7e3f421 100644 --- a/flake.nix +++ b/flake.nix @@ -7,6 +7,10 @@ url = "./day01"; inputs.nixpkgs.follows = "nixpkgs"; }; + day01cpp = { + url = "./day01cpp"; + inputs.nixpkgs.follows = "nixpkgs"; + }; naersk = { url = "github:nix-community/naersk/master"; inputs.nixpkgs.follows = "nixpkgs"; @@ -14,12 +18,16 @@ utils.url = "github:numtide/flake-utils"; }; - outputs = { self, nixpkgs, utils, naersk, day01 }: + outputs = { self, nixpkgs, utils, naersk, day01, day01cpp }: utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; }; in { - packages.day01 = day01.defaultPackage.${system}; - }); + packages = { + day01 = day01.defaultPackage.${system}; + day01cpp = day01cpp.defaultPackage.${system}; + }; + } + ); } diff --git a/result b/result index 81f84c0..1cf655b 120000 --- a/result +++ b/result @@ -1 +1 @@ -/nix/store/bmsr9z02zcchqqij4ai42b327qg32zyv-aoc-0.1.0 \ No newline at end of file +/nix/store/hl50b172fpp2v07pc9l1pwa1yab2hqvp-main \ No newline at end of file -- GitLab