From 482cbf67cd7c85555aef84eda576dc472e8c2c4e Mon Sep 17 00:00:00 2001 From: _cry64 Date: Tue, 17 Mar 2026 22:45:46 +1000 Subject: [PATCH] switch modules/outputs names --- nix/snow/flake/modules/checks.nix | 32 ++---- nix/snow/flake/modules/default.nix | 10 +- .../flake/{outputs => modules}/deploy.nix | 0 .../flake/modules/nixosConfigurations.nix | 105 +++++++++++++----- nix/snow/flake/{modules => outputs}/README.md | 0 nix/snow/flake/{modules => outputs}/apps.nix | 0 nix/snow/flake/outputs/checks.nix | 32 ++++-- nix/snow/flake/outputs/default.nix | 10 +- .../flake/{modules => outputs}/devShells.nix | 0 .../flake/{modules => outputs}/formatter.nix | 0 .../{modules => outputs}/legacyPackages.nix | 0 .../flake/outputs/nixosConfigurations.nix | 105 +++++------------- .../{modules => outputs}/nixosModules.nix | 0 .../flake/{modules => outputs}/outputs.nix | 0 .../flake/{modules => outputs}/overlays.nix | 0 .../flake/{modules => outputs}/packages.nix | 0 16 files changed, 147 insertions(+), 147 deletions(-) rename nix/snow/flake/{outputs => modules}/deploy.nix (100%) rename nix/snow/flake/{modules => outputs}/README.md (100%) rename nix/snow/flake/{modules => outputs}/apps.nix (100%) rename nix/snow/flake/{modules => outputs}/devShells.nix (100%) rename nix/snow/flake/{modules => outputs}/formatter.nix (100%) rename nix/snow/flake/{modules => outputs}/legacyPackages.nix (100%) rename nix/snow/flake/{modules => outputs}/nixosModules.nix (100%) rename nix/snow/flake/{modules => outputs}/outputs.nix (100%) rename nix/snow/flake/{modules => outputs}/overlays.nix (100%) rename nix/snow/flake/{modules => outputs}/packages.nix (100%) diff --git a/nix/snow/flake/modules/checks.nix b/nix/snow/flake/modules/checks.nix index d10d6d5..de6a9c0 100644 --- a/nix/snow/flake/modules/checks.nix +++ b/nix/snow/flake/modules/checks.nix @@ -1,26 +1,10 @@ { - lib, - snow, + config, + _snowFlake, ... -}: let - inherit - (lib) - mkOption - 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; - } +}: { + outputs.checks = + _snowFlake.inputs.deploy-rs.lib + |> builtins.mapAttrs (system: deployLib: + deployLib.deployChecks config.outputs.deploy); +} diff --git a/nix/snow/flake/modules/default.nix b/nix/snow/flake/modules/default.nix index e6914a0..2c0a9ca 100644 --- a/nix/snow/flake/modules/default.nix +++ b/nix/snow/flake/modules/default.nix @@ -1,15 +1,7 @@ {...}: { imports = [ - ./outputs.nix - - ./apps.nix ./checks.nix - ./devShells.nix - ./formatter.nix - ./legacyPackages.nix + ./deploy.nix ./nixosConfigurations.nix - ./nixosModules.nix - ./overlays.nix - ./packages.nix ]; } diff --git a/nix/snow/flake/outputs/deploy.nix b/nix/snow/flake/modules/deploy.nix similarity index 100% rename from nix/snow/flake/outputs/deploy.nix rename to nix/snow/flake/modules/deploy.nix diff --git a/nix/snow/flake/modules/nixosConfigurations.nix b/nix/snow/flake/modules/nixosConfigurations.nix index 7db8077..977fa22 100644 --- a/nix/snow/flake/modules/nixosConfigurations.nix +++ b/nix/snow/flake/modules/nixosConfigurations.nix @@ -1,35 +1,84 @@ -{lib, ...}: let +{ + _snowFlake, + snow, + config, + systems, + root, + ... +}: let inherit - (lib) - mkOption - types - literalExpression + (builtins) + all + attrNames + warn + ; + + inherit + (config) + nodes ; in { - options = { - outputs.nixosConfigurations = mkOption { - type = types.lazyAttrsOf types.raw; - default = {}; - description = '' - Instantiated NixOS configurations. Used by `nixos-rebuild`. + outputs.nixosConfigurations = let + groups = snow.lib.parseGroupDecls root config.nodes.groups; + in + snow.lib.mapNodes nodes ( + { + 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 - 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 { - # system is not needed with freshly generated hardware-configuration.nix - # system = "x86_64-linux"; # or set nixpkgs.hostPlatform in a module. - modules = [ - ./my-machine/nixos-configuration.nix - config.nixosModules.my-module - ]; + 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... builtins.mapAttrs (system: deployLib: - deployLib.deployChecks config.outputs.deploy); -} +}: let + inherit + (lib) + mkOption + 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; + } diff --git a/nix/snow/flake/outputs/default.nix b/nix/snow/flake/outputs/default.nix index 2c0a9ca..e6914a0 100644 --- a/nix/snow/flake/outputs/default.nix +++ b/nix/snow/flake/outputs/default.nix @@ -1,7 +1,15 @@ {...}: { imports = [ + ./outputs.nix + + ./apps.nix ./checks.nix - ./deploy.nix + ./devShells.nix + ./formatter.nix + ./legacyPackages.nix ./nixosConfigurations.nix + ./nixosModules.nix + ./overlays.nix + ./packages.nix ]; } diff --git a/nix/snow/flake/modules/devShells.nix b/nix/snow/flake/outputs/devShells.nix similarity index 100% rename from nix/snow/flake/modules/devShells.nix rename to nix/snow/flake/outputs/devShells.nix diff --git a/nix/snow/flake/modules/formatter.nix b/nix/snow/flake/outputs/formatter.nix similarity index 100% rename from nix/snow/flake/modules/formatter.nix rename to nix/snow/flake/outputs/formatter.nix diff --git a/nix/snow/flake/modules/legacyPackages.nix b/nix/snow/flake/outputs/legacyPackages.nix similarity index 100% rename from nix/snow/flake/modules/legacyPackages.nix rename to nix/snow/flake/outputs/legacyPackages.nix diff --git a/nix/snow/flake/outputs/nixosConfigurations.nix b/nix/snow/flake/outputs/nixosConfigurations.nix index 977fa22..7db8077 100644 --- a/nix/snow/flake/outputs/nixosConfigurations.nix +++ b/nix/snow/flake/outputs/nixosConfigurations.nix @@ -1,84 +1,35 @@ -{ - _snowFlake, - snow, - config, - systems, - root, - ... -}: let +{lib, ...}: let inherit - (builtins) - all - attrNames - warn - ; - - inherit - (config) - nodes + (lib) + mkOption + types + literalExpression ; in { - outputs.nixosConfigurations = let - groups = snow.lib.parseGroupDecls root config.nodes.groups; - in - snow.lib.mapNodes nodes ( - { - base, - lib, - name, - node, - ... - }: let - nodeGroups = - (node.groups groups) - |> snow.lib.resolveGroupsInheritance - |> snow.lib.groupModules; + options = { + outputs.nixosConfigurations = mkOption { + type = types.lazyAttrsOf types.raw; + default = {}; + description = '' + Instantiated NixOS configurations. Used by `nixos-rebuild`. - 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; + `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 { + # system is not needed with freshly generated hardware-configuration.nix + # system = "x86_64-linux"; # or set nixpkgs.hostPlatform in a module. + modules = [ + ./my-machine/nixos-configuration.nix + config.nixosModules.my-module + ]; }; - }; - specialArgs = assert (userArgs - |> attrNames - |> all (argName: - ! snowArgs ? argName - || abort '' - `specialArgs` are like super important to Snow my love...