Skip to content

Commit 5d2af64

Browse files
committed
feat: allow disabling of network name aliases & usage - podman quadlets
Signed-off-by: Reputable2722 <153411261+Reputable2772@users.noreply.github.com>
1 parent 4841e7e commit 5d2af64

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

Modules/Home-Manager/quadlets.nix

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ let
7070
appendEnv = true;
7171
appendEnvFiles = true;
7272
unitDefaults = true;
73+
networkNameAlias = true;
7374
# Opt out either with this flag, or by setting :noMap at the end of a specific volume
7475
mapVolumes = true;
7576
};
@@ -99,7 +100,7 @@ let
99100
};
100101

101102
unitDefaults =
102-
qVal:
103+
qVal: qOpts:
103104
{
104105
Install.WantedBy = [ "default.target" ];
105106
Service = {
@@ -109,7 +110,7 @@ let
109110
};
110111
}
111112
// optionalAttrs (isContainer qVal) {
112-
Container.PodmanArgs = "--network-alias ${qVal.Container.ContainerName} --user 0:0";
113+
Container.PodmanArgs = "${lib.optionalString qOpts.networkNameAlias "--network-alias ${qVal.Container.ContainerName}"} --user 0:0";
113114
};
114115

115116
mkdirOp = qVal: {
@@ -158,6 +159,14 @@ let
158159
# Merge container & default options.
159160
quadletOptions = defaultOptions // (qVal.__options or { });
160161

162+
/**
163+
Ideal Preprocessing ordering -
164+
unitDefaults -> appendEnv -> appendEnvFiles -> mapVolumes (special) -> mkdirOp
165+
166+
Current ordering
167+
mapVolumes (special) -> unitDefaults -> mkdirOp -> appendEnv -> appendEnvFiles
168+
*/
169+
161170
# Map only volumes separately, since volumes have to be overwritten entirely,
162171
# rather than be merged.
163172
mappedVolumes =
@@ -178,7 +187,9 @@ let
178187
qVal;
179188
preProcess = foldl' (acc: elem: (lib'.deepMerge (elem acc) acc)) mappedVolumes (
180189
[
181-
(f: optionalAttrs quadletOptions.unitDefaults (unitDefaults f))
190+
# Temp fix for hp-laptop not using bridge networking.
191+
# TODO: Write a better pre-processing script later.
192+
(f: optionalAttrs quadletOptions.unitDefaults (unitDefaults f quadletOptions))
182193
]
183194
++ (lib.optionals (isContainer qVal) [
184195
(f: optionalAttrs quadletOptions.mkdir (mkdirOp f))

Users/Selfhosted/home.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
enable = true;
66
quadlets = {
77
"minecraft.container" = {
8+
__options.networkNameAlias = false;
89
Container = {
910
ContainerName = "minecraft";
1011
Image = "docker.io/itzg/minecraft-server";
@@ -18,6 +19,7 @@
1819
};
1920

2021
"ollama.container" = {
22+
__options.networkNameAlias = false;
2123
Container = {
2224
ContainerName = "ollama";
2325
GroupAdd = "keep-groups";
@@ -35,6 +37,7 @@
3537
};
3638

3739
"ddns-updater.container" = {
40+
__options.networkNameAlias = false;
3841
Container = {
3942
ContainerName = "ddns-updater";
4043
Image = "docker.io/favonia/cloudflare-ddns:latest";

0 commit comments

Comments
 (0)