-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib: add collectFiles and collectFilesAt #43
Conversation
An example on how it works:
{
services.minecraft-servers.servers.cool-modpack = {
enable = true;
package = pkgs.fabricServers.fabric-1_18_2-0_14_9;
symlinks = collectFilesAt modpack "mods" // {
"mods/FabricProxy-lite.jar" = pkgs.fetchurl rec {
pname = "FabricProxy-Lite";
version = "1.1.6";
url = "https://cdn.modrinth.com/data/8dI2tmqs/versions/v${version}/${pname}-${version}.jar";
hash = "sha256-U+nXvILXlYdx0vgomVDkKxj0dGCtw60qW22EK4FhAJk=";
};
};
files = collectFilesAt modpack "config" // {
"config/server-specific.conf".value = {
example = "foo-bar";
};
};
};
} |
Would it be good to have If files = {
config = {
"file1" = ...;
"file2" = ...;
};
}; to create
Then |
Hey! Sorry for taking so long to respond.
This is a very good idea and looks cleaner, will def get that in.
This sounds super nice and actually kinda solves some concerns with composability, I think. Sadly my current design for this PR has a major footgun. We currently cleanup files when shutting down the server, but removing files/symlinks entries from your nixos config will NOT remove the files (as the service isn't stopped with the previous generation's stop script)! This isn't a major concern when using a single derivation for a big-ish directory, for example: services.minecraft-servers.servers.cool-modpack = {
enable = true;
package = pkgs.fabricServers.fabric-1_18_2-0_14_9;
symlinks."mods" = "${modpack}/mods"
}; Removing mods from Once the entry is a single file, things get messy: services.minecraft-servers.servers.cool-modpack = {
enable = true;
package = pkgs.fabricServers.fabric-1_18_2-0_14_9;
symlinks = collectFilesAt modpack "mods" // {
"mods/FabricProxy-lite.jar" = pkgs.fetchurl rec {
pname = "FabricProxy-Lite";
version = "1.1.6";
url = "https://cdn.modrinth.com/data/8dI2tmqs/versions/v${version}/${pname}-${version}.jar";
hash = "sha256-U+nXvILXlYdx0vgomVDkKxj0dGCtw60qW22EK4FhAJk=";
};
}; As mentioned, the stop script will remove what's currently defined, not what was previously there. We'll have to special case this somehow. A few solutions I thought of:
|
I'm pretty sure it runs the stop script with the old configuration given |
SMH, for every common problem, there is already an elegant solution haha, had no idea about that. Will look into it. |
I think stopIfChanged is pretty limited (e.g. it won't work if we prefer to reload instead), so I decided to implement a file-attrs based solution (#116). |
0b4b9cb
to
5620998
Compare
Should be good to go. |
These are lib functions that recursively read a directory, and return files in the format expected by `files`/`symlinks`. This makes it possible to, for example, link all mods from a modpack, and still include additional mods/configs.
5620998
to
64c5496
Compare
This is a lib function that recursively reads a directory, and returns them in the format expected by
files
/symlinks
. This makes it possible to, for example, link all mods from a modpack, and still include additional mods.