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`.
`nixosConfigurations` is for specific machines. If you want to expose
reusable configurations, add them to [`nixosModules`](#opt-flake.nixosModules)
in the form of modules (no `lib.nixosSystem`), so that you can reference
them in this or another flake's `nixosConfigurations`.
'';
example = literalExpression ''
{ {
my-machine = inputs.nixpkgs.lib.nixosSystem { base,
# system is not needed with freshly generated hardware-configuration.nix lib,
# system = "x86_64-linux"; # or set nixpkgs.hostPlatform in a module. name,
modules = [ node,
./my-machine/nixos-configuration.nix ...
config.nixosModules.my-module }: let
]; nodeGroups =
(node.groups groups)
|> snow.lib.resolveGroupsInheritance
|> snow.lib.groupModules;
homeManager =
if node.homeManager != null
then node.homeManager
else if nodes.homeManager != null
then nodes.homeManager
else
warn ''
[snowflake] Neither `nodes.homeManager` nor `nodes.nodes.${name}.homeManager` were specified!
[snowflake] home-manager will NOT be used! User configuration will be ignored!
''
null;
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 = ''
Instantiated NixOS configurations. Used by `nixos-rebuild`.
`nixosConfigurations` is for specific machines. If you want to expose
reusable configurations, add them to [`nixosModules`](#opt-flake.nixosModules)
in the form of modules (no `lib.nixosSystem`), so that you can reference
them in this or another flake's `nixosConfigurations`.
'';
example = literalExpression ''
{ {
base, my-machine = inputs.nixpkgs.lib.nixosSystem {
lib, # system is not needed with freshly generated hardware-configuration.nix
name, # system = "x86_64-linux"; # or set nixpkgs.hostPlatform in a module.
node, modules = [
... ./my-machine/nixos-configuration.nix
}: let config.nixosModules.my-module
nodeGroups = ];
(node.groups groups) };
|> snow.lib.resolveGroupsInheritance }
|> snow.lib.groupModules; '';
homeManager =
if node.homeManager != null
then node.homeManager
else if nodes.homeManager != null
then nodes.homeManager
else
warn ''
[snowflake] Neither `nodes.homeManager` nor `nodes.nodes.${name}.homeManager` were specified!
[snowflake] home-manager will NOT be used! User configuration will be ignored!
''
null;
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;
}
);
} }