2024-06-21 12:33:38 -05:00
|
|
|
# github.com/brianmcgee has lots of great ideas for going above and beyond for this
|
|
|
|
|
{
|
2024-11-18 21:22:32 -06:00
|
|
|
description = "Greg's homepage";
|
|
|
|
|
inputs = {
|
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
|
|
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
|
|
|
|
process-compose.url = "github:Platonic-Systems/process-compose-flake";
|
2024-11-18 21:31:43 -06:00
|
|
|
hooks.url = "github:cachix/git-hooks.nix";
|
2024-11-18 21:22:32 -06:00
|
|
|
};
|
2024-06-21 12:33:38 -05:00
|
|
|
|
2024-11-18 21:22:32 -06:00
|
|
|
outputs =
|
|
|
|
|
{ flake-parts, nixpkgs, ... }@inputs:
|
|
|
|
|
let
|
|
|
|
|
lib = nixpkgs.lib;
|
|
|
|
|
providers = [
|
|
|
|
|
"qemu"
|
|
|
|
|
"virtualbox-iso"
|
|
|
|
|
"hyperv-iso"
|
|
|
|
|
];
|
|
|
|
|
distros = import ./distros;
|
|
|
|
|
# Inserts the distro name into each element in the list
|
|
|
|
|
insertNames = lib.attrsets.mapAttrsToList (
|
|
|
|
|
distro: val: (builtins.map (x: x // { inherit distro; }) val)
|
|
|
|
|
) distros;
|
|
|
|
|
# Flattens all the distros into a single list
|
|
|
|
|
flat = lib.lists.flatten insertNames;
|
|
|
|
|
# Combines providers list with flattened list
|
|
|
|
|
withProviders = lib.attrsets.mapCartesianProduct ({ d, provider }: d // { inherit provider; }) {
|
|
|
|
|
d = flat;
|
|
|
|
|
provider = providers;
|
|
|
|
|
};
|
2024-11-18 23:28:04 -06:00
|
|
|
active = builtins.filter (
|
|
|
|
|
x:
|
|
|
|
|
!(x.eol or false) && ((lib.lists.findFirstIndex (y: y == x.provider) (-1) (x.exclude or [ ])) == -1)
|
|
|
|
|
) withProviders;
|
2024-11-18 21:22:32 -06:00
|
|
|
name = d: "-${d.distro}-${d.arch}-${d.provider}-${d.version}";
|
|
|
|
|
distroFile = d: "distros/${d.distro}/${d.version}/${d.arch}.pkrvars.hcl";
|
|
|
|
|
in
|
|
|
|
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
|
|
|
|
flake = {
|
|
|
|
|
# Universal things
|
|
|
|
|
};
|
|
|
|
|
systems = [
|
|
|
|
|
"x86_64-linux"
|
|
|
|
|
"aarch64-linux"
|
|
|
|
|
];
|
|
|
|
|
perSystem =
|
|
|
|
|
{
|
|
|
|
|
pkgs,
|
|
|
|
|
self',
|
|
|
|
|
system,
|
|
|
|
|
...
|
|
|
|
|
}@inputs':
|
|
|
|
|
{
|
|
|
|
|
_module.args.pkgs = import inputs.nixpkgs {
|
|
|
|
|
inherit system;
|
|
|
|
|
config.allowUnfree = true;
|
|
|
|
|
};
|
2024-11-18 21:31:43 -06:00
|
|
|
|
|
|
|
|
devShells.default = pkgs.mkShell {
|
|
|
|
|
buildInputs = self'.checks.pre-commit.enabledPackages;
|
|
|
|
|
shellHook = self'.checks.pre-commit.shellHook;
|
|
|
|
|
|
|
|
|
|
packages =
|
|
|
|
|
(with pkgs; [
|
|
|
|
|
vagrant
|
|
|
|
|
])
|
|
|
|
|
++ (with self'.packages; [
|
|
|
|
|
cache
|
|
|
|
|
generate
|
|
|
|
|
shellcheck
|
|
|
|
|
validate
|
|
|
|
|
])
|
|
|
|
|
++ (builtins.map (d: self'.packages."build${name d}") withProviders);
|
2024-11-18 21:22:32 -06:00
|
|
|
# These commands will be shown in the motd that users read
|
|
|
|
|
# upon entering the shell
|
2024-11-18 21:31:43 -06:00
|
|
|
env = {
|
|
|
|
|
EFI_DIR = "${pkgs.OVMF.fd}/FV/";
|
|
|
|
|
PACKER_CONFIG_DIR = "./packer_config";
|
2024-12-24 00:23:26 -06:00
|
|
|
STORAGE_URL = "s3.thehellings.lan:9000";
|
2024-11-18 21:31:43 -06:00
|
|
|
};
|
2024-11-18 21:22:32 -06:00
|
|
|
};
|
2024-06-21 12:33:38 -05:00
|
|
|
|
2024-11-18 21:22:32 -06:00
|
|
|
# This is not special, this is just flakes
|
|
|
|
|
packages =
|
|
|
|
|
let
|
2024-11-18 23:28:04 -06:00
|
|
|
base =
|
|
|
|
|
prefix: d: args:
|
|
|
|
|
pkgs.writeShellApplication {
|
|
|
|
|
name = "${prefix}${name d}";
|
|
|
|
|
runtimeInputs = with pkgs; [
|
|
|
|
|
cdrtools
|
|
|
|
|
findutils
|
|
|
|
|
packer
|
|
|
|
|
qemu_full
|
|
|
|
|
vagrant
|
|
|
|
|
xorriso
|
|
|
|
|
];
|
|
|
|
|
text = ''
|
|
|
|
|
# This is a workaround for a goofy behavior in CI
|
|
|
|
|
if [ -e "''${PACKER_CONFIG_DIR}" ]; then
|
|
|
|
|
find "''${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";"
|
|
|
|
|
fi
|
|
|
|
|
packer init sources
|
|
|
|
|
packer build -only=${d.provider}.${d.arch} -var-file=${distroFile d} ${args} sources/
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
builds = lib.lists.foldr (
|
|
|
|
|
d: acc: acc // { "build${name d}" = (base "build" d "-except=upload -var headless=false"); }
|
|
|
|
|
) { } withProviders;
|
|
|
|
|
cibuilds = lib.lists.foldr (
|
|
|
|
|
d: acc: acc // { "ci${name d}" = (base "ci" d "-except=upload"); }
|
|
|
|
|
) { } withProviders;
|
|
|
|
|
uploads = lib.lists.foldr (
|
|
|
|
|
d: acc: acc // { "upload${name d}" = (base "upload" d ""); }
|
|
|
|
|
) { } withProviders;
|
2024-11-18 22:32:20 -06:00
|
|
|
qemu_list = builtins.map (d: { buildcmd = (name d); }) (
|
|
|
|
|
builtins.filter (x: x.provider == "qemu") active
|
2024-11-18 21:22:32 -06:00
|
|
|
);
|
2024-11-18 22:32:20 -06:00
|
|
|
vbox_list = builtins.map (d: { buildcmd = (name d); }) (
|
|
|
|
|
builtins.filter (x: x.provider == "virtualbox-iso") active
|
2024-11-18 21:22:32 -06:00
|
|
|
);
|
2024-11-18 22:32:20 -06:00
|
|
|
hyperv_list = builtins.map (d: { distro = distroFile d; }) (
|
|
|
|
|
builtins.filter (x: x.provider == "hyperv-iso") active
|
2024-11-18 21:22:32 -06:00
|
|
|
);
|
|
|
|
|
in
|
|
|
|
|
builds
|
|
|
|
|
// uploads
|
|
|
|
|
// cibuilds
|
|
|
|
|
// {
|
2024-11-18 22:26:17 -06:00
|
|
|
continue = (
|
|
|
|
|
import ./nix/continue.nix {
|
|
|
|
|
inherit
|
|
|
|
|
pkgs
|
2024-11-18 21:22:32 -06:00
|
|
|
qemu_list
|
|
|
|
|
vbox_list
|
|
|
|
|
hyperv_list
|
2024-11-18 22:26:17 -06:00
|
|
|
;
|
|
|
|
|
}
|
2024-11-18 21:22:32 -06:00
|
|
|
);
|
|
|
|
|
cache = pkgs.callPackage (import ./nix/cache.nix) { inherit active distroFile; };
|
|
|
|
|
validate = pkgs.callPackage (import ./nix/validate.nix) { };
|
|
|
|
|
cache-restore = pkgs.writeShellApplication {
|
|
|
|
|
name = "cache-restore";
|
|
|
|
|
runtimeInputs = with pkgs; [
|
|
|
|
|
jq
|
|
|
|
|
minio-client
|
|
|
|
|
packer
|
|
|
|
|
];
|
|
|
|
|
text = builtins.readFile ./cache-restore.sh;
|
|
|
|
|
};
|
2024-11-18 23:37:30 -06:00
|
|
|
generate = pkgs.callPackage (import ./nix/generate.nix) { };
|
|
|
|
|
shellcheck = pkgs.callPackage (import ./nix/shellcheck.nix) { };
|
2024-11-18 21:22:32 -06:00
|
|
|
};
|
2024-06-21 12:33:38 -05:00
|
|
|
|
2024-11-18 21:22:32 -06:00
|
|
|
checks = {
|
|
|
|
|
pre-commit = inputs.hooks.lib.${inputs'.system}.run {
|
|
|
|
|
src = ./.;
|
|
|
|
|
hooks = {
|
|
|
|
|
check-added-large-files.enable = true;
|
|
|
|
|
check-case-conflicts.enable = true;
|
|
|
|
|
check-merge-conflicts.enable = true;
|
|
|
|
|
check-symlinks.enable = true;
|
|
|
|
|
deadnix.enable = true;
|
|
|
|
|
end-of-file-fixer.enable = true;
|
|
|
|
|
fix-byte-order-marker.enable = true;
|
|
|
|
|
mixed-line-endings.enable = true;
|
|
|
|
|
nixfmt-rfc-style.enable = true;
|
|
|
|
|
trim-trailing-whitespace.enable = true;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
2024-06-21 12:33:38 -05:00
|
|
|
}
|