The goal is to have a flake with a nixosModule output, that enables a different nixosModule (from the flake’s inputs) and install some packages, when enabled.
I can’t figure out how to import the musnix flake/nixosmodule, or reference it, or whatever I should do.
When I import the flake’s default nixosModule into my nixos configurtation flake and enables it from my configuration, I get this error:
error: The option `musnix' does not exist.
When I import the musnix nixosModule in my nixos configurtation flake, it works.
But the point was to only need to import a single module (or use a single flake as input), which then would import/consume all the other flakes.
I’ve searched for days and read a lot of examples. But none exactly as what I’m trying. Which makes me suspect it’s not possible.
But surely there is a way, to import and enable one nixosModule, from within another, right?
I’ve read a lot of documentation. But I think it’s confused me more than helped me… by now.
I would appreciate any help. An example, link to an article that should explain it. Told that it’s simply not possible. Anything
The flake I’m trying to get to work:
{
description = "A flake for a music productions setup";
inputs = {
# General nixos inputs:
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
# This input should be imported into and/or enabled in the output nixosModule "musing"
musnix = {
url = "github:musnix/musnix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
# Don't know if these output are necessary
outputs = {
self,
nixpkgs,
musnix
}:
{
nixosModules = {
# Default module, should enable the musnix module when itself is enabled
default =
{
config,
lib,
nixpkgs,
musnix,
...
}:
with lib;
let
cfg = config.musing;
system = "x86_64-linux";
pkgs = import nixpkgs { system = "${system}"; };
# I thought the "musnix" in the config segnemt below, would reference this
# But it doesn't seem to do that
inherit musnix;
in
{
options.musing = {
enable = mkEnableOption "custom music production config";
suite-size = mkOption {
type = types.str;
default = "light";
};
};
config = mkIf cfg.enable {
# Testing enabling a nixosModule from flake input
# It's this one I'm failing at..
musnix = {
enable = true;
};
# testing install of packages
environment.systemPackages = with pkgs; [
# test pkg from nixpkgs
cowsay
];
};
};
musing = self.nixosModules.default;
# If I import this nixosModule in my nixos configuration, it works.
# But I would prefer to make it a part of the "musing" nixosModule
musnix = musnix.nixosModules.musnix;
};
};
}
Hope it makes sense. English is not my first language, neither am Nix…