1
0
Fork 0
mirror of https://github.com/zhaofengli/attic.git synced 2024-12-14 11:57:30 +00:00
attic/flake/nix-versions.nix
2024-08-30 12:33:28 -04:00

64 lines
1.7 KiB
Nix

{ lib, flake-parts-lib, config, ... }:
let
inherit (lib)
mkOption
types
;
inherit (flake-parts-lib)
mkPerSystemOption
;
in
{
options = {
perSystem = mkPerSystemOption {
options.attic.nix-versions = {
versions = mkOption {
type = types.attrsOf types.package;
default = {};
};
manifestFile = mkOption {
type = types.package;
};
};
options.internalMatrix = mkOption {
type = types.attrsOf (types.attrsOf types.package);
};
};
};
config = {
flake.internalMatrix = lib.mapAttrs (system: ps: ps.internalMatrix) config.allSystems;
perSystem = { self', pkgs, config, cranePkgs, ... }: let
cfg = config.attic.nix-versions;
in {
attic.nix-versions = {
versions = {
default = pkgs.nix;
"2.20" = pkgs.nixVersions.nix_2_20;
"2.24" = pkgs.nixVersions.nix_2_24;
};
manifestFile = let
manifest = lib.mapAttrs (_: nix: {
inherit nix;
shellHook = ''
export NIX_INCLUDE_PATH="${lib.getDev nix}/include"
export NIX_CFLAGS_COMPILE="-isystem $NIX_INCLUDE_PATH $NIX_CFLAGS_COMPILE"
export NIX_LDFLAGS="-L${nix}/lib $NIX_LDFLAGS"
export PKG_CONFIG_PATH="${lib.getDev nix}/lib/pkgconfig:$PKG_CONFIG_PATH"
export PATH="${lib.getBin nix}/bin:$PATH"
'';
}) cfg.versions;
in pkgs.writeText "nix-versions.json" (builtins.toJSON manifest);
};
internalMatrix = lib.mapAttrs (_: nix: let
cranePkgs' = cranePkgs.override { inherit nix; };
in {
inherit (cranePkgs') attic-tests cargoArtifacts;
}) cfg.versions;
};
};
}