diff --git a/newinfra/nix/hive.nix b/newinfra/nix/hive.nix index c047227..4ee5fe2 100644 --- a/newinfra/nix/hive.nix +++ b/newinfra/nix/hive.nix @@ -1,6 +1,9 @@ { meta = - let nixpkgs-path = (fetchTarball "https://github.com/NixOS/nixpkgs/archive/7105ae3957700a9646cc4b766f5815b23ed0c682.tar.gz"); in + let + my-projects-versions = builtins.fromJSON (builtins.readFile ./my-projects.json); + nixpkgs-path = (fetchTarball "https://github.com/NixOS/nixpkgs/archive/7105ae3957700a9646cc4b766f5815b23ed0c682.tar.gz"); + in { # Override to pin the Nixpkgs version (recommended). This option # accepts one of the following: @@ -10,14 +13,12 @@ nixpkgs = import nixpkgs-path; # nixos-24.11 2025-03-21 specialArgs = { - website = import (fetchTarball "https://github.com/Noratrieb/website/archive/57c4a239da5d17eafde4ade165f3c6706639a9b4.tar.gz"); - blog = fetchTarball "https://github.com/Noratrieb/blog/archive/04f7cf7d27db359cbf9fac2e9e3e677a7e76abd9.tar.gz"; - slides = fetchTarball "https://github.com/Noratrieb/slides/archive/0401f35c22b124b69447655f0c537badae9e223c.tar.gz"; - - pretense = import (fetchTarball "https://github.com/Noratrieb/pretense/archive/270b01fc1118dfd713c1c41530d1a7d98f04527d.tar.gz"); - quotdd = import (fetchTarball "https://github.com/Noratrieb/quotdd/archive/9c37b3e2093020771ee7c9da6200f95d4269b4e4.tar.gz"); - - does-it-build = import (fetchTarball "https://github.com/Noratrieb/does-it-build/archive/79bb6d1eb06d47db7d59829cd6cce247d223a960.tar.gz"); + website = import (fetchTarball "https://github.com/Noratrieb/website/archive/${my-projects-versions.website}.tar.gz"); + blog = fetchTarball "https://github.com/Noratrieb/blog/archive/${my-projects-versions.blog}.tar.gz"; + slides = fetchTarball "https://github.com/Noratrieb/slides/archive/${my-projects-versions.slides}.tar.gz"; + pretense = import (fetchTarball "https://github.com/Noratrieb/pretense/archive/${my-projects-versions.pretense}.tar.gz"); + quotdd = import (fetchTarball "https://github.com/Noratrieb/quotdd/archive/${my-projects-versions.quotdd}.tar.gz"); + does-it-build = import (fetchTarball "https://github.com/Noratrieb/does-it-build/archive/${my-projects-versions.does-it-build}.tar.gz"); inherit nixpkgs-path; diff --git a/newinfra/nix/my-projects.json b/newinfra/nix/my-projects.json new file mode 100644 index 0000000..4f77bab --- /dev/null +++ b/newinfra/nix/my-projects.json @@ -0,0 +1,8 @@ +{ + "website": "57c4a239da5d17eafde4ade165f3c6706639a9b4", + "blog": "ea2758dd10f29e8d66ca3f54d7303f2ac20005d2", + "slides": "0401f35c22b124b69447655f0c537badae9e223c", + "pretense": "270b01fc1118dfd713c1c41530d1a7d98f04527d", + "quotdd": "e922229e1d9e055be35dabd112bafc87a0686548", + "does-it-build": "79bb6d1eb06d47db7d59829cd6cce247d223a960" +} diff --git a/newinfra/update-my-projects.mjs b/newinfra/update-my-projects.mjs new file mode 100644 index 0000000..e940822 --- /dev/null +++ b/newinfra/update-my-projects.mjs @@ -0,0 +1,31 @@ +import fs from "node:fs/promises"; + +const path = `${import.meta.dirname}/nix/my-projects.json`; +const projects = JSON.parse(await fs.readFile(path)); + +let hasChanges = false; + +for (const [name, commit] of Object.entries(projects)) { + const res = await fetch( + `https://api.github.com/repos/Noratrieb/${name}/commits/HEAD` + ); + if (!res.ok) { + throw new Error( + `get commit for ${name}: ${res.status} - ${await res.text()}` + ); + } + const body = await res.json(); + const latestCommit = body.sha; + + if (commit !== latestCommit) { + console.log( + `${name} changed from ${commit} -> ${latestCommit} (${body.commit.message})` + ); + projects[name] = latestCommit; + hasChanges = true; + } +} + +if (hasChanges) { + await fs.writeFile(path, JSON.stringify(projects, null, 2) + "\n"); +} diff --git a/shell.nix b/shell.nix index a5779cb..e845754 100644 --- a/shell.nix +++ b/shell.nix @@ -14,6 +14,7 @@ wireguard-tools python311Packages.zstandard python311Packages.brotli + nodejs (import (builtins.fetchTarball "https://github.com/ryantm/agenix/archive/531beac616433bac6f9e2a19feb8e99a22a66baf.tar.gz") { }).agenix ]; }