feat: transfer wowmine to neuro
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
{
|
||||
nixpkgs ? builtins.fetchTarball {
|
||||
url = "https://github.com/NixOS/nixpkgs/archive/b25309931cfda5f0b8805f462a29897eeae50168.tar.gz";
|
||||
sha256 = "sha256-qMSsgG+9tIdx282dMqGuJAUK3t6F36clM6efd0rXfes=";
|
||||
},
|
||||
system ? "x86_64-linux",
|
||||
}:
|
||||
let
|
||||
evaluated = import (nixpkgs + "/nixos/lib/eval-config.nix") {
|
||||
inherit system;
|
||||
modules = [
|
||||
../wowmine-web.nix
|
||||
{
|
||||
boot.isContainer = true;
|
||||
networking.hostName = "neuro";
|
||||
system.stateVersion = "26.05";
|
||||
}
|
||||
];
|
||||
};
|
||||
inherit (evaluated) config pkgs;
|
||||
inherit (pkgs) lib;
|
||||
failedAssertions = map (a: a.message) (lib.filter (a: !a.assertion) config.assertions);
|
||||
selectedUnits = lib.filterAttrs (
|
||||
name: _: lib.hasPrefix "acme-" name || lib.hasPrefix "nginx" name
|
||||
) config.systemd.units;
|
||||
# Link the real generated unit files. The full NixOS system-unit directory
|
||||
# also contains unrelated package units and global boot target aliases.
|
||||
units = pkgs.runCommand "wowmine-web-units" { } (
|
||||
"mkdir -p $out\n"
|
||||
+ lib.concatStrings (lib.mapAttrsToList (name: unit:
|
||||
''
|
||||
ln -s ${unit.unit}/${name} $out/${name}
|
||||
''
|
||||
+ lib.concatMapStrings (alias: ''
|
||||
ln -s ${name} $out/${alias}
|
||||
'') unit.aliases
|
||||
+ lib.concatStrings (lib.mapAttrsToList (option: suffix:
|
||||
lib.concatMapStrings (target: ''
|
||||
mkdir -p $out/${target}.${suffix}
|
||||
ln -s ../${name} $out/${target}.${suffix}/${name}
|
||||
'') unit.${option}
|
||||
) {
|
||||
wantedBy = "wants";
|
||||
requiredBy = "requires";
|
||||
upheldBy = "upholds";
|
||||
})
|
||||
) selectedUnits)
|
||||
);
|
||||
nginxConfig = builtins.head (
|
||||
builtins.match ".* -c '([^']+)'" config.systemd.services.nginx.serviceConfig.ExecStart
|
||||
);
|
||||
metadata = {
|
||||
nixpkgsRevision = "b25309931cfda5f0b8805f462a29897eeae50168";
|
||||
inherit system failedAssertions nginxConfig;
|
||||
assertionCount = builtins.length config.assertions;
|
||||
warnings = config.warnings;
|
||||
users = lib.genAttrs [ "nginx" "acme" ] (
|
||||
name: {
|
||||
inherit (config.users.users.${name}) uid group extraGroups home homeMode isSystemUser;
|
||||
}
|
||||
);
|
||||
groups = lib.genAttrs [ "nginx" "acme" ] (
|
||||
name: {
|
||||
inherit (config.users.groups.${name}) gid members;
|
||||
}
|
||||
);
|
||||
units = lib.mapAttrs (
|
||||
_: unit: {
|
||||
inherit (unit) wantedBy requiredBy upheldBy aliases;
|
||||
text = unit.text;
|
||||
}
|
||||
) selectedUnits;
|
||||
certificate = {
|
||||
inherit (config.security.acme.certs."wowmine.bfs.band")
|
||||
directory group webroot email server reloadServices renewInterval renewJitter;
|
||||
};
|
||||
sourceFiles = [ "wowmine-web.nix" "wowmine-site/eval.nix" "wowmine-site/static" ];
|
||||
siteRoot = config.services.nginx.virtualHosts."wowmine.bfs.band".locations."^~ /wowmine/".alias;
|
||||
runtimeRoots = [ "/var/www/wowmine/public/minecraft/wowmine" ];
|
||||
};
|
||||
metadataFile = pkgs.writeText "wowmine-web-metadata.json" (builtins.toJSON metadata);
|
||||
bundle = pkgs.runCommand "wowmine-web-scoped" { } ''
|
||||
mkdir -p $out/tmpfiles.d
|
||||
ln -s ${units} $out/units
|
||||
ln -s ${nginxConfig} $out/nginx.conf
|
||||
ln -s ${metadataFile} $out/metadata.json
|
||||
for package in ${toString config.systemd.tmpfiles.packages}; do
|
||||
if [ -e "$package/lib/tmpfiles.d/10-acme.conf" ]; then
|
||||
ln -s "$package/lib/tmpfiles.d/10-acme.conf" $out/tmpfiles.d/
|
||||
fi
|
||||
done
|
||||
test -e $out/tmpfiles.d/10-acme.conf
|
||||
'';
|
||||
in
|
||||
assert lib.assertMsg (failedAssertions == [ ]) (lib.concatStringsSep "\n" failedAssertions);
|
||||
{
|
||||
inherit bundle metadata units nginxConfig;
|
||||
}
|
||||
Reference in New Issue
Block a user