template: simplify with forAllSystems and inline module

Use the forAllSystems pattern to reduce duplication and inline the
NixOS module directly in nixosSystem call. This eliminates the need for
separate nixosModules and nixosConfigurations outputs, making the
template more concise and easier to understand.

Also use virtualisation.munix namespace for the option.
This commit is contained in:
Jörg Thalheim 2025-12-15 16:48:58 +01:00
parent ced0559be8
commit 1d864e0ded

View file

@ -13,18 +13,28 @@
outputs = outputs =
{ {
self,
nixpkgs, nixpkgs,
munix, munix,
... ...
}: }:
{ let
nixosModules.musictest = forAllSystems = nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
];
musictest-vm =
system:
nixpkgs.lib.nixosSystem {
modules = [
munix.nixosModules.default
(
{ pkgs, ... }: { pkgs, ... }:
{ {
system.stateVersion = "26.05"; system.stateVersion = "26.05";
virtualisation.munix.defaultCommand = "euphonica"; virtualisation.munix.defaultCommand = "euphonica";
nixpkgs.hostPlatform = system;
programs.dconf.enable = true; programs.dconf.enable = true;
fonts.packages = with pkgs; [ adwaita-fonts ]; fonts.packages = with pkgs; [ adwaita-fonts ];
environment.systemPackages = with pkgs; [ euphonica ]; environment.systemPackages = with pkgs; [ euphonica ];
@ -48,30 +58,14 @@
url = "https://archive.org/download/NineInchNailsGhostsI-Iv24bit48khz/0101GhostsI.ogg"; url = "https://archive.org/download/NineInchNailsGhostsI-Iv24bit48khz/0101GhostsI.ogg";
sha256 = "0iijm1c191aqkxybl4a4gvlpnf72hk4896lwvp0xixkhds88qzxi"; 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 { in
system = "x86_64-linux"; {
modules = [ packages = forAllSystems (system: {
munix.nixosModules.default default = (musictest-vm system).config.system.build.munix;
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";
};
}; };
} }