summaryrefslogtreecommitdiff
path: root/modules/flake
diff options
context:
space:
mode:
authorseth <[email protected]>2024-10-18 03:10:35 -0400
committerGitHub <[email protected]>2024-10-18 07:10:35 +0000
commite6f79b30e620cf7bd5b06e2579e979ff090e925a (patch)
tree1dd2b20126602ef448f77fbb9cdd44ba7f02a58c /modules/flake
parentfdaf8680ef5bbcadb7cece43911beff18f90cdb2 (diff)
more refactors & outsource some things (#477)
* tree-wide: drop flake-parts * drop nixinate * justfile: cleanup * drop treefmt-nix * doc: update READMEs * flake: cleanup * seth: don't use `./.` * modules/nixos,darwin: bundle all modules They all depend on each other anyways so * systems: manually import internal modules * seth: use riff module from nix-exprs * flake: back to flake-parts * Revert "flake: back to flake-parts" This reverts commit 35334882f7c0c23991a4efd65ea08b216006b2b0. Saving the last commit so I can go back if I want * flake: use lib.const this looks better...right? * flake: declare systems like a normal person
Diffstat (limited to 'modules/flake')
-rw-r--r--modules/flake/default.nix12
-rw-r--r--modules/flake/map-configs.nix191
2 files changed, 0 insertions, 203 deletions
diff --git a/modules/flake/default.nix b/modules/flake/default.nix
deleted file mode 100644
index d06026d..0000000
--- a/modules/flake/default.nix
+++ /dev/null
@@ -1,12 +0,0 @@
-let
- flakeModules = {
- map-configs = ./map-configs.nix;
- };
-in
-{
- imports = [ flakeModules.map-configs ];
-
- flake = {
- inherit flakeModules;
- };
-}
diff --git a/modules/flake/map-configs.nix b/modules/flake/map-configs.nix
deleted file mode 100644
index e7733f3..0000000
--- a/modules/flake/map-configs.nix
+++ /dev/null
@@ -1,191 +0,0 @@
-{
- config,
- lib,
- withSystem,
- inputs,
- self,
- ...
-}:
-let
- nixosSystem =
- {
- nixpkgs,
- modules,
- specialArgs,
- ...
- }@args:
- nixpkgs.lib.nixosSystem (
- lib.removeAttrs args [ "nixpkgs" ]
- // {
- modules = modules ++ builtins.attrValues (self.nixosModules or [ ]);
- specialArgs = specialArgs // {
- inherit inputs;
- };
- }
- );
-
- darwinSystem =
- {
- nix-darwin,
- modules,
- specialArgs,
- ...
- }@args:
- nix-darwin.lib.darwinSystem (
- lib.removeAttrs args [ "nix-darwin" ]
- // {
- modules = modules ++ builtins.attrValues (self.darwinModules or { });
- specialArgs = specialArgs // {
- inherit inputs;
- };
- }
- );
-
- homeManagerConfiguration =
- {
- modules,
- extraSpecialArgs,
- ...
- }@args:
- inputs.home-manager.lib.homeManagerConfiguration (
- args
- // {
- modules = modules ++ builtins.attrValues (self.homeModules or self.homeManagerModules or { });
- extraSpecialArgs = extraSpecialArgs // {
- inherit inputs;
- };
- }
- );
-
- modulesOption = lib.mkOption {
- type = lib.types.listOf lib.types.unspecified;
- default = [ ];
- description = ''
- List of modules to use in the configuration
- '';
- };
-
- specialArgsOption = lib.mkOption {
- type = lib.types.lazyAttrsOf lib.types.raw;
- default = { };
- description = ''
- Extra arguments to pass to the configuration
- '';
- };
-
- freeformType = lib.types.attrsOf lib.types.raw;
-
- nixosConfigurationSubmodule = {
- inherit freeformType;
-
- options = {
- nixpkgs = lib.mkOption {
- type = lib.types.lazyAttrsOf lib.types.raw;
- default = inputs.nixpkgs or (throw "Could not find flake input `nixpkgs`");
- description = ''
- Instance of nixpkgs to use `lib.nixosSystem` from
- '';
- example = lib.literalExpression ''
- inputs.nixpkgs-stable
- '';
- };
-
- modules = modulesOption;
- specialArgs = specialArgsOption;
- };
- };
-
- homeConfigurationSubmodule = {
- inherit freeformType;
-
- options = {
- pkgs = lib.mkOption {
- type = lib.types.lazyAttrsOf lib.types.raw;
- default = withSystem "x86_64-linux" ({ pkgs, ... }: pkgs);
- description = ''
- Instance of nixpkgs to use with the configuration
- '';
- example = lib.literalExpression ''
- inputs.nixpkgs.legacyPackages.aarch64-darwin
- '';
- };
-
- modules = modulesOption;
- extraSpecialArgs = specialArgsOption;
- };
- };
-
- darwinConfigurationSubmodule = {
- inherit freeformType;
-
- options = {
- nix-darwin = lib.mkOption {
- type = lib.types.lazyAttrsOf lib.types.raw;
- default =
- inputs.nix-darwin or inputs.darwin
- or (throw "Could not find flake input `nixpkgs` or `nix-darwin`");
- description = ''
- Instance of nix-darwin to use `lib.nix-darwin` from
- '';
- };
-
- modules = modulesOption;
- specialArgs = specialArgsOption;
- };
- };
-in
-
-{
- options = {
- nixosConfigurations = lib.mkOption {
- type = lib.types.lazyAttrsOf (lib.types.submodule nixosConfigurationSubmodule);
- default = { };
- apply = lib.mapAttrs (lib.const nixosSystem);
- description = ''
- Map of configuration names and arguments to `nixosSystem`
- '';
- example = lib.literalExpression ''
- {
- my-machine = { modules = [ ./configuration.nix ]; };
- }
- '';
- };
-
- homeConfigurations = lib.mkOption {
- type = lib.types.lazyAttrsOf (lib.types.submodule homeConfigurationSubmodule);
- default = { };
- apply = lib.mapAttrs (lib.const homeManagerConfiguration);
- description = ''
- Map of configuration names and arguments to `homeManagerConfiguration`
- '';
- example = lib.literalExpression ''
- {
- me = { pkgs = nixpkgs.legacyPackages.x86_64-linux; };
- }
- '';
- };
-
- darwinConfigurations = lib.mkOption {
- type = lib.types.lazyAttrsOf (lib.types.submodule darwinConfigurationSubmodule);
- default = { };
- apply = lib.mapAttrs (lib.const darwinSystem);
- description = ''
- Map of configuration names and arguments to `darwinSystem`
- '';
- example = lib.literalExpression ''
- {
- my-mac = { modules = [ ./darwin-configuration.nix ]; };
- }
- '';
- };
- };
-
- config.flake = {
- inherit (config) nixosConfigurations homeConfigurations darwinConfigurations;
- /*
- nixosConfigurations = lib.mapAttrs (lib.const nixosSystem) config.nixosConfigurations;
- homeConfigurations = lib.mapAttrs (lib.const homeManagerConfiguration) config.homeConfigurations;
- darwinConfigurations = lib.mapAttrs (lib.const darwinSystem) config.darwinConfigurations;
- */
- };
-}