clan-munix/templates/musictest/flake.nix
Jörg Thalheim ced0559be8 nixos: add munix.defaultCommand option and system.build.munix
Add a NixOS option to configure the default command for the VM and
provide a system.build.munix output that wraps munix with the correct
toplevel and default command. This reduces boilerplate in downstream
flakes since they no longer need to manually wrap munix.

The template now uses these new features, significantly simplifying
the apps definition.
2025-12-15 16:24:56 +01:00

77 lines
2.3 KiB
Nix

{
nixConfig = {
extra-substituters = [ "https://cache.clan.lol" ];
extra-trusted-public-keys = [
"cache.clan.lol-1:3KztgSAB5R1M+Dz7vzkBGzXdodizbgLXGXKXlcQLA28="
];
};
inputs = {
munix.url = "git+https://git.clan.lol/clan/munix?shallow=1&ref=main";
nixpkgs.follows = "munix/nixpkgs";
};
outputs =
{
self,
nixpkgs,
munix,
...
}:
{
nixosModules.musictest =
{ pkgs, ... }:
{
system.stateVersion = "26.05";
virtualisation.munix.defaultCommand = "euphonica";
programs.dconf.enable = true;
fonts.packages = with pkgs; [ adwaita-fonts ];
environment.systemPackages = with pkgs; [ euphonica ];
# Local background service as a demo that doesn't require network creds :)
services.mpd = {
enable = true;
startWhenNeeded = true;
musicDirectory = "/etc/demo-music";
user = "appvm";
group = "appvm";
extraConfig = ''
audio_output {
type "pipewire"
name "Pipewire Output"
}
'';
};
environment.etc."demo-music/0101GhostsI.ogg".source = pkgs.fetchurl {
# just a CC-BY-SA licensed example
url = "https://archive.org/download/NineInchNailsGhostsI-Iv24bit48khz/0101GhostsI.ogg";
sha256 = "0iijm1c191aqkxybl4a4gvlpnf72hk4896lwvp0xixkhds88qzxi";
};
};
nixosConfigurations.musictest-aarch64 = nixpkgs.lib.nixosSystem {
system = "aarch64-linux";
modules = [
munix.nixosModules.default
self.nixosModules.musictest
];
};
nixosConfigurations.musictest-x86_64 = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
munix.nixosModules.default
self.nixosModules.musictest
];
};
apps.aarch64-linux.default = {
type = "app";
program = "${self.nixosConfigurations.musictest-aarch64.config.system.build.munix}/bin/munix";
};
apps.x86_64-linux.default = {
type = "app";
program = "${self.nixosConfigurations.musictest-x86_64.config.system.build.munix}/bin/munix";
};
};
}