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

104 lines
2.5 KiB
Nix
Raw Normal View History

2024-09-25 12:08:34 +02:00
let
inputs = import ./npins;
system = "x86_64-linux";
pkgs = import inputs.nixpkgs { config = { }; overlays = [ ]; system = builtins.currentSystem; };
lib = import "${inputs.nixpkgs}/lib" // { inherit nixosSystem; };
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;
modules = args.modules;
}
// builtins.removeAttrs args [ "modules" ]
);
in
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 = {
mastodon = nixosSystem {
inherit system;
modules = with nixosModules; [
disko
disk-layout
interactive-vm
mastodon-vm
];
};
peertube = nixosSystem {
inherit system;
modules = with nixosModules; [
disko
disk-layout
interactive-vm
peertube-vm
];
};
pixelfed = nixosSystem {
inherit system;
modules = with nixosModules; [
disko
disk-layout
interactive-vm
pixelfed-vm
];
};
all = nixosSystem {
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
];
};
}