feat: provide wrapped packages

This commit is contained in:
Kat Inskip 2024-10-25 13:35:27 -04:00
parent fb9e62db99
commit 845afbeaf5
Signed by: kat
GPG key ID: 465E64DECEA8CF0F
12 changed files with 77 additions and 29 deletions

View file

@ -7,18 +7,6 @@
}:
with lib; let
inherit (channels.std) string list set;
enabledNixosSystems = filterAttrs (_: system: system.config.ci.enable && system.config.type == "NixOS") channels.nixfiles.systems;
exportsSystems = let
warnSystems = set.filter (_: system: system.config.ci.allowFailure) enabledNixosSystems;
toSystems = systems: string.concatMapSep " " string.escapeShellArg (set.keys systems);
in ''
NF_NIX_SYSTEMS=(${toSystems enabledNixosSystems})
NF_NIX_SYSTEMS_WARN=(${toSystems warnSystems})
'';
buildAllSystems = pkgs.writeShellScriptBin "build-systems" ''
${exportsSystems}
nix run .#nf-actions-test
'';
in {
imports = [./common.nix];
config = {

View file

@ -7,13 +7,14 @@
shells = import ./shells {inherit inputs tree lib std pkgs;};
inherit (import ./pkgs.nix {inherit inputs tree overlay;}) pkgs;
formatter = import ./formatter.nix {inherit inputs pkgs;};
wrappers = import ./wrappers {inherit inputs;};
inherit (std) set;
checks = set.map (_: deployLib: deployLib.deployChecks inputs.self.deploy) inputs.deploy-rs.lib;
in
{
inherit inputs tree std pkgs formatter lib checks;
legacyPackages = pkgs;
packages = pkgs;
packages = pkgs // wrappers;
}
// systems
// shells

View file

@ -6,4 +6,4 @@
# formerly final: prev:, but deadnix
inherit (inputs.std.lib) set;
in
set.map (_: package: prev.callPackage package {}) (removeAttrs tree.packages ["default"])
(set.map (_: package: prev.callPackage package {}) (removeAttrs tree.packages ["default"]))

View file

@ -1,13 +0,0 @@
{
wrapShellScriptBin,
pkgs,
}:
wrapShellScriptBin "nf-actions-test" ./actions-test.sh {
depsRuntimePath = with pkgs; [
git
cachix
jq
nix
curl
];
}

View file

@ -8,6 +8,5 @@ wrapShellScriptBin "nf-update" ./update.sh {
cachix
jq
curl
nf-actions-test
];
}

View file

@ -32,7 +32,7 @@ echo "checking that nodes still build..." >&2
if [[ -n ${NF_UPDATE_CACHIX_PUSH-} ]]; then
export NF_ACTIONS_TEST_OUTLINK=${NF_ACTIONS_TEST_OUTLINK-result}
fi
nf-actions-test -L
nix run .#nf-actions-test -- -L
if [[ -n ${NF_UPDATE_CACHIX_PUSH-} ]]; then
send_discord_message "Cachix pushing"

9
wrappers/default.nix Normal file
View file

@ -0,0 +1,9 @@
{
inputs,
...
}@args: let
in
inputs.utils.lib.eachDefaultSystem (system: {
nf-actions-test = import ./nf-actions-test.nix args;
nf-generate = import ./nf-generate.nix args;
})

20
wrappers/exports.nix Normal file
View file

@ -0,0 +1,20 @@
{
system,
inputs,
...
}: let
inherit (inputs.std.lib) string list set;
systems = inputs.self.systems;
enabledNixosSystems = set.filter (_: system: system.config.ci.enable && system.config.type == "NixOS") systems;
in {
exports = ''
export NF_CONFIG_ROOT=''${NF_CONFIG_ROOT-${toString ../../.}}
'';
exportsSystems = let
warnSystems = set.filter (_: system: system.config.ci.allowFailure) enabledNixosSystems;
toSystems = systems: string.concatMapSep " " string.escapeShellArg (set.keys systems);
in ''
NF_NIX_SYSTEMS=(${toSystems enabledNixosSystems})
NF_NIX_SYSTEMS_WARN=(${toSystems warnSystems})
'';
}

7
wrappers/generate.sh Normal file
View file

@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -eu
for ciconfig in "${NF_CONFIG_FILES[@]}"; do
echo "processing ${ciconfig}..." >&2
nix run --argstr config "$NF_CONFIG_ROOT/ci/$ciconfig" -f "$NF_INPUT_CI" run.gh-actions-generate
done

View file

@ -0,0 +1,17 @@
{
system,
inputs,
...
}@args: let
lib = inputs.nixpkgs.lib;
exportFile = import ./exports.nix args;
inherit (exportFile) exports exportsSystems;
inherit (inputs.std.lib) string list set;
packages = inputs.self.packages.${system};
inherit (inputs.self.legacyPackages.${system}) pkgs;
nf-actions-test = pkgs.writeShellScriptBin "nf-actions-test" ''
${exports}
${exportsSystems}
source ${./actions-test.sh}
'';
in nf-actions-test

20
wrappers/nf-generate.nix Normal file
View file

@ -0,0 +1,20 @@
{
system,
inputs,
...
}@args: let
lib = inputs.nixpkgs.lib;
exportFile = import ./exports.nix args;
inherit (exportFile) exports exportsSystems;
inherit (lib.strings) makeBinPath;
inherit (inputs.std.lib) string list set;
packages = inputs.self.packages.${system};
inherit (inputs.self.legacyPackages.${system}) pkgs;
nf-generate = pkgs.writeShellScriptBin "nf-generate" ''
${exports}
export PATH="$PATH:${makeBinPath [pkgs.jq]}"
NF_INPUT_CI=${string.escapeShellArg inputs.ci}
NF_CONFIG_FILES=(${string.concatMapSep " " string.escapeShellArg ci.workflowConfigs})
source ${../ci/generate.sh}
'';
in nf-generate