{ inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; outputs = { self, nixpkgs }: let forAllSystems = f: nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-linux" ] ( system: f (import nixpkgs { inherit system; }) system ); in { devShells = forAllSystems ( pkgs: sys: { default = pkgs.mkShell { packages = with pkgs.ocamlPackages; [ dune_3 ocaml angstrom angstrom-unix camlzip ppx_inline_test ocaml-lsp ocamlformat ocamlformat-rpc-lib utop ]; }; } ); packages = forAllSystems ( pkgs: sys: { default = pkgs.ocamlPackages.buildDunePackage { pname = "inshellah"; version = "0.1"; src = ./.; nativeBuildInputs = [ pkgs.git ]; buildInputs = with pkgs.ocamlPackages; [ dune_3 ocaml angstrom angstrom-unix camlzip ]; meta.mainProgram = "inshellah"; }; } ); checks = forAllSystems ( pkgs: sys: let # Evaluate a minimal NixOS config that enables the module. # If the module has infinite recursion, this evaluation will fail. mockSystem = nixpkgs.lib.nixosSystem { system = sys; modules = [ self.nixosModules.default { # Minimal config to make NixOS evaluation happy boot.loader.grub.device = "nodev"; fileSystems."/" = { device = "/dev/sda1"; fsType = "ext4"; }; programs.inshellah.enable = true; environment.systemPackages = [ pkgs.hello ]; } ]; }; in { module-no-infinite-recursion = pkgs.runCommandLocal "inshellah-module-test" { # Force evaluation of extraSetup and systemPackages at eval time. # If the module has infinite recursion, this derivation can't even # be instantiated. extraSetupLen = builtins.stringLength mockSystem.config.environment.extraSetup; syspkgCount = builtins.length mockSystem.config.environment.systemPackages; } '' echo "environment.extraSetup length: $extraSetupLen" echo "environment.systemPackages count: $syspkgCount" touch $out ''; } ); nixosModules.default = { pkgs, ... }: { imports = [ ./nix/module.nix ]; programs.inshellah.package = self.packages.${pkgs.stdenv.hostPlatform.system}.default; }; }; }