switch modules/outputs names

This commit is contained in:
do butterflies cry? 2026-03-17 22:45:46 +10:00
parent e7fdbf416c
commit 482cbf67cd
Signed by: cry
GPG key ID: F68745A836CA0412
16 changed files with 147 additions and 147 deletions

View file

@ -1,26 +1,10 @@
{ {
lib, config,
snow, _snowFlake,
... ...
}: let }: {
inherit outputs.checks =
(lib) _snowFlake.inputs.deploy-rs.lib
mkOption |> builtins.mapAttrs (system: deployLib:
types deployLib.deployChecks config.outputs.deploy);
; }
inherit
(snow.lib)
mkPerSystemFlakeOutput
;
in
mkPerSystemFlakeOutput {
name = "checks";
option = mkOption {
type = types.lazyAttrsOf types.package;
default = {};
description = ''
Derivations to be built by [`nix flake check`](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake-check.html).
'';
};
file = ./checks.nix;
}

View file

@ -1,15 +1,7 @@
{...}: { {...}: {
imports = [ imports = [
./outputs.nix
./apps.nix
./checks.nix ./checks.nix
./devShells.nix ./deploy.nix
./formatter.nix
./legacyPackages.nix
./nixosConfigurations.nix ./nixosConfigurations.nix
./nixosModules.nix
./overlays.nix
./packages.nix
]; ];
} }

View file

@ -1,35 +1,84 @@
{lib, ...}: let {
_snowFlake,
snow,
config,
systems,
root,
...
}: let
inherit inherit
(lib) (builtins)
mkOption all
types attrNames
literalExpression warn
;
inherit
(config)
nodes
; ;
in { in {
options = { outputs.nixosConfigurations = let
outputs.nixosConfigurations = mkOption { groups = snow.lib.parseGroupDecls root config.nodes.groups;
type = types.lazyAttrsOf types.raw; in
default = {}; snow.lib.mapNodes nodes (
description = '' {
Instantiated NixOS configurations. Used by `nixos-rebuild`. base,
lib,
name,
node,
...
}: let
nodeGroups =
(node.groups groups)
|> snow.lib.resolveGroupsInheritance
|> snow.lib.groupModules;
`nixosConfigurations` is for specific machines. If you want to expose homeManager =
reusable configurations, add them to [`nixosModules`](#opt-flake.nixosModules) if node.homeManager != null
in the form of modules (no `lib.nixosSystem`), so that you can reference then node.homeManager
them in this or another flake's `nixosConfigurations`. else if nodes.homeManager != null
''; then nodes.homeManager
example = literalExpression '' else
{ warn ''
my-machine = inputs.nixpkgs.lib.nixosSystem { [snowflake] Neither `nodes.homeManager` nor `nodes.nodes.${name}.homeManager` were specified!
# system is not needed with freshly generated hardware-configuration.nix [snowflake] home-manager will NOT be used! User configuration will be ignored!
# system = "x86_64-linux"; # or set nixpkgs.hostPlatform in a module. ''
modules = [ null;
./my-machine/nixos-configuration.nix
config.nixosModules.my-module userArgs = nodes.args // node.args;
]; snowArgs = {
inherit systems snow root base nodes node;
inherit (node) system;
hostname = name;
_snow = {
inherit (_snowFlake) inputs;
inherit userArgs snowArgs homeManager;
specialArgs = userArgs // snowArgs;
}; };
};
specialArgs = assert (userArgs
|> attrNames
|> all (argName:
! snowArgs ? argName
|| abort ''
`specialArgs` are like super important to Snow my love... </3
But `args.${argName}` is a reserved argument name :(
''));
snowArgs._snow.specialArgs;
in
lib.nixosSystem {
inherit (node) system;
inherit specialArgs;
modules =
[
_snowFlake.self.nixosModules.default
(snow.lib.findImport /${root}/hosts/${name})
]
++ nodeGroups
++ node.modules
++ nodes.modules;
} }
''; );
};
};
} }

View file

@ -1,10 +1,26 @@
{ {
config, lib,
_snowFlake, snow,
... ...
}: { }: let
outputs.checks = inherit
_snowFlake.inputs.deploy-rs.lib (lib)
|> builtins.mapAttrs (system: deployLib: mkOption
deployLib.deployChecks config.outputs.deploy); types
} ;
inherit
(snow.lib)
mkPerSystemFlakeOutput
;
in
mkPerSystemFlakeOutput {
name = "checks";
option = mkOption {
type = types.lazyAttrsOf types.package;
default = {};
description = ''
Derivations to be built by [`nix flake check`](https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake-check.html).
'';
};
file = ./checks.nix;
}

View file

@ -1,7 +1,15 @@
{...}: { {...}: {
imports = [ imports = [
./outputs.nix
./apps.nix
./checks.nix ./checks.nix
./deploy.nix ./devShells.nix
./formatter.nix
./legacyPackages.nix
./nixosConfigurations.nix ./nixosConfigurations.nix
./nixosModules.nix
./overlays.nix
./packages.nix
]; ];
} }

View file

@ -1,84 +1,35 @@
{ {lib, ...}: let
_snowFlake,
snow,
config,
systems,
root,
...
}: let
inherit inherit
(builtins) (lib)
all mkOption
attrNames types
warn literalExpression
;
inherit
(config)
nodes
; ;
in { in {
outputs.nixosConfigurations = let options = {
groups = snow.lib.parseGroupDecls root config.nodes.groups; outputs.nixosConfigurations = mkOption {
in type = types.lazyAttrsOf types.raw;
snow.lib.mapNodes nodes ( default = {};
{ description = ''
base, Instantiated NixOS configurations. Used by `nixos-rebuild`.
lib,
name,
node,
...
}: let
nodeGroups =
(node.groups groups)
|> snow.lib.resolveGroupsInheritance
|> snow.lib.groupModules;
homeManager = `nixosConfigurations` is for specific machines. If you want to expose
if node.homeManager != null reusable configurations, add them to [`nixosModules`](#opt-flake.nixosModules)
then node.homeManager in the form of modules (no `lib.nixosSystem`), so that you can reference
else if nodes.homeManager != null them in this or another flake's `nixosConfigurations`.
then nodes.homeManager '';
else example = literalExpression ''
warn '' {
[snowflake] Neither `nodes.homeManager` nor `nodes.nodes.${name}.homeManager` were specified! my-machine = inputs.nixpkgs.lib.nixosSystem {
[snowflake] home-manager will NOT be used! User configuration will be ignored! # system is not needed with freshly generated hardware-configuration.nix
'' # system = "x86_64-linux"; # or set nixpkgs.hostPlatform in a module.
null; modules = [
./my-machine/nixos-configuration.nix
userArgs = nodes.args // node.args; config.nixosModules.my-module
snowArgs = { ];
inherit systems snow root base nodes node;
inherit (node) system;
hostname = name;
_snow = {
inherit (_snowFlake) inputs;
inherit userArgs snowArgs homeManager;
specialArgs = userArgs // snowArgs;
}; };
};
specialArgs = assert (userArgs
|> attrNames
|> all (argName:
! snowArgs ? argName
|| abort ''
`specialArgs` are like super important to Snow my love... </3
But `args.${argName}` is a reserved argument name :(
''));
snowArgs._snow.specialArgs;
in
lib.nixosSystem {
inherit (node) system;
inherit specialArgs;
modules =
[
_snowFlake.self.nixosModules.default
(snow.lib.findImport /${root}/hosts/${name})
]
++ nodeGroups
++ node.modules
++ nodes.modules;
} }
); '';
};
};
} }