Skip to content

Commit 8ee6637

Browse files
committed
OCI containers as nixos services
1 parent a33d077 commit 8ee6637

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

nix/misc.nix

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,39 @@ in
6464
};
6565
};
6666
};
67+
mkOci = {
68+
srv,
69+
img,
70+
cfgs ? [],
71+
dirs ? [],
72+
}: {
73+
lib,
74+
pkgs,
75+
config,
76+
...
77+
}:
78+
with lib; {
79+
imports = [
80+
];
81+
82+
options = {
83+
services."${srv}" = {
84+
enable = mkOption {
85+
default = false;
86+
type = types.bool;
87+
};
88+
};
89+
};
90+
91+
config = mkIf config.services."${srv}".enable {
92+
virtualisation.oci-containers.containers.${srv} = {
93+
image = img;
94+
volumes =
95+
(map (x: x + ":" + x + ":ro") cfgs)
96+
++ (map (x: x + ":" + x) dirs);
97+
cmd =
98+
concatMap (x: ["-f" x]) cfgs;
99+
};
100+
};
101+
};
67102
}

prv

Submodule prv updated from b6533e2 to 82e9951

0 commit comments

Comments
 (0)