flake.nix: Add app to start VM through nix run

This commit is contained in:
Tristan Daniël Maat 2022-10-12 13:11:11 +01:00
parent e512e73b5e
commit dea9032530
Signed by: tlater
GPG key ID: 49670FD774E43268

View file

@ -92,20 +92,11 @@
}; };
}; };
devShells.${system}.default = pkgs.mkShell { apps.${system}.default = let
sopsPGPKeyDirs = ["./keys/hosts/" "./keys/users/"]; inherit (self.nixosConfigurations.vm.config.system.build) vm;
nativeBuildInputs = [ inherit (nixpkgs.legacyPackages.${system}) writeShellScript;
sops-pkgs.sops-import-keys-hook inherit (nixpkgs.lib.attrsets) mapAttrsToList;
]; inherit (nixpkgs.lib.strings) concatStringsSep;
buildInputs = with pkgs; [
nixfmt
git-lfs
sops-pkgs.sops-init-gpg-key
];
shellHook = let
inherit (pkgs.lib.attrsets) mapAttrsToList;
inherit (pkgs.lib.strings) concatStringsSep;
ports = { ports = {
"2222" = "2222"; "2222" = "2222";
"3080" = "80"; "3080" = "80";
@ -118,10 +109,27 @@
(mapAttrsToList (mapAttrsToList
(host: vm: "hostfwd=::${host}-:${vm}") (host: vm: "hostfwd=::${host}-:${vm}")
ports); ports);
in '' in {
type = "app";
program = builtins.toString (writeShellScript "run-vm" ''
export QEMU_OPTS="-m 3941 -smp 2 -curses" export QEMU_OPTS="-m 3941 -smp 2 -curses"
export QEMU_NET_OPTS="${QEMU_NET_OPTS}" export QEMU_NET_OPTS="${QEMU_NET_OPTS}"
"${vm}/bin/run-tlaternet-vm"
'');
};
devShells.${system}.default = pkgs.mkShell {
sopsPGPKeyDirs = ["./keys/hosts/" "./keys/users/"];
nativeBuildInputs = [
sops-pkgs.sops-import-keys-hook
];
buildInputs = with pkgs; [
nixfmt
git-lfs
sops-pkgs.sops-init-gpg-key
];
shellHook = ''
# 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"