simple-nixos-fediverse/flake.nix
Valentin Gagarin 3d8eadda4d WIP: add installer generation and deployment scripts
This doesn't work yet for reasons that are not entirely clear to me:

    > nix run .#deploy.all --show-trace
    error: 'nixosConfigurations.all.type' is not a string but

sic!

    > nix build .#installers.all
    warning: Git tree '/home/vg/src/simple-nixos-fediverse' is dirty
    error:
           … while calling the 'derivationStrict' builtin

             at /builtin/derivation.nix:9:12: (source not available)

           … while evaluating derivation 'nixos-24.11.20240815.9286249-x86_64-linux.iso'
             whose name attribute is located at /nix/store/nqqkj0pwx2ymv8rxpw1m80zd4fxkvk0s-source/pkgs/stdenv/generic/make-derivation.nix:334:7

           … while evaluating attribute 'sources' of derivation 'nixos-24.11.20240815.9286249-x86_64-linux.iso'

             at /nix/store/nqqkj0pwx2ymv8rxpw1m80zd4fxkvk0s-source/nixos/lib/make-iso9660-image.nix:76:3:

               75|
               76|   sources = map (x: x.source) contents;
                 |   ^
               77|   targets = map (x: x.target) contents;

           (stack trace truncated; use '--show-trace' to show the full trace)

           error: Could not load a value as a module, because it is of type "flake", in file /nix/store/nqqkj0pwx2ymv8rxpw1m80zd4fxkvk0s-source/flake.nix.

???
2024-09-25 11:57:03 +02:00

105 lines
2.5 KiB
Nix

{
description = "Testing mastodon configurations";
inputs = {
nixpkgs.url = "github:radvendii/nixpkgs/nixos_rebuild_tests";
disko.url = "github:nix-community/disko";
};
outputs = { self, nixpkgs, disko, ... }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
in {
nixosModules = {
## Fediversity modules
fediversity = import ./fediversity;
## VM-specific modules
inherit (disko.nixosModules) disko;
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;
};
nixosConfigurations = {
mastodon = nixpkgs.lib.nixosSystem {
inherit system;
modules = with self.nixosModules; [
disko
disk-layout
fediversity
interactive-vm
mastodon-vm
];
};
peertube = nixpkgs.lib.nixosSystem {
inherit system;
modules = with self.nixosModules; [
disko
disk-layout
fediversity
interactive-vm
peertube-vm
];
};
pixelfed = nixpkgs.lib.nixosSystem {
inherit system;
modules = with self.nixosModules; [
disko
disk-layout
fediversity
interactive-vm
pixelfed-vm
];
};
all = nixpkgs.lib.nixosSystem {
inherit system;
modules = with self.nixosModules; [
disko
disk-layout
fediversity
interactive-vm
peertube-vm
pixelfed-vm
mastodon-vm
];
};
};
# build with
# nix build .#installers.<config>
installers =
let
installer = (import ./installer.nix) nixpkgs;
in
nixpkgs.lib.mapAttrs (_: config: installer config) self.nixosConfigurations;
# run with
# nix run .#deploy.<machine>
deploy =
let
deployCommand = (pkgs.callPackage ./deploy.nix {});
in
nixpkgs.lib.mapAttrs (name: config: deployCommand name config) self.nixosConfigurations;
checks.${system} = {
mastodon-garage = import ./tests/mastodon-garage.nix { inherit pkgs self; };
pixelfed-garage = import ./tests/pixelfed-garage.nix { inherit pkgs self; };
};
devShells.${system}.default = pkgs.mkShell {
packages = with pkgs; [
nil
];
};
};
}