2024-01-22 15:50:05 -05:00
|
|
|
{
|
|
|
|
arion,
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
inherit
|
|
|
|
(lib)
|
|
|
|
filterAttrs
|
|
|
|
hasAttr
|
|
|
|
mapAttrs
|
|
|
|
mkEnableOption
|
|
|
|
mkForce
|
|
|
|
mkIf
|
|
|
|
mkOption
|
|
|
|
optionalAttrs
|
|
|
|
types
|
|
|
|
;
|
|
|
|
|
|
|
|
inherit (config.vars) mainUser;
|
|
|
|
|
|
|
|
cfg = config.arion;
|
|
|
|
in {
|
|
|
|
imports = [arion.nixosModules.arion];
|
|
|
|
|
|
|
|
options.arion = {
|
2024-06-24 12:30:49 -04:00
|
|
|
enable = mkEnableOption "My custom arion config layer module";
|
2024-01-22 15:50:05 -05:00
|
|
|
|
|
|
|
rwDataDir = mkOption {
|
|
|
|
default = "/var/lib/arion";
|
|
|
|
type = types.str;
|
2024-06-24 12:30:49 -04:00
|
|
|
description = ''
|
2024-01-22 15:50:05 -05:00
|
|
|
Directory to place persistent data in
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
projects = mkOption {
|
|
|
|
default = {};
|
2024-06-24 12:30:49 -04:00
|
|
|
description = ''
|
2024-01-22 15:50:05 -05:00
|
|
|
Declarative specification of docker-compose in nix.
|
|
|
|
'';
|
|
|
|
type = types.attrs;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
users.extraUsers.${mainUser}.extraGroups = ["docker"];
|
|
|
|
|
|
|
|
virtualisation = {
|
|
|
|
docker = {
|
|
|
|
enable = true;
|
|
|
|
storageDriver = "btrfs";
|
|
|
|
};
|
|
|
|
|
|
|
|
arion = {
|
|
|
|
backend = "docker";
|
|
|
|
|
|
|
|
projects =
|
|
|
|
mapAttrs (n: v: {
|
|
|
|
# https://docs.hercules-ci.com/arion/options
|
|
|
|
settings = {
|
|
|
|
enableDefaultNetwork = v.enableDefaultNetwork or true;
|
|
|
|
|
|
|
|
networks =
|
|
|
|
optionalAttrs (hasAttr "networks" v)
|
|
|
|
v.networks;
|
|
|
|
|
|
|
|
services =
|
|
|
|
mapAttrs (n': v': {
|
|
|
|
# https://github.com/hercules-ci/arion/issues/169#issuecomment-1301370634
|
|
|
|
build.image = let
|
|
|
|
importImage = file: pkgs.callPackage file pkgs;
|
|
|
|
in
|
|
|
|
mkForce (importImage v'.image);
|
|
|
|
|
|
|
|
service =
|
2024-02-28 22:22:14 -05:00
|
|
|
(filterAttrs (attrName: _:
|
|
|
|
attrName != "image" && attrName != "extraOptions")
|
|
|
|
v')
|
2024-01-22 15:50:05 -05:00
|
|
|
# By default set the container_name to the attrset's name
|
|
|
|
// (optionalAttrs (! hasAttr "container_name" v') {
|
|
|
|
container_name = n';
|
|
|
|
});
|
2024-02-28 22:22:14 -05:00
|
|
|
|
|
|
|
out.service =
|
|
|
|
optionalAttrs
|
|
|
|
(hasAttr "extraOptions" v')
|
|
|
|
v'.extraOptions;
|
2024-01-22 15:50:05 -05:00
|
|
|
})
|
|
|
|
v;
|
|
|
|
};
|
|
|
|
})
|
|
|
|
cfg.projects;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
# Script for updating the images of all images of a compose.nix file
|
|
|
|
environment.systemPackages = with pkgs; [
|
2024-07-20 22:02:22 -04:00
|
|
|
(callPackage ./updateImage.nix {})
|
2024-01-22 15:50:05 -05:00
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|