Migrate packages module to clanServices

This commit is contained in:
pinpox
2025-06-12 10:35:10 +02:00
parent 8435c71da7
commit faa1bf21e0
5 changed files with 106 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
---
description = "Define package sets from nixpkgs and install them on one or more machines"
categories = ["System"]
features = [ "inventory" ]
features = [ "inventory" "deprecated" ]
---

View File

@@ -0,0 +1,41 @@
{ ... }:
{
_class = "clan.service";
manifest.name = "clan-core/packages";
manifest.description = "Define package sets from nixpkgs and install them on one or more machines";
manifest.categories = [
"System"
];
roles.default = {
interface =
{ lib, ... }:
{
options.packages = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
example = [ "cowsay" ];
description = "The packages to install on the machine";
};
};
perInstance =
{ settings, ... }:
{
nixosModule =
{
lib,
pkgs,
...
}:
{
environment.systemPackages = map (
pName: lib.getAttrFromPath (lib.splitString "." pName) pkgs
) settings.packages;
};
};
};
}

View File

@@ -0,0 +1,19 @@
{ lib, self, ... }:
{
clan.modules = {
packages = lib.modules.importApply ./default.nix { };
};
perSystem =
{ pkgs, ... }:
{
checks = lib.optionalAttrs (pkgs.stdenv.isLinux) {
packages = import ./tests/vm/default.nix {
inherit pkgs;
clan-core = self;
nixosLib = import (self.inputs.nixpkgs + "/nixos/lib") { };
};
};
};
}

View File

@@ -0,0 +1,41 @@
{
pkgs,
nixosLib,
clan-core,
...
}:
nixosLib.runTest (
{ ... }:
{
imports = [
clan-core.modules.nixosVmTest.clanTest
];
hostPkgs = pkgs;
name = "packages";
clan = {
directory = ./.;
modules."@clan/packages" = ../../default.nix;
inventory = {
machines.server = { };
instances.default = {
module.name = "@clan/packages";
roles.default.machines."server".settings = {
packages = [ "cbonsai" ];
};
};
};
};
nodes.server = { };
testScript = ''
start_all()
server.succeed("cbonsai")
'';
}
)

View File

@@ -0,0 +1,4 @@
{
"publickey": "age1qm0p4vf9jvcnn43s6l4prk8zn6cx0ep9gzvevxecv729xz540v8qa742eg",
"type": "age"
}