From 0908f92bfbc7e6d392213ab42c64198436d61af2 Mon Sep 17 00:00:00 2001 From: Andrea Ciceri Date: Thu, 11 Jan 2024 12:49:26 +0100 Subject: [PATCH] feat: push all flake's outputs to `attic` --- ci/all-flake-drvs.nix | 56 +++++++++++++++++++++++++++++++++++++++++++ ci/default.nix | 5 ++-- 2 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 ci/all-flake-drvs.nix diff --git a/ci/all-flake-drvs.nix b/ci/all-flake-drvs.nix new file mode 100644 index 0000000..2e88d9e --- /dev/null +++ b/ci/all-flake-drvs.nix @@ -0,0 +1,56 @@ +{self, config, lib, inputs, ...}: { + options.allDrvs = { + systems = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = config.systems; + }; + list = lib.mkOption { + type = lib.types.listOf lib.types.package; + default = lib.concatMap + (system: (config.perSystem system).allDrvs._drvsList) + config.allDrvs.systems; + }; + }; + config.perSystem = {config, lib, system, ...}: let + cfg = config.allDrvs; + in { + options.allDrvs = { + outputs = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = lib.intersectLists [ + "packages" + "checks" + "hydraJobs" + "devShells" + "legacyPackages" + ] (lib.attrNames self.outputs); + }; + _getStandardOutputs = lib.mkOption { + type = lib.types.listOf lib.types.package; + internal = true; + default = lib.concatMap + (output: lib.attrValues config.${output}) + cfg.outputs; + }; + formatter = lib.mkOption { + type = lib.types.listOf lib.types.package; + default = if config ? formatter then [] else [config.formatter]; + }; + nixosConfigurations = lib.mkOption { + type = lib.types.listOf lib.types.package; + default = let + allConfigs = lib.lists.map + (config: config.config.system.build.toplevel) + (lib.attrValues self.nixosConfigurations); + in lib.filter (drv: drv.system == system) allConfigs; + }; + _drvsList = lib.mkOption { + type = lib.types.listOf lib.types.package; + internal = true; + default = cfg._getStandardOutputs + ++ cfg.formatter + ++ cfg.nixosConfigurations; + }; + }; + }; +} diff --git a/ci/default.nix b/ci/default.nix index 3eb99c3..c29d996 100644 --- a/ci/default.nix +++ b/ci/default.nix @@ -1,6 +1,7 @@ -{inputs, ...}: { +{inputs, config, ...}: { imports = [ inputs.hercules-ci-effects.flakeModule + ./all-flake-drvs.nix # to be updated to import a flake output "${inputs.hercules-ci-effects}/effects/push-cache/default.nix" ]; @@ -12,7 +13,7 @@ mlabs-spo-anywhere = { type = "attic"; secretName = "spo-anywhere-cache-push-token"; - packages = [inputs.nixpkgs.legacyPackages.x86_64-linux.hello]; + packages = config.allDrvs.list; }; }; };