This repository has been archived on 2024-11-13. You can view files and clone it, but cannot push or open issues or pull requests.
simple-nixos-fediverse/default.nix

106 lines
2.5 KiB
Nix
Raw Normal View History

2024-09-25 12:23:34 +02:00
{ inputs ? import ./npins
, system ? builtins.currentSystem
, pkgs ? import inputs.nixpkgs { config = { }; overlays = [ ]; inherit system; }
, lib ? import "${inputs.nixpkgs}/lib"
// {
nixosSystem = args:
import "${inputs.nixpkgs}/nixos/lib/eval-config.nix"
(
{
inherit lib;
# Allow system to be set modularly in nixpkgs.system.
# We set it to null, to remove the "legacy" entrypoint's
# non-hermetic default.
system = null;
2024-09-25 12:08:34 +02:00
2024-09-25 12:23:34 +02:00
modules = args.modules;
}
// builtins.removeAttrs args [ "modules" ]
);
}
,
}:
2024-09-25 12:08:34 +02:00
rec {
nixosModules = {
disko = "${inputs.disko}/module.nix";
disk-layout = import ./vm/disk-layout.nix;
interactive-vm = import ./vm/interactive-vm.nix;
mastodon-vm = import ./vm/mastodon-vm.nix;
peertube-vm = import ./vm/peertube-vm.nix;
pixelfed-vm = import ./vm/pixelfed-vm.nix;
};
# test with
# nix-build -A nixosConfigurations.<config>.installTest
nixosConfigurations = {
2024-09-25 12:23:34 +02:00
mastodon = lib.nixosSystem {
2024-09-25 12:08:34 +02:00
inherit system;
modules = with nixosModules; [
disko
disk-layout
interactive-vm
mastodon-vm
];
};
2024-09-25 12:23:34 +02:00
peertube = lib.nixosSystem {
2024-09-25 12:08:34 +02:00
inherit system;
modules = with nixosModules; [
disko
disk-layout
interactive-vm
peertube-vm
];
};
2024-09-25 12:23:34 +02:00
pixelfed = lib.nixosSystem {
2024-09-25 12:08:34 +02:00
inherit system;
modules = with nixosModules; [
disko
disk-layout
interactive-vm
pixelfed-vm
];
};
2024-09-25 12:23:34 +02:00
all = lib.nixosSystem {
2024-09-25 12:08:34 +02:00
inherit system;
modules = with nixosModules; [
interactive-vm
disko
disk-layout
peertube-vm
pixelfed-vm
mastodon-vm
];
};
};
# build with
# nix-build -A installers.<config>
installers =
let
installer = (import ./installer.nix) { inherit lib; outPath = inputs.nixpkgs; };
in
lib.mapAttrs (_: config: installer config) nixosConfigurations;
# run with
# $(nix-build -A deploy.<machine> --no-out-link)/bin/deploy
deploy =
let
deployCommand = (pkgs.callPackage ./deploy.nix { });
in
lib.mapAttrs (name: config: deployCommand name config) nixosConfigurations;
tests = {
mastodon-garage = import ./tests/mastodon-garage.nix { inherit pkgs; };
pixelfed-garage = import ./tests/pixelfed-garage.nix { inherit pkgs; };
};
shell = pkgs.mkShell {
packages = with pkgs; [
nil
];
};
}