From 19b5cb46e0f217b05a09fe4d43dbbb4aae7e72e8 Mon Sep 17 00:00:00 2001 From: Evy Garden <julian.storozhenko@tu-dortmund.de> Date: Sat, 2 Dec 2023 12:49:38 +0100 Subject: [PATCH] initial day02 --- day02/.envrc | 1 + day02/.gitignore | 2 ++ day02/Cargo.lock | 7 ++++ day02/Cargo.toml | 8 +++++ day02/flake.nix | 28 +++++++++++++++ day02/src/main.rs | 3 ++ flake.lock | 91 ++++++++++++++++++++++++++++++++++++++++++----- flake.nix | 7 +++- 8 files changed, 138 insertions(+), 9 deletions(-) create mode 100644 day02/.envrc create mode 100644 day02/.gitignore create mode 100644 day02/Cargo.lock create mode 100644 day02/Cargo.toml create mode 100644 day02/flake.nix create mode 100644 day02/src/main.rs diff --git a/day02/.envrc b/day02/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/day02/.envrc @@ -0,0 +1 @@ +use flake diff --git a/day02/.gitignore b/day02/.gitignore new file mode 100644 index 0000000..4864a1e --- /dev/null +++ b/day02/.gitignore @@ -0,0 +1,2 @@ +# rust +target/ diff --git a/day02/Cargo.lock b/day02/Cargo.lock new file mode 100644 index 0000000..52d399b --- /dev/null +++ b/day02/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "day02" +version = "0.1.0" diff --git a/day02/Cargo.toml b/day02/Cargo.toml new file mode 100644 index 0000000..843335d --- /dev/null +++ b/day02/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "day02" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/day02/flake.nix b/day02/flake.nix new file mode 100644 index 0000000..1b24640 --- /dev/null +++ b/day02/flake.nix @@ -0,0 +1,28 @@ +{ + description = "AoC 2023 - day 02"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05"; + naersk = { + url = "github:nix-community/naersk/master"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, utils, naersk }: + utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + naerskBuildPackage = (conf: + (pkgs.callPackage naersk { }).buildPackage ({ src = ./.; } // conf) + ); + in + { + defaultPackage = naerskBuildPackage { }; + + devShell = with pkgs; mkShell { + buildInputs = [ cargo rustc rustfmt ]; + }; + }); +} diff --git a/day02/src/main.rs b/day02/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/day02/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/flake.lock b/flake.lock index ffb9556..d992100 100644 --- a/flake.lock +++ b/flake.lock @@ -10,12 +10,12 @@ }, "locked": { "lastModified": 1, - "narHash": "sha256-tY3L0BwQAOShopkV4HZ+v9zwM16Yj+joLr+5xi6Bwx8=", - "path": "/nix/store/wl49h89zff154wpqbagplgk7sw1z74ds-source/day01", + "narHash": "sha256-Ks2BdODzP+gqgz4u9o4boZIqE0KnzrpA7FqLQ4IuBdc=", + "path": "/nix/store/zprw6qgx4v1m92zfzirmmli192k6cgrf-source/day01", "type": "path" }, "original": { - "path": "/nix/store/wl49h89zff154wpqbagplgk7sw1z74ds-source/day01", + "path": "/nix/store/zprw6qgx4v1m92zfzirmmli192k6cgrf-source/day01", "type": "path" } }, @@ -28,12 +28,31 @@ }, "locked": { "lastModified": 1, - "narHash": "sha256-gwH89EDWFx3eparAlrWPU/9GnsltYgNk0Kia2ZwycgI=", - "path": "/nix/store/wl49h89zff154wpqbagplgk7sw1z74ds-source/day01cpp", + "narHash": "sha256-8Yu/GKz1zA91/CL5PgmiBRxE2h+bb9uRLHK1HTtmLbQ=", + "path": "/nix/store/zprw6qgx4v1m92zfzirmmli192k6cgrf-source/day01cpp", "type": "path" }, "original": { - "path": "/nix/store/wl49h89zff154wpqbagplgk7sw1z74ds-source/day01cpp", + "path": "/nix/store/zprw6qgx4v1m92zfzirmmli192k6cgrf-source/day01cpp", + "type": "path" + } + }, + "day02": { + "inputs": { + "naersk": "naersk_2", + "nixpkgs": [ + "nixpkgs" + ], + "utils": "utils_3" + }, + "locked": { + "lastModified": 1, + "narHash": "sha256-sHAKZV5MGsQlBCKKgaKaKtXHP9aSTOadM94p1yMM4Aw=", + "path": "/nix/store/zprw6qgx4v1m92zfzirmmli192k6cgrf-source/day02", + "type": "path" + }, + "original": { + "path": "/nix/store/zprw6qgx4v1m92zfzirmmli192k6cgrf-source/day02", "type": "path" } }, @@ -60,6 +79,28 @@ } }, "naersk_2": { + "inputs": { + "nixpkgs": [ + "day02", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1698420672, + "narHash": "sha256-/TdeHMPRjjdJub7p7+w55vyABrsJlt5QkznPYy55vKA=", + "owner": "nix-community", + "repo": "naersk", + "rev": "aeb58d5e8faead8980a807c840232697982d47b9", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "master", + "repo": "naersk", + "type": "github" + } + }, + "naersk_3": { "inputs": { "nixpkgs": [ "nixpkgs" @@ -100,9 +141,10 @@ "inputs": { "day01": "day01", "day01cpp": "day01cpp", - "naersk": "naersk_2", + "day02": "day02", + "naersk": "naersk_3", "nixpkgs": "nixpkgs", - "utils": "utils_3" + "utils": "utils_4" } }, "systems": { @@ -150,6 +192,21 @@ "type": "github" } }, + "systems_4": { + "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" @@ -203,6 +260,24 @@ "repo": "flake-utils", "type": "github" } + }, + "utils_4": { + "inputs": { + "systems": "systems_4" + }, + "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 7e3f421..5feb5d0 100644 --- a/flake.nix +++ b/flake.nix @@ -11,6 +11,10 @@ url = "./day01cpp"; inputs.nixpkgs.follows = "nixpkgs"; }; + day02 = { + url = "./day02"; + inputs.nixpkgs.follows = "nixpkgs"; + }; naersk = { url = "github:nix-community/naersk/master"; inputs.nixpkgs.follows = "nixpkgs"; @@ -18,7 +22,7 @@ utils.url = "github:numtide/flake-utils"; }; - outputs = { self, nixpkgs, utils, naersk, day01, day01cpp }: + outputs = { self, nixpkgs, utils, naersk, day01, day01cpp, day02 }: utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; }; @@ -27,6 +31,7 @@ packages = { day01 = day01.defaultPackage.${system}; day01cpp = day01cpp.defaultPackage.${system}; + day02 = day01.defaultPackage.${system}; }; } ); -- GitLab