From f7602cbde3280877800cb7a7d970857c0125c31e Mon Sep 17 00:00:00 2001 From: harryprayiv Date: Tue, 14 Feb 2023 16:06:44 -0500 Subject: [PATCH 01/17] nixify for Nixers playing along at home --- shell.nix | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 shell.nix diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..3b6cb0b --- /dev/null +++ b/shell.nix @@ -0,0 +1,9 @@ +let + # Pinned nixpkgs, deterministic. Last updated: 2/12/21. + pkgs = import (fetchTarball("https://github.com/NixOS/nixpkgs/archive/a58a0b5098f0c2a389ee70eb69422a052982d990.tar.gz")) {}; + + # Rolling updates, not deterministic. + # pkgs = import (fetchTarball("channel:nixpkgs-unstable")) {}; +in pkgs.mkShell { + buildInputs = [ pkgs.cargo pkgs.rustc pkgs.glibc pkgs.ncurses ]; +} From 0fbf09e2452cfce87d9cc337f8838b38dd63457b Mon Sep 17 00:00:00 2001 From: harryprayiv Date: Mon, 20 Feb 2023 08:37:58 -0500 Subject: [PATCH 02/17] auto-run using nix-shell --- shell.nix | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/shell.nix b/shell.nix index 3b6cb0b..f69b473 100644 --- a/shell.nix +++ b/shell.nix @@ -1,9 +1,13 @@ +{ pkgs ? import { } }: let - # Pinned nixpkgs, deterministic. Last updated: 2/12/21. - pkgs = import (fetchTarball("https://github.com/NixOS/nixpkgs/archive/a58a0b5098f0c2a389ee70eb69422a052982d990.tar.gz")) {}; - - # Rolling updates, not deterministic. - # pkgs = import (fetchTarball("channel:nixpkgs-unstable")) {}; + todoScript = pkgs.writeScriptBin "todo-rs" '' + cargo run TODO + ''; in pkgs.mkShell { + name = "todo-rs"; buildInputs = [ pkgs.cargo pkgs.rustc pkgs.glibc pkgs.ncurses ]; + + shellHook = '' + cargo run TODO + ''; } From ed36cc9bce351e12330d95e069e6b76f951deb28 Mon Sep 17 00:00:00 2001 From: harryprayiv Date: Mon, 20 Feb 2023 08:39:08 -0500 Subject: [PATCH 03/17] my template todo list --- TODO | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/TODO b/TODO index 0e8447e..44dcaa3 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,6 @@ -TODO: Make a cup of tea -TODO: Buy a bread -TODO: Write the todo app -DONE: Make a cup of tea -DONE: Start the stream -DONE: Have a breakfast +TODO: Cardano Module +TODO: Loki, Grafana, Prometheus, Promtail +TODO: Rust Module +TODO: Plutus Module +TODO: Haskell Module +TODO: WASM Module From 5dcd95651473afc061b34a33d3e931e714c109bd Mon Sep 17 00:00:00 2001 From: harryprayiv Date: Tue, 14 Mar 2023 15:38:05 -0400 Subject: [PATCH 04/17] new flake stuff --- TODO | 4 +++ default.nix | 56 +++++++++++++++++++++++++++++++++++++ flake.lock | 24 ++++++++++++++++ flake.nix | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 163 insertions(+) create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/TODO b/TODO index 44dcaa3..1bcfc88 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,7 @@ +TODO: cardano node module cleanup +TODO: fix nix-templates +TODO: std plutus starter +TODO: gimbalabs plutus starter TODO: Cardano Module TODO: Loki, Grafana, Prometheus, Promtail TODO: Rust Module diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..7948169 --- /dev/null +++ b/default.nix @@ -0,0 +1,56 @@ +# default.nix +{ lib +, naersk +, stdenv +, clangStdenv +, hostPlatform +, targetPlatform +, pkg-config +, libiconv +, rustfmt +, cargo +, rustc + # , llvmPackages # Optional + # , protobuf # Optional +}: + +let + cargoToml = (builtins.fromTOML (builtins.readFile ./Cargo.toml)); +in + +naersk.lib."${targetPlatform.system}".buildPackage rec { + src = ./.; + + buildInputs = [ + rustfmt + pkg-config + cargo + rustc + libiconv + ]; + checkInputs = [ cargo rustc ]; + + doCheck = true; + CARGO_BUILD_INCREMENTAL = "false"; + RUST_BACKTRACE = "full"; + copyLibs = true; + + # Optional things you might need: + # + # If you depend on `libclang`: + # LIBCLANG_PATH = "${llvmPackages.libclang}/lib"; + # + # If you depend on protobuf: + # PROTOC = "${protobuf}/bin/protoc"; + # PROTOC_INCLUDE = "${protobuf}/include"; + + name = cargoToml.package.name; + version = cargoToml.package.version; + + meta = with lib; { + description = cargoToml.package.description; + homepage = cargoToml.package.homepage; + license = with licenses; [ mit ]; + maintainers = with maintainers; [ ]; + }; +} \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..512a156 --- /dev/null +++ b/flake.lock @@ -0,0 +1,24 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1677932085, + "narHash": "sha256-+AB4dYllWig8iO6vAiGGYl0NEgmMgGHpy9gzWJ3322g=", + "path": "/nix/store/qilsyakhi0qmjq9iwxn49g3qbl1rp5m7-source", + "rev": "3c5319ad3aa51551182ac82ea17ab1c6b0f0df89", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..c5ce18d --- /dev/null +++ b/flake.nix @@ -0,0 +1,79 @@ +# flake.nix +{ + description = "My cute Rust crate!"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + naersk.url = "github:nmattia/naersk"; + naersk.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { self, nixpkgs, naersk }: + let + cargoToml = (builtins.fromTOML (builtins.readFile ./Cargo.toml)); + supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ]; + forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system); + in + { + overlay = final: prev: { + "${cargoToml.package.name}" = final.callPackage ./. { inherit naersk; }; + }; + + packages = forAllSystems (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ + self.overlay + ]; + }; + in + { + "${cargoToml.package.name}" = pkgs."${cargoToml.package.name}"; + }); + + + defaultPackage = forAllSystems (system: (import nixpkgs { + inherit system; + overlays = [ self.overlay ]; + })."${cargoToml.package.name}"); + + checks = forAllSystems (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ + self.overlay + ]; + }; + in + { + format = pkgs.runCommand "check-format" + { + buildInputs = with pkgs; [ rustfmt cargo ]; + } '' + ${pkgs.rustfmt}/bin/cargo-fmt fmt --manifest-path ${./.}/Cargo.toml -- --check + ${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt --check ${./.} + touch $out # it worked! + ''; + "${cargoToml.package.name}" = pkgs."${cargoToml.package.name}"; + }); + devShell = forAllSystems (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ self.overlay ]; + }; + in + pkgs.mkShell { + inputsFrom = with pkgs; [ + pkgs."${cargoToml.package.name}" + ]; + buildInputs = with pkgs; [ + rustfmt + nixpkgs-fmt + ]; + LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; + }); + }; +} \ No newline at end of file From e9c2bf811a3a310528afbf7cac5c3081a27d1c76 Mon Sep 17 00:00:00 2001 From: harryprayiv Date: Tue, 14 Mar 2023 15:40:31 -0400 Subject: [PATCH 05/17] getting it working with flakes --- flake.lock | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/flake.lock b/flake.lock index 512a156..1b510f6 100644 --- a/flake.lock +++ b/flake.lock @@ -1,20 +1,44 @@ { "nodes": { + "naersk": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1671096816, + "narHash": "sha256-ezQCsNgmpUHdZANDCILm3RvtO1xH8uujk/+EqNvzIOg=", + "owner": "nmattia", + "repo": "naersk", + "rev": "d998160d6a076cfe8f9741e56aeec7e267e3e114", + "type": "github" + }, + "original": { + "owner": "nmattia", + "repo": "naersk", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1677932085, - "narHash": "sha256-+AB4dYllWig8iO6vAiGGYl0NEgmMgGHpy9gzWJ3322g=", - "path": "/nix/store/qilsyakhi0qmjq9iwxn49g3qbl1rp5m7-source", - "rev": "3c5319ad3aa51551182ac82ea17ab1c6b0f0df89", - "type": "path" + "lastModified": 1678724065, + "narHash": "sha256-MjeRjunqfGTBGU401nxIjs7PC9PZZ1FBCZp/bRB3C2M=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b8afc8489dc96f29f69bec50fdc51e27883f89c1", + "type": "github" }, "original": { - "id": "nixpkgs", - "type": "indirect" + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" } }, "root": { "inputs": { + "naersk": "naersk", "nixpkgs": "nixpkgs" } } From 1c486886ea8cb1dc06cf0fa401d3875d0e59ad05 Mon Sep 17 00:00:00 2001 From: harryprayiv Date: Tue, 14 Mar 2023 15:46:28 -0400 Subject: [PATCH 06/17] attempt --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index c5ce18d..f131805 100644 --- a/flake.nix +++ b/flake.nix @@ -50,7 +50,7 @@ { format = pkgs.runCommand "check-format" { - buildInputs = with pkgs; [ rustfmt cargo ]; + buildInputs = with pkgs; [ cargo rustc glibc ncurses ]; } '' ${pkgs.rustfmt}/bin/cargo-fmt fmt --manifest-path ${./.}/Cargo.toml -- --check ${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt --check ${./.} From 6bf7623cc27fbd7821a148b2480a9629ab6c8009 Mon Sep 17 00:00:00 2001 From: harryprayiv Date: Tue, 14 Mar 2023 15:49:44 -0400 Subject: [PATCH 07/17] not working yet --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c08475b..0400c5c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,15 +4,15 @@ version = 3 [[package]] name = "cc" -version = "1.0.68" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" [[package]] name = "libc" -version = "0.2.97" +version = "0.2.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6" +checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" [[package]] name = "ncurses" @@ -27,9 +27,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.19" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" [[package]] name = "todo-rs" From 59882811d12225de7e53eb49dcbc2bee967cdc12 Mon Sep 17 00:00:00 2001 From: harryprayiv Date: Tue, 14 Mar 2023 16:00:40 -0400 Subject: [PATCH 08/17] gitignore on list --- .gitignore | 1 + TODO | 11 ++--------- flake.nix | 8 +++++++- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index ea8c4bf..3816ff8 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +TODO diff --git a/TODO b/TODO index 1bcfc88..7b48d60 100644 --- a/TODO +++ b/TODO @@ -1,10 +1,3 @@ -TODO: cardano node module cleanup -TODO: fix nix-templates -TODO: std plutus starter -TODO: gimbalabs plutus starter -TODO: Cardano Module -TODO: Loki, Grafana, Prometheus, Promtail + TODO: Rust Module -TODO: Plutus Module -TODO: Haskell Module -TODO: WASM Module + diff --git a/flake.nix b/flake.nix index f131805..94b065b 100644 --- a/flake.nix +++ b/flake.nix @@ -50,7 +50,7 @@ { format = pkgs.runCommand "check-format" { - buildInputs = with pkgs; [ cargo rustc glibc ncurses ]; + buildInputs = with pkgs; [ cargo rustc ncurses ]; } '' ${pkgs.rustfmt}/bin/cargo-fmt fmt --manifest-path ${./.}/Cargo.toml -- --check ${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt --check ${./.} @@ -69,9 +69,15 @@ inputsFrom = with pkgs; [ pkgs."${cargoToml.package.name}" ]; + # shellHook = '' + # cargo run TODO + # ''; buildInputs = with pkgs; [ rustfmt nixpkgs-fmt + cargo + rustc + ncurses ]; LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; }); From d1f80dc13e6481fb25b75fcc0204040a1c4c9dab Mon Sep 17 00:00:00 2001 From: harryprayiv Date: Tue, 14 Mar 2023 16:02:47 -0400 Subject: [PATCH 09/17] gitignore isn't working --- flake.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 94b065b..d22af40 100644 --- a/flake.nix +++ b/flake.nix @@ -69,9 +69,9 @@ inputsFrom = with pkgs; [ pkgs."${cargoToml.package.name}" ]; - # shellHook = '' - # cargo run TODO - # ''; + shellHook = '' + cargo run TODO + ''; buildInputs = with pkgs; [ rustfmt nixpkgs-fmt From d0f7969f015146a02cc87b8090bbc498c7410933 Mon Sep 17 00:00:00 2001 From: harryprayiv Date: Tue, 14 Mar 2023 16:12:01 -0400 Subject: [PATCH 10/17] gitignore my list --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3816ff8..2d90e8d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target TODO +todo-rs From b1998b0ad62d1b5196a590e8cd8333c48bcf9a9b Mon Sep 17 00:00:00 2001 From: harryprayiv Date: Tue, 14 Mar 2023 16:14:41 -0400 Subject: [PATCH 11/17] fixing initial todos befor eI gitignore --- TODO | 4 +--- todo-rs | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 todo-rs diff --git a/TODO b/TODO index 7b48d60..16fa12c 100644 --- a/TODO +++ b/TODO @@ -1,3 +1 @@ - -TODO: Rust Module - +TODO: Rust Module \ No newline at end of file diff --git a/todo-rs b/todo-rs new file mode 100644 index 0000000..ea6bb3f --- /dev/null +++ b/todo-rs @@ -0,0 +1,4 @@ +TODO: Nix-Config (comprehensive Cardano) +TODO: PLutus Starter (IOG std) +TODO: Plutus Starter (Gimbalabs) +TODO: Cardano Node From fff6e6c2ea0574ffe3ad3b0d2ded0dd8402a5577 Mon Sep 17 00:00:00 2001 From: harryprayiv Date: Tue, 14 Mar 2023 16:14:52 -0400 Subject: [PATCH 12/17] gitignore update --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 2d90e8d..54466f5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ /target -TODO -todo-rs + From 6f96fd908e6dd7703c3c764235aef4f4b7167627 Mon Sep 17 00:00:00 2001 From: harryprayiv Date: Tue, 14 Mar 2023 16:16:53 -0400 Subject: [PATCH 13/17] gitignores --- .gitignore | 1 + TODO | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 54466f5..6a9b853 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target +TODO diff --git a/TODO b/TODO index 16fa12c..a265ee5 100644 --- a/TODO +++ b/TODO @@ -1 +1,3 @@ -TODO: Rust Module \ No newline at end of file +TODO: Newer Item +TODO: New Item +TODO: Rust Module From 9da01dd06609e56bf36b684ff55498b3e273e445 Mon Sep 17 00:00:00 2001 From: harryprayiv Date: Tue, 14 Mar 2023 16:17:03 -0400 Subject: [PATCH 14/17] delete that file --- todo-rs | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 todo-rs diff --git a/todo-rs b/todo-rs deleted file mode 100644 index ea6bb3f..0000000 --- a/todo-rs +++ /dev/null @@ -1,4 +0,0 @@ -TODO: Nix-Config (comprehensive Cardano) -TODO: PLutus Starter (IOG std) -TODO: Plutus Starter (Gimbalabs) -TODO: Cardano Node From f268da90c36cdd98dd41d216b2c6d1376b426ae0 Mon Sep 17 00:00:00 2001 From: harryprayiv Date: Tue, 14 Mar 2023 16:27:27 -0400 Subject: [PATCH 15/17] so weird how TODO goes anyway --- .gitignore | 1 - TODO | 2 -- flake.nix | 5 ++--- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 6a9b853..3816ff8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ /target - TODO diff --git a/TODO b/TODO index a265ee5..b2a9e3c 100644 --- a/TODO +++ b/TODO @@ -1,3 +1 @@ -TODO: Newer Item -TODO: New Item TODO: Rust Module diff --git a/flake.nix b/flake.nix index d22af40..b51745d 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ # flake.nix { - description = "My cute Rust crate!"; + description = "todo-rs"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; @@ -70,11 +70,10 @@ pkgs."${cargoToml.package.name}" ]; shellHook = '' + echo "starting todo list app" cargo run TODO ''; buildInputs = with pkgs; [ - rustfmt - nixpkgs-fmt cargo rustc ncurses From 69d673d395dfef9a13cd7da31e731ec9846afa5a Mon Sep 17 00:00:00 2001 From: harryprayiv Date: Tue, 14 Mar 2023 16:34:12 -0400 Subject: [PATCH 16/17] shell hooks are annoying --- flake.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index b51745d..186d355 100644 --- a/flake.nix +++ b/flake.nix @@ -69,10 +69,10 @@ inputsFrom = with pkgs; [ pkgs."${cargoToml.package.name}" ]; - shellHook = '' - echo "starting todo list app" - cargo run TODO - ''; + # shellHook = '' + # echo "starting todo list app" + # cargo run TODO + # ''; buildInputs = with pkgs; [ cargo rustc From 999165c3df22f2388d41536d65945c7bb34fefe1 Mon Sep 17 00:00:00 2001 From: Harry Pray IV Date: Sun, 24 Sep 2023 10:32:17 -0400 Subject: [PATCH 17/17] Create .envrc .envrc --- .envrc | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .envrc diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..c824d65 --- /dev/null +++ b/.envrc @@ -0,0 +1,5 @@ +if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc" "sha256-0gsh4bmn8mfc1iszxvpinkkq652b3wr238qcrqp8rwybmn7pwrqf=" +fi + +use flake .