feat(nixos): pass inputs and hostName as specialArgs to nixosSystem

This commit is contained in:
Mohammad Rafiq 2025-07-06 04:55:10 +08:00
parent b43476ccee
commit e385783de2
No known key found for this signature in database
4 changed files with 32 additions and 6 deletions

View file

@ -1,4 +1,9 @@
{ config, lib, ... }:
{
config,
lib,
inputs,
...
}:
let
inherit (lib.trivial) pipe;
inherit (lib.attrsets) filterAttrs mapAttrs';
@ -13,10 +18,8 @@ let
{
name = hostName;
value = lib.nixosSystem {
modules = [
value
{ networking = { inherit hostName; }; }
];
specialArgs = { inherit inputs hostName; };
modules = [ value ];
};
};
in

View file

@ -0,0 +1,4 @@
{ inputs, ... }:
{
imports = [ inputs.flake-parts.flakeModules.modules ];
}

View file

@ -1,3 +1,15 @@
{ config, ... }:
{
flake.hostSpec.hosts = { };
flake.hostSpec.hosts = {
"nixos/test".imports = with config.flake.modules.nixos; [ networking ];
"nixos/test".config = {
boot.loader.systemd-boot.enable = true;
fileSystems."/" = {
device = "/dev/sda1";
fsType = "ext4";
};
nixpkgs.hostPlatform = "x86_64-linux";
system.stateVersion = "25.05";
};
};
}

View file

@ -0,0 +1,7 @@
{
flake.modules.nixos.networking =
{ hostName, ... }:
{
networking = { inherit hostName; };
};
}