quakeflake/flake.nix

78 lines
2.1 KiB
Nix
Raw Normal View History

2021-12-02 01:59:44 +01:00
{
description = "Quake 3 Arena Dedicated Server";
inputs = {
2022-08-13 20:47:06 +02:00
nixpkgs.url = "github:nixos/nixpkgs/release-22.05";
2021-12-02 01:59:44 +01:00
};
outputs = inputs@{ self, nixpkgs }: {
2022-08-13 20:47:06 +02:00
apps.x86_64-linux = rec {
q3a = {
type = "app";
program = "${self.packages.x86_64-linux.q3a}/bin/q3a";
};
default = q3a;
};
2021-12-02 01:59:44 +01:00
packages = builtins.mapAttrs (system: _:
let
inherit (self.nixosConfigurations) quakeserver;
2021-12-02 02:43:25 +01:00
remote = "2a01:4f9:4b:39ec::1c";
2021-12-02 01:59:44 +01:00
in rec {
rootfs = quakeserver.config.system.build.toplevel;
container = quakeserver.config.system.build.tarball;
deploy = with nixpkgs.legacyPackages.${system};
writeScriptBin "deploy" ''
#! ${runtimeShell} -e
2021-12-02 02:43:25 +01:00
nix copy --to ssh://root@${remote} ${rootfs}
ssh root@${remote} ${rootfs}/bin/switch-to-configuration switch
2021-12-02 01:59:44 +01:00
'';
2022-08-13 20:47:06 +02:00
q3a = with nixpkgs.legacyPackages.${system}; buildEnv {
name = "q3a";
paths = [
quake3e
(runCommandNoCC "baseq3" {} ''
mkdir -p $out/lib/baseq3
ln -s ${self.packages.${system}.isoBaseq3}/* $out/lib/baseq3/
ln -s ${quake3pointrelease}/baseq3/* $out/lib/baseq3/
ln -s ${quake3hires}/baseq3/* $out/lib/baseq3/
'')
(writeScriptBin "q3a" ''
#! ${runtimeShell} -e
exec $(dirname $0)/quake3e +set fs_basepath $(dirname $0)/../lib
'')
];
};
2021-12-02 01:59:44 +01:00
} //
import ./pkgs/baseq3.nix (inputs // { inherit system; })
) { x86_64-linux = true; };
nixosModules = {
container = import ./nixos-modules/container.nix;
quake3ded = import ./nixos-modules/quake3ded.nix;
};
nixosConfigurations.quakeserver = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
extraArgs = {
inherit self;
};
modules = [
"${nixpkgs}/nixos/modules/virtualisation/lxc-container.nix"
self.nixosModules.container
self.nixosModules.quake3ded
{
networking.hostName = "quakeserver";
}
];
};
};
}