diff --git a/day02/.envrc b/day02/.envrc new file mode 100644 index 0000000000000000000000000000000000000000..3550a30f2de389e537ee40ca5e64a77dc185c79b --- /dev/null +++ b/day02/.envrc @@ -0,0 +1 @@ +use flake diff --git a/day02/.gitignore b/day02/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4864a1e68596e5fc3a7f573bdc7762cbddc26b35 --- /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 0000000000000000000000000000000000000000..52d399b3aa10d79dff5263a81292d58925e5483d --- /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 0000000000000000000000000000000000000000..843335d53c02f6ebc00a7c472a5e6e72b8e48afa --- /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 0000000000000000000000000000000000000000..1b246404d3eced7493ba399a97443d56dda2909f --- /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 0000000000000000000000000000000000000000..e7a11a969c037e00a796aafeff6258501ec15e9a --- /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 ffb9556d4a73f738f6d31eec0f42b900ae139691..d992100005c4322f750a3359e303eb011da7ccde 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 7e3f4216c0824d414242e2361c67de019d6ae760..5feb5d0d8e1fc8ea303f1bf20deca4ffa3ef4187 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}; }; } );