flake.nix: Add app to start VM through nix run
This commit is contained in:
parent
e512e73b5e
commit
dea9032530
46
flake.nix
46
flake.nix
|
@ -92,6 +92,32 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
apps.${system}.default = let
|
||||||
|
inherit (self.nixosConfigurations.vm.config.system.build) vm;
|
||||||
|
inherit (nixpkgs.legacyPackages.${system}) writeShellScript;
|
||||||
|
inherit (nixpkgs.lib.attrsets) mapAttrsToList;
|
||||||
|
inherit (nixpkgs.lib.strings) concatStringsSep;
|
||||||
|
ports = {
|
||||||
|
"2222" = "2222";
|
||||||
|
"3080" = "80";
|
||||||
|
"3443" = "443";
|
||||||
|
"2221" = "2221";
|
||||||
|
"21025" = "21025"; # Starbound
|
||||||
|
};
|
||||||
|
QEMU_NET_OPTS =
|
||||||
|
concatStringsSep ","
|
||||||
|
(mapAttrsToList
|
||||||
|
(host: vm: "hostfwd=::${host}-:${vm}")
|
||||||
|
ports);
|
||||||
|
in {
|
||||||
|
type = "app";
|
||||||
|
program = builtins.toString (writeShellScript "run-vm" ''
|
||||||
|
export QEMU_OPTS="-m 3941 -smp 2 -curses"
|
||||||
|
export QEMU_NET_OPTS="${QEMU_NET_OPTS}"
|
||||||
|
"${vm}/bin/run-tlaternet-vm"
|
||||||
|
'');
|
||||||
|
};
|
||||||
|
|
||||||
devShells.${system}.default = pkgs.mkShell {
|
devShells.${system}.default = pkgs.mkShell {
|
||||||
sopsPGPKeyDirs = ["./keys/hosts/" "./keys/users/"];
|
sopsPGPKeyDirs = ["./keys/hosts/" "./keys/users/"];
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
|
@ -103,25 +129,7 @@
|
||||||
sops-pkgs.sops-init-gpg-key
|
sops-pkgs.sops-init-gpg-key
|
||||||
];
|
];
|
||||||
|
|
||||||
shellHook = let
|
shellHook = ''
|
||||||
inherit (pkgs.lib.attrsets) mapAttrsToList;
|
|
||||||
inherit (pkgs.lib.strings) concatStringsSep;
|
|
||||||
ports = {
|
|
||||||
"2222" = "2222";
|
|
||||||
"3080" = "80";
|
|
||||||
"3443" = "443";
|
|
||||||
"2221" = "2221";
|
|
||||||
"21025" = "21025"; # Starbound
|
|
||||||
};
|
|
||||||
QEMU_NET_OPTS =
|
|
||||||
concatStringsSep ","
|
|
||||||
(mapAttrsToList
|
|
||||||
(host: vm: "hostfwd=::${host}-:${vm}")
|
|
||||||
ports);
|
|
||||||
in ''
|
|
||||||
export QEMU_OPTS="-m 3941 -smp 2 -curses"
|
|
||||||
export QEMU_NET_OPTS="${QEMU_NET_OPTS}"
|
|
||||||
|
|
||||||
# Work around sudo requiring a full terminal when deploying to
|
# Work around sudo requiring a full terminal when deploying to
|
||||||
# a remote host
|
# a remote host
|
||||||
export NIX_SSHOPTS="-t"
|
export NIX_SSHOPTS="-t"
|
||||||
|
|
Loading…
Reference in a new issue