Something went wrong. Try again.
Something went wrong. Try again.
hackermusic flake.nix
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115{ description = "hackermusic — SolidJS 2.0 (RC) + TypeScript 7 + oxc toolchain";
inputs = { # Locked to the rev providing nodejs_latest 26.x, pnpm 11.x, oxlint 1.80, oxfmt 0.61. # Refresh with: nix flake update nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; };
outputs = { self, nixpkgs }: let systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ]; forAllSystems = nixpkgs.lib.genAttrs systems;
# The built client is fetched per platform — the lockfile carries a different # rolldown/esbuild/oxc binary for each — so a build has to happen *on* the # system it is for. Cross-compiling a JavaScript bundle is the one thing a # Node ecosystem build cannot do, hence linux only until someone with a Mac # asks for it. buildSystems = [ "x86_64-linux" "aarch64-linux" ];
# The built client, as a store path of static files. Called through the # consuming system's own package set (see nixosModules) rather than a # self-reference through `self.packages`, so nothing has to resolve the # flake's own outputs to answer a question about one of them. webFor = system: (import nixpkgs { inherit system; }).callPackage ./nix/package.nix { }; in { devShells = forAllSystems ( system: let pkgs = import nixpkgs { inherit system; };
# Everything the plain shell has, so `perf` is a superset rather than a # second shell to remember the packages of. packages = [ pkgs.nodejs_latest # latest Node.js pkgs.pnpm # package manager (matches "packageManager" in package.json) pkgs.oxlint # linter pkgs.oxfmt # formatter pkgs.git pkgs.jujutsu # jj — git-backed VCS front-end pkgs.nixfmt-tree # formats nix/ and flake.nix (`nix fmt`) ]; in { default = pkgs.mkShell { inherit packages; };
# `nix develop .#perf` — the dev shell plus the browser the Chrome DevTools # MCP server drives, for main-thread work the test runner cannot see: long # tasks, GC, the warmer's bytes, layout. Deliberately a separate shell: it # is a gigabyte of browser, and the people running `nix flake check` or just # wanting pnpm should not pay for it at entry. # # Chrome comes from here rather than from the MCP server's own puppeteer # download because that download assumes an FHS `/lib64/ld-linux`, which this # system has no equivalent of. The server is configured with `--browser-url` # and connects to `scripts/dev-chrome` instead. perf = pkgs.mkShell { packages = packages ++ pkgs.lib.optionals pkgs.stdenv.isLinux [ # nixpkgs does not build Chromium for Darwin; on a Mac the same script # picks up a Google Chrome already on PATH. pkgs.chromium ]; }; } );
# `nix build .#web` — the static site nginx serves. packages = nixpkgs.lib.genAttrs buildSystems (system: { default = webFor system; web = webFor system; });
# The NixOS service: nginx, the cache rules this build's fingerprints ask for, # and an optional same-origin proxy for the music server. `package` defaults to # the build above, so `services.hackermusic.enable = true` is the deployment. nixosModules.default = { pkgs, ... }: { imports = [ ./nix/module.nix ]; services.hackermusic.package = pkgs.lib.mkDefault (pkgs.callPackage ./nix/package.nix { }); };
checks = { x86_64-linux = { # Boots nginx with the module and holds a stub music server behind the # proxy, so it needs a machine that can run a VM. nginx = (import nixpkgs { system = "x86_64-linux"; }).callPackage ./nix/tests/nginx.nix { }; }; };
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-tree); };}