{ description = "Peace and dignity at the TV: delegating the remotes to an agent"; inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05"; outputs = { self, nixpkgs }: let systems = [ "x86_64-linux" "aarch64-linux" ]; forAll = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system}); python = pkgs: pkgs.python3.withPackages (ps: [ ps.pyserial ps.libgpiod ps.pyflakes ]); # An example box, for nix flake check: does a box's system evaluate? example = self.lib.mkBox { name = "box"; server = "home"; wifi = "home"; admin = "admin"; sshKeys = [ ]; }; in { # The box's services, for a NixOS system of your own. nixosModules.box = ./box/module.nix; # A box: a Raspberry Pi 3B with the AIY Voice HAT, from a few names (box/system.nix says which). # Its image: (mkBox { ... }).config.system.build.sdImage. The box's JavaScript and earcons are # the same on every architecture, so they're built natively, on buildSystem, rather than under qemu. lib.mkBox = { name, server, wifi, admin, sshKeys, modules ? [ ], buildSystem ? "x86_64-linux" }: nixpkgs.lib.nixosSystem { system = "aarch64-linux"; modules = [ "${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix" self.nixosModules.box ./box/voicehat.nix (import ./box/system.nix { inherit name server wifi admin sshKeys; }) { pdtv26.box.packages = with self.packages.${buildSystem}; { speechJs = speech-js; boxJs = box-js; inherit earcons; }; } ] ++ modules; }; packages = forAll (pkgs: { speech = pkgs.callPackage ./speech/server.nix { }; speech-js = pkgs.callPackage ./speech/default.nix { }; box-js = pkgs.callPackage ./box/default.nix { }; earcons = pkgs.callPackage ./box/earcons.nix { }; brain = pkgs.callPackage ./brain/brain.nix { src = self; }; brain-js = pkgs.callPackage ./brain/default.nix { }; status = pkgs.callPackage ./status/default.nix { }; }); # nix develop --command make test devShells = forAll (pkgs: { default = pkgs.mkShellNoCC { packages = [ (python pkgs) pkgs.gnumake pkgs.gawk pkgs.curl pkgs.picocom pkgs.nixos-rebuild pkgs.libsecret ]; }; }); checks = forAll (pkgs: { ir-pico = pkgs.runCommand "ir-pico-doctests" { nativeBuildInputs = [ (python pkgs) ]; } '' cd ${./ir-pico} python3 -I -m doctest ir_commands.py pico_tty.py touch $out ''; speech = self.packages.${pkgs.stdenv.hostPlatform.system}.speech-js; box-js = self.packages.${pkgs.stdenv.hostPlatform.system}.box-js; brain-js = self.packages.${pkgs.stdenv.hostPlatform.system}.brain-js; # The channel, its unit, and its instructions, put together. brain = self.packages.${pkgs.stdenv.hostPlatform.system}.brain; status = self.packages.${pkgs.stdenv.hostPlatform.system}.status; # Doctests, and pyflakes for the names doctests don't reach. box-py = pkgs.runCommand "box-py-doctests" { nativeBuildInputs = [ (python pkgs) ]; } '' cd ${./box/body} python3 -I -m doctest *.py pyflakes *.py ${./box/wifi_psk.py} python3 -I -m doctest ${./box/wifi_psk.py} touch $out ''; # The example box's system evaluates; building it takes aarch64, and booting it, a Pi. box-system = pkgs.writeText "box-system" (builtins.unsafeDiscardStringContext example.config.system.build.toplevel.drvPath); }); }; }