{ description = "bootvine — live dependency tree of systemd jobs on the boot console"; nixConfig = { extra-substituters = [ "https://wvhulle.cachix.org" ]; extra-trusted-public-keys = [ "wvhulle.cachix.org-1:heXx8DZMiRsKUx6l1TxNoF+Nmtmz66QEdsonQzc1ir0=" ]; }; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; crane.url = "github:ipetkov/crane"; rust-overlay = { url = "github:oxalica/rust-overlay"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = { self, nixpkgs, crane, rust-overlay, }: let inherit (nixpkgs) lib; forEachSystem = f: lib.genAttrs [ "x86_64-linux" "aarch64-linux" ] ( system: let pkgs = import nixpkgs { inherit system; overlays = [ (import rust-overlay) ]; }; rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; in f { inherit system pkgs craneLib rustToolchain ; builds = import ./nix/crane-builds.nix { inherit lib pkgs craneLib; }; } ); vmTests = import ./vm-tests { inherit lib; bootvineModule = self.nixosModules.bootvine; }; in { packages = forEachSystem ( { pkgs, builds, ... }: { default = builds.bootvine; inherit (builds) bootvine scripted-demos repo-tasks workspace-dependencies ; sample-unit-files = pkgs.callPackage ./vm-tests/slow-services/sample-unit-files.nix { inherit (vmTests) sampleUnits; }; } ); nixosModules = { default = self.nixosModules.bootvine; bootvine = import ./nix/nixos-module.nix { inherit self; }; }; nixosConfigurations = lib.mapAttrs' ( machineName: _: lib.nameValuePair "sample-${machineName}" (vmTests.nixosSystemFor "x86_64-linux" machineName) ) vmTests.machines; apps = forEachSystem ( { pkgs, system, builds, rustToolchain, ... }: let sampleMachineApps = lib.mapAttrs' ( machineName: machineDescription: lib.nameValuePair "sample-vm-${machineName}" { type = "app"; meta.description = "Boot the ${machineName} sample machine in QEMU: ${machineDescription}"; program = lib.getExe (vmTests.nixosSystemFor system machineName).config.system.build.vm; } ) vmTests.machineDescriptions; wrappedProgramTool = { toolName, wrappedProgram, addedFlags, runtimeInputs ? [ ], wrapperArguments ? [ ], }: pkgs.runCommand toolName { nativeBuildInputs = [ pkgs.makeBinaryWrapper ]; meta.mainProgram = toolName; } '' makeWrapper ${wrappedProgram} $out/bin/${toolName} \ ${ lib.escapeShellArgs ( lib.concatMap (addedFlag: [ "--add-flags" addedFlag ]) addedFlags ) } \ ${lib.optionalString (runtimeInputs != [ ]) "--prefix PATH : ${lib.makeBinPath runtimeInputs}"} \ ${lib.escapeShellArgs wrapperArguments} ''; nuScriptTool = { scriptPath, toolName, runtimeInputs ? [ ], wrapperArguments ? [ ], }: wrappedProgramTool { inherit toolName runtimeInputs wrapperArguments; wrappedProgram = lib.getExe pkgs.nushell; addedFlags = [ "${scriptPath}" toolName ]; }; describedApp = appDescription: appTool: { type = "app"; meta.description = appDescription; program = lib.getExe appTool; }; nixBuiltPathsTool = toolArguments: nuScriptTool (toolArguments // { scriptPath = ./ci/nix-built-paths.nu; }); releaseTaskTool = toolArguments: nuScriptTool (toolArguments // { scriptPath = ./ci/release-tasks.nu; }); exportBuiltPathsHook = nixBuiltPathsTool { toolName = "export-built-paths-hook"; }; exportingBuildTool = toolArguments: nixBuiltPathsTool ( toolArguments // { wrapperArguments = [ "--set" "EXPORT_HOOK_PROGRAM" (lib.getExe exportBuiltPathsHook) ]; } ); releasePlzTool = toolName: releaseTaskTool { inherit toolName; runtimeInputs = [ pkgs.release-plz pkgs.gitMinimal pkgs.pkg-config pkgs.stdenv.cc rustToolchain ]; wrapperArguments = [ "--set" "PKG_CONFIG_PATH" (lib.makeSearchPathOutput "dev" "lib/pkgconfig" builds.bootvine.buildInputs) ]; }; repoTaskTool = toolArguments: wrappedProgramTool ( toolArguments // { wrappedProgram = lib.getExe builds.repo-tasks; } ); in sampleMachineApps // { release-plz-release = describedApp "Publish unpublished versions to crates.io and tag them with a Codeberg release" ( releasePlzTool "release-plz-release" ); release-plz-release-pr = describedApp "Open or update the Codeberg pull request that bumps the version and changelog" ( releasePlzTool "release-plz-release-pr" ); record-screencasts = describedApp "Re-record the scripted demo animations and the sample machine recordings into recordings/; publish them with publish-recordings" (repoTaskTool { toolName = "record-screencasts"; addedFlags = [ "record-screencasts" "--vm-check-outputs" "${pkgs.linkFarm "vm-check-outputs" ( lib.mapAttrs (machineName: _: self.checks.${system}."vm-${machineName}") vmTests.machines )}" ]; runtimeInputs = [ pkgs.vhs pkgs.libwebp builds.scripted-demos builds.repo-tasks ]; }); publish-recordings = describedApp "Replace the recordings branch on origin with a single commit holding recordings/" (repoTaskTool { toolName = "publish-recordings"; addedFlags = [ "publish-recordings" ]; runtimeInputs = [ pkgs.gitMinimal builds.repo-tasks ]; }); build-unless-cached = describedApp "Build a flake output and export it to the CI workspace unless it is already in Cachix" (exportingBuildTool { toolName = "build-unless-cached"; }); build-and-export-paths = describedApp "Build flake outputs and export newly built paths to the CI workspace" (exportingBuildTool { toolName = "build-and-export-paths"; }); import-exported-paths = describedApp "Import paths exported to the CI workspace by an earlier step" (nixBuiltPathsTool { toolName = "import-exported-paths"; }); upload-exported-paths = describedApp "Push paths exported to the CI workspace to the wvhulle Cachix cache" (nixBuiltPathsTool { toolName = "upload-exported-paths"; runtimeInputs = [ pkgs.cachix ]; }); check-conventional-commits = describedApp "Check that the commit messages in a git revision range are conventional commits" (releaseTaskTool { toolName = "check-conventional-commits"; runtimeInputs = [ pkgs.convco pkgs.gitMinimal ]; }); } ); checks = forEachSystem ( { pkgs, builds, ... }: { inherit (builds) rustfmt-formatting clippy-lints; bootvine-build = builds.bootvine; repo-tasks-build = builds.repo-tasks; ci-task-tests = pkgs.runCommand "bootvine-ci-task-tests" { nativeBuildInputs = [ pkgs.nushell ]; } '' nu ${./ci}/test-ci-tasks.nu touch $out ''; } // lib.mapAttrs' (machineName: check: lib.nameValuePair "vm-${machineName}" check) ( vmTests.checksFor pkgs ) ); devShells = forEachSystem ( { pkgs, craneLib, builds, ... }: { default = craneLib.devShell { inputsFrom = [ builds.bootvine ]; packages = [ pkgs.prek pkgs.convco pkgs.release-plz pkgs.git-cliff ]; }; } ); }; }