From fc2acc13d80c3e633f3b19b160b45b99e7e009f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20=E2=80=9CNiols=E2=80=9D=20Jeannerod?= Date: Thu, 14 Nov 2024 01:10:00 +0100 Subject: [PATCH] Integrate services as a flake part --- flake.nix | 11 ++- services/flake-part.nix | 14 ++++ services/flake.nix | 109 ----------------------------- services/tests/mastodon-garage.nix | 5 +- services/tests/pixelfed-garage.nix | 5 +- 5 files changed, 27 insertions(+), 117 deletions(-) create mode 100644 services/flake-part.nix delete mode 100644 services/flake.nix diff --git a/flake.nix b/flake.nix index 7192e50..403d4d7 100644 --- a/flake.nix +++ b/flake.nix @@ -15,7 +15,11 @@ "aarch64-darwin" ]; - imports = [ inputs.git-hooks.flakeModule ]; + imports = [ + inputs.git-hooks.flakeModule + + ./services/flake-part.nix + ]; perSystem = { config, pkgs, ... }: @@ -44,7 +48,10 @@ }; }; - devShells.default = pkgs.mkShell { shellHook = config.pre-commit.installationScript; }; + devShells.default = pkgs.mkShell { + packages = [ pkgs.nil ]; + shellHook = config.pre-commit.installationScript; + }; }; }; } diff --git a/services/flake-part.nix b/services/flake-part.nix new file mode 100644 index 0000000..01c941a --- /dev/null +++ b/services/flake-part.nix @@ -0,0 +1,14 @@ +{ self, ... }: + +{ + flake.nixosModules.fediversity = import ./fediversity; + + perSystem = + { pkgs, ... }: + { + checks = { + mastodon-garage = import ./tests/mastodon-garage.nix { inherit self pkgs; }; + pixelfed-garage = import ./tests/pixelfed-garage.nix { inherit self pkgs; }; + }; + }; +} diff --git a/services/flake.nix b/services/flake.nix deleted file mode 100644 index c350d80..0000000 --- a/services/flake.nix +++ /dev/null @@ -1,109 +0,0 @@ -{ - inputs = { - nixpkgs.url = "github:radvendii/nixpkgs/nixos_rebuild_tests"; - nixpkgs-latest.url = "github:nixos/nixpkgs"; - - pixelfed = { - url = "github:pixelfed/pixelfed?ref=v0.12.3"; - flake = false; - }; - }; - - outputs = - { - self, - nixpkgs, - nixpkgs-latest, - pixelfed, - }: - let - system = "x86_64-linux"; - lib = nixpkgs.lib; - pkgs = nixpkgs.legacyPackages.${system}; - pkgsLatest = nixpkgs-latest.legacyPackages.${system}; - bleedingFediverseOverlay = ( - _: _: { - pixelfed = pkgsLatest.pixelfed.overrideAttrs (old: { - src = pixelfed; - patches = (old.patches or [ ]) ++ [ ./fediversity/pixelfed-group-permissions.patch ]; - }); - ## TODO: give mastodon, peertube the same treatment - } - ); - in - { - nixosModules = { - ## Bleeding-edge fediverse packages - bleedingFediverse = { - nixpkgs.overlays = [ bleedingFediverseOverlay ]; - }; - ## Fediversity modules - fediversity = import ./fediversity; - - ## VM-specific modules - interactive-vm = import ./vm/interactive-vm.nix; - garage-vm = import ./vm/garage-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; [ - bleedingFediverse - fediversity - interactive-vm - garage-vm - mastodon-vm - ]; - }; - - peertube = nixpkgs.lib.nixosSystem { - inherit system; - modules = with self.nixosModules; [ - bleedingFediverse - fediversity - interactive-vm - garage-vm - peertube-vm - ]; - }; - - pixelfed = nixpkgs.lib.nixosSystem { - inherit system; - modules = with self.nixosModules; [ - bleedingFediverse - fediversity - interactive-vm - garage-vm - pixelfed-vm - ]; - }; - - all = nixpkgs.lib.nixosSystem { - inherit system; - modules = with self.nixosModules; [ - bleedingFediverse - fediversity - interactive-vm - garage-vm - peertube-vm - pixelfed-vm - mastodon-vm - ]; - }; - }; - - 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 { - inputs = with pkgs; [ nil ]; - shellHook = self.checks.${system}.pre-commit.shellHook; - }; - }; -} diff --git a/services/tests/mastodon-garage.nix b/services/tests/mastodon-garage.nix index 242e865..b0a9d62 100644 --- a/services/tests/mastodon-garage.nix +++ b/services/tests/mastodon-garage.nix @@ -43,10 +43,9 @@ pkgs.nixosTest { { virtualisation.memorySize = lib.mkVMOverride 4096; imports = with self.nixosModules; [ - bleedingFediverse fediversity - garage-vm - mastodon-vm + ../vm/garage-vm.nix + ../vm/mastodon-vm.nix ]; # TODO: pair down environment.systemPackages = with pkgs; [ diff --git a/services/tests/pixelfed-garage.nix b/services/tests/pixelfed-garage.nix index bdac402..849a45c 100644 --- a/services/tests/pixelfed-garage.nix +++ b/services/tests/pixelfed-garage.nix @@ -143,10 +143,9 @@ pkgs.nixosTest { cores = 8; }; imports = with self.nixosModules; [ - bleedingFediverse fediversity - garage-vm - pixelfed-vm + ../vm/garage-vm.nix + ../vm/pixelfed-vm.nix ]; # TODO: pair down environment.systemPackages = with pkgs; [