diff --git a/flake.nix b/flake.nix index ff9a365..0987782 100644 --- a/flake.nix +++ b/flake.nix @@ -150,17 +150,20 @@ ./modules/flake/agenix.nix ./modules/flake/deploy.nix ./modules/flake/topology + ./modules/flake/packages ]; - perSystem = { lib, pkgs, system, ... }: { - # Packages (`nix build`) - packages = import ./pkgs { inherit pkgs; }; + perSystem = { lib, pkgs, system, ... }: { # Apps (`nix run`) apps = import ./apps { inherit pkgs; }; # Dev Shells (`nix develop`) - devShells = import ./shells { inherit pkgs inputs; }; + devShells = import ./shells { + inherit inputs; + # NOTE: for `nixVersions.monitored` + pkgs = pkgs.extend inputs.self.overlays.modifications; + }; # Formatter (`nix fmt`) formatter = pkgs.nixpkgs-fmt; @@ -175,6 +178,9 @@ # Automatic configurations, see `./modules/flake/configurations.nix` autoConfigurations.enableAll = true; + # Automatic packages, see `./modules/flake/packages/default.nix` + autoPackages.enable = true; + # Templates templates = import ./templates { inherit inputs; diff --git a/hosts/home-manager/x86_64-linux/__template__/home.nix b/hosts/home-manager/x86_64-linux/__template__/home.nix index 686c2e5..97ba30c 100644 --- a/hosts/home-manager/x86_64-linux/__template__/home.nix +++ b/hosts/home-manager/x86_64-linux/__template__/home.nix @@ -1,11 +1,11 @@ # This is your home-manager configuration file # Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix) -{ inputs, outputs, lib, pkgs, config, ... }: { +{ inputs, lib, pkgs, config, ... }: { # You can import other home-manager modules here imports = [ # If you want to use modules your own flake exports (from modules/home-manager): - # outputs.homeManagerModules.example + # inputs.self.homeManagerModules.example # Or modules exported from other flakes (such as nix-colors): # inputs.nix-colors.homeManagerModules.default diff --git a/hosts/nix-darwin/aarch64-darwin/limonka/configuration.nix b/hosts/nix-darwin/aarch64-darwin/limonka/configuration.nix index 1be47af..e75912c 100644 --- a/hosts/nix-darwin/aarch64-darwin/limonka/configuration.nix +++ b/hosts/nix-darwin/aarch64-darwin/limonka/configuration.nix @@ -1,4 +1,4 @@ -{ inputs, outputs, lib, pkgs, config, ... }: +{ inputs, lib, pkgs, config, ... }: { environment.systemPackages = with pkgs; [ ]; diff --git a/hosts/nix-darwin/aarch64-darwin/limonka/home/pavelatanasov.nix b/hosts/nix-darwin/aarch64-darwin/limonka/home/pavelatanasov.nix index 681ff5f..d31ea1c 100644 --- a/hosts/nix-darwin/aarch64-darwin/limonka/home/pavelatanasov.nix +++ b/hosts/nix-darwin/aarch64-darwin/limonka/home/pavelatanasov.nix @@ -1,4 +1,4 @@ -{ inputs, outputs, lib, pkgs, config, ... }: +{ inputs, lib, pkgs, config, ... }: { home = { diff --git a/hosts/nix-darwin/x86_64-darwin/apavel-a01/configuration.nix b/hosts/nix-darwin/x86_64-darwin/apavel-a01/configuration.nix index d3ac5be..25638a2 100644 --- a/hosts/nix-darwin/x86_64-darwin/apavel-a01/configuration.nix +++ b/hosts/nix-darwin/x86_64-darwin/apavel-a01/configuration.nix @@ -1,4 +1,4 @@ -{ inputs, outputs, lib, pkgs, config, ... }: +{ inputs, lib, pkgs, config, ... }: { environment.systemPackages = with pkgs; [ ]; diff --git a/hosts/nix-darwin/x86_64-darwin/apavel-a01/home/apavel.nix b/hosts/nix-darwin/x86_64-darwin/apavel-a01/home/apavel.nix index 0045935..32d4ef9 100644 --- a/hosts/nix-darwin/x86_64-darwin/apavel-a01/home/apavel.nix +++ b/hosts/nix-darwin/x86_64-darwin/apavel-a01/home/apavel.nix @@ -1,4 +1,4 @@ -{ inputs, outputs, lib, pkgs, config, ... }: +{ inputs, lib, pkgs, config, ... }: { home = { diff --git a/hosts/nix-darwin/x86_64-darwin/limontozu/configuration.nix b/hosts/nix-darwin/x86_64-darwin/limontozu/configuration.nix index dca459a..dabfdfb 100644 --- a/hosts/nix-darwin/x86_64-darwin/limontozu/configuration.nix +++ b/hosts/nix-darwin/x86_64-darwin/limontozu/configuration.nix @@ -1,4 +1,4 @@ -{ inputs, outputs, lib, pkgs, config, ... }: +{ inputs, lib, pkgs, config, ... }: { environment.systemPackages = with pkgs; [ ]; diff --git a/hosts/nix-darwin/x86_64-darwin/limontozu/home/pavelatanasov.nix b/hosts/nix-darwin/x86_64-darwin/limontozu/home/pavelatanasov.nix index 3974b0e..d6a1804 100644 --- a/hosts/nix-darwin/x86_64-darwin/limontozu/home/pavelatanasov.nix +++ b/hosts/nix-darwin/x86_64-darwin/limontozu/home/pavelatanasov.nix @@ -1,4 +1,4 @@ -{ inputs, outputs, lib, pkgs, config, ... }: +{ inputs, lib, pkgs, config, ... }: { home = { diff --git a/hosts/nix-on-droid/aarch64-linux/cheetah/configuration.nix b/hosts/nix-on-droid/aarch64-linux/cheetah/configuration.nix index 51cf546..366b932 100644 --- a/hosts/nix-on-droid/aarch64-linux/cheetah/configuration.nix +++ b/hosts/nix-on-droid/aarch64-linux/cheetah/configuration.nix @@ -1,4 +1,4 @@ -{ inputs, outputs, lib, pkgs, config, ... }: +{ inputs, lib, pkgs, config, ... }: { environment.packages = with pkgs; [ ]; diff --git a/hosts/nix-on-droid/aarch64-linux/cheetah/home.nix b/hosts/nix-on-droid/aarch64-linux/cheetah/home.nix index 7b4135b..dc68e59 100644 --- a/hosts/nix-on-droid/aarch64-linux/cheetah/home.nix +++ b/hosts/nix-on-droid/aarch64-linux/cheetah/home.nix @@ -1,4 +1,4 @@ -{ inputs, outputs, lib, pkgs, config, ... }: +{ inputs, lib, pkgs, config, ... }: { # Home Manager needs a bit of information about you and the diff --git a/hosts/nixos/x86_64-linux/__template__/configuration.nix b/hosts/nixos/x86_64-linux/__template__/configuration.nix index 30d18c8..99a5318 100644 --- a/hosts/nixos/x86_64-linux/__template__/configuration.nix +++ b/hosts/nixos/x86_64-linux/__template__/configuration.nix @@ -1,11 +1,11 @@ # This is your system's configuration file. # Use this to configure your system environment (it replaces /etc/nixos/configuration.nix) -{ inputs, outputs, lib, pkgs, config, ... }: { +{ inputs, lib, pkgs, config, ... }: { # You can import other NixOS modules here imports = [ # If you want to use modules your own flake exports (from modules/nixos): - # outputs.nixosModules.example + # inputs.self.nixosModules.example # Or modules from other flakes (such as nixos-hardware): # inputs.hardware.nixosModules.common-cpu-amd @@ -22,8 +22,8 @@ # You can add overlays here overlays = [ # If you want to use overlays your own flake exports (from overlays dir): - # outputs.overlays.modifications - # outputs.overlays.additions + # inputs.self.overlays.modifications + # inputs.self.overlays.additions # Or overlays exported from other flakes: # neovim-nightly-overlay.overlays.default diff --git a/hosts/nixos/x86_64-linux/homix/configuration.nix b/hosts/nixos/x86_64-linux/homix/configuration.nix index 74ad26e..de358fa 100644 --- a/hosts/nixos/x86_64-linux/homix/configuration.nix +++ b/hosts/nixos/x86_64-linux/homix/configuration.nix @@ -2,7 +2,7 @@ # your system. Help is available in the configuration.nix(5) man page # and in the NixOS manual (accessible by running ‘nixos-help’). -{ inputs, outputs, lib, pkgs, config, ... }: +{ inputs, lib, pkgs, config, ... }: { imports = [ diff --git a/hosts/nixos/x86_64-linux/homix/home/reo101.nix b/hosts/nixos/x86_64-linux/homix/home/reo101.nix index 56dbecc..be61793 100644 --- a/hosts/nixos/x86_64-linux/homix/home/reo101.nix +++ b/hosts/nixos/x86_64-linux/homix/home/reo101.nix @@ -1,4 +1,4 @@ -{ inputs, outputs, lib, pkgs, config, ... }: +{ inputs, lib, pkgs, config, ... }: { imports = [ diff --git a/hosts/nixos/x86_64-linux/jeeves/configuration.nix b/hosts/nixos/x86_64-linux/jeeves/configuration.nix index efb0c46..d0fddff 100644 --- a/hosts/nixos/x86_64-linux/jeeves/configuration.nix +++ b/hosts/nixos/x86_64-linux/jeeves/configuration.nix @@ -1,4 +1,4 @@ -{ inputs, outputs, lib, pkgs, config, ... }: +{ inputs, lib, pkgs, config, ... }: { imports = [ inputs.hardware.nixosModules.common-cpu-amd diff --git a/hosts/nixos/x86_64-linux/jeeves/disko.nix b/hosts/nixos/x86_64-linux/jeeves/disko.nix index 61892d2..97b281f 100644 --- a/hosts/nixos/x86_64-linux/jeeves/disko.nix +++ b/hosts/nixos/x86_64-linux/jeeves/disko.nix @@ -1,4 +1,4 @@ -{ inputs, outputs, lib, pkgs, config, ... }: +{ inputs, lib, pkgs, config, ... }: { imports = [ inputs.disko.nixosModules.disko diff --git a/hosts/nixos/x86_64-linux/jeeves/home-assistant/default.nix b/hosts/nixos/x86_64-linux/jeeves/home-assistant/default.nix index 5e93ac4..94e732f 100644 --- a/hosts/nixos/x86_64-linux/jeeves/home-assistant/default.nix +++ b/hosts/nixos/x86_64-linux/jeeves/home-assistant/default.nix @@ -1,4 +1,4 @@ -{ inputs, outputs, lib, pkgs, config, ... }: +{ inputs, lib, pkgs, config, ... }: { environment.systemPackages = with pkgs; [ ]; diff --git a/hosts/nixos/x86_64-linux/jeeves/home/jeeves.nix b/hosts/nixos/x86_64-linux/jeeves/home/jeeves.nix index f3b71bd..5c852e9 100644 --- a/hosts/nixos/x86_64-linux/jeeves/home/jeeves.nix +++ b/hosts/nixos/x86_64-linux/jeeves/home/jeeves.nix @@ -1,4 +1,4 @@ -{ inputs, outputs, lib, pkgs, config, ... }: +{ inputs, lib, pkgs, config, ... }: { imports = [ diff --git a/hosts/nixos/x86_64-linux/jeeves/network.nix b/hosts/nixos/x86_64-linux/jeeves/network.nix index 35176d1..52b91fa 100644 --- a/hosts/nixos/x86_64-linux/jeeves/network.nix +++ b/hosts/nixos/x86_64-linux/jeeves/network.nix @@ -1,4 +1,4 @@ -{ inputs, outputs, lib, pkgs, config, ... }: +{ inputs, lib, pkgs, config, ... }: { environment.systemPackages = with pkgs; [ ]; diff --git a/hosts/nixos/x86_64-linux/jeeves/nginx.nix b/hosts/nixos/x86_64-linux/jeeves/nginx.nix index 6d85def..c08cf11 100644 --- a/hosts/nixos/x86_64-linux/jeeves/nginx.nix +++ b/hosts/nixos/x86_64-linux/jeeves/nginx.nix @@ -1,4 +1,4 @@ -{ inputs, outputs, lib, pkgs, config, ... }: +{ inputs, lib, pkgs, config, ... }: { # age.secrets."nextcloud.adminpass" = { diff --git a/hosts/nixos/x86_64-linux/jeeves/ollama.nix b/hosts/nixos/x86_64-linux/jeeves/ollama.nix index 2c4dff7..69c9a51 100644 --- a/hosts/nixos/x86_64-linux/jeeves/ollama.nix +++ b/hosts/nixos/x86_64-linux/jeeves/ollama.nix @@ -1,4 +1,4 @@ -{ inputs, outputs, lib, pkgs, config, ... }: +{ inputs, lib, pkgs, config, ... }: { networking.firewall.allowedTCPPorts = [11434]; diff --git a/hosts/nixos/x86_64-linux/jeeves/wireguard.nix b/hosts/nixos/x86_64-linux/jeeves/wireguard.nix index 178c619..a0c8b1e 100644 --- a/hosts/nixos/x86_64-linux/jeeves/wireguard.nix +++ b/hosts/nixos/x86_64-linux/jeeves/wireguard.nix @@ -1,4 +1,4 @@ -{ inputs, outputs, lib, pkgs, config, ... }: +{ inputs, lib, pkgs, config, ... }: { environment.systemPackages = with pkgs; [ wireguard-tools diff --git a/modules/flake/configurations.nix b/modules/flake/configurations.nix index 628b7d9..bec3eee 100644 --- a/modules/flake/configurations.nix +++ b/modules/flake/configurations.nix @@ -1,19 +1,23 @@ { lib, config, self, inputs, withSystem, ... }: let - outputs = self; - inherit (import ../../nix/utils.nix { inherit lib self; }) + inherit (import ../../nix/utils.nix { inherit lib config self; }) and hasFiles hasDirectories recurseDir - configuration-type-to-outputs-modules - configuration-type-to-outputs-hosts; + configuration-type-to-outputs-modules; in let # Configuration helpers configurationTypes = ["nixos" "nix-on-droid" "nix-darwin" "home-manager"]; + # `pkgs` with flake's overlays + # NOTE: done here to avoid infinite recursion + pkgs' = system: + (withSystem system ({ pkgs, ... }: pkgs)).extend + (final: prev: inputs.self.packages.${system}); + homeManagerModule = { root, system, hostname, users ? null }: { home-manager = { # Use same `pkgs` instance as system (i.e. carry over overlays) @@ -24,7 +28,7 @@ let sharedModules = builtins.attrValues config.flake.${configuration-type-to-outputs-modules "home-manager"}; # Pass in `inputs`, `outputs` and maybe `meta` extraSpecialArgs = { - inherit inputs outputs; + inherit inputs; # TODO: meta? inherit hostname; }; @@ -42,7 +46,7 @@ let mkNixosHost = args @ { root, system, hostname, users }: inputs.nixpkgs.lib.nixosSystem { inherit system; - pkgs = withSystem system ({ pkgs, ... }: pkgs); + pkgs = pkgs' system; modules = [ # Main configuration @@ -62,14 +66,14 @@ let ] ++ (builtins.attrValues config.flake.${configuration-type-to-outputs-modules "nixos"}); specialArgs = { - inherit inputs outputs; + inherit inputs; }; }; mkNixOnDroidHost = args @ { root, system, hostname }: inputs.nix-on-droid.lib.nixOnDroidConfiguration { # NOTE: inferred by `pkgs.system` # inherit system; - pkgs = withSystem system ({ pkgs, ... }: pkgs); + pkgs = pkgs' system; modules = [ # Main configuration @@ -79,7 +83,7 @@ let ] ++ (builtins.attrValues config.flake.${configuration-type-to-outputs-modules "nix-on-droid"}); extraSpecialArgs = { - inherit inputs outputs; + inherit inputs; }; home-manager-path = inputs.home-manager.outPath; @@ -87,7 +91,7 @@ let mkNixDarwinHost = args @ { root, system, hostname, users }: inputs.nix-darwin.lib.darwinSystem { inherit system; - pkgs = withSystem system ({ pkgs, ... }: pkgs); + pkgs = pkgs' system; modules = [ # Main configuration @@ -102,20 +106,20 @@ let ] ++ (builtins.attrValues config.flake.${configuration-type-to-outputs-modules "nix-darwin"}); specialArgs = { - inherit inputs outputs; + inherit inputs; }; }; mkHomeManagerHost = args @ { root, system, hostname }: inputs.home-manager.lib.homeManagerConfiguration { inherit system; - pkgs = withSystem system ({ pkgs, ... }: pkgs); + pkgs = pkgs' system; modules = [ "${root}/home.nix" ] ++ (builtins.attrValues config.flake.${configuration-type-to-outputs-modules "home-manager"}); extraSpecialArgs = { - inherit inputs outputs; + inherit inputs; inherit hostname; }; }; @@ -182,6 +186,20 @@ in type = types.path; default = "${submodule.config.baseDir}/${configurationType}"; }; + # TODO: split hosts and configurations? + resultHosts = lib.mkOption { + description = '' + The resulting automatic packages + ''; + # TODO: specify + type = types.unspecified; + readOnly = true; + internal = true; + default = + lib.optionalAttrs + config.flake.autoConfigurations.${configurationType}.enable + (recurseDir config.flake.autoConfigurations.${configurationType}.dir); + }; }; }; default = {}; @@ -194,21 +212,7 @@ in }; config = { - flake = let - autoHosts = - lib.pipe - configurationTypes - [ - (builtins.map - (configurationType: - lib.nameValuePair - "${configuration-type-to-outputs-hosts configurationType}" - (if config.flake.autoConfigurations.${configurationType}.enable - then recurseDir config.flake.autoConfigurations.${configurationType}.dir - else { }))) - builtins.listToAttrs - ]; - in autoHosts // { + flake = { # Configurations nixosConfigurations = createConfigurations @@ -231,7 +235,7 @@ in (lib.strings.removeSuffix ".nix") (builtins.attrNames (configurationFiles."home" or { }))); }) - self.${configuration-type-to-outputs-hosts "nixos"}; + config.flake.autoConfigurations.nixos.resultHosts; nixOnDroidConfigurations = createConfigurations @@ -248,7 +252,7 @@ in inherit system; hostname = host; }) - self.${configuration-type-to-outputs-hosts "nix-on-droid"}; + config.flake.autoConfigurations.nix-on-droid.resultHosts; darwinConfigurations = createConfigurations @@ -271,7 +275,7 @@ in (lib.strings.removeSuffix ".nix") (builtins.attrNames (configurationFiles."home" or { }))); }) - self.${configuration-type-to-outputs-hosts "nix-darwin"}; + config.flake.autoConfigurations.nix-darwin.resultHosts; homeConfigurations = createConfigurations @@ -288,7 +292,7 @@ in inherit system; hostname = host; }) - self.${configuration-type-to-outputs-hosts "home-manager"}; + config.flake.autoConfigurations.home-manager.resultHosts; }; }; } diff --git a/modules/flake/deploy.nix b/modules/flake/deploy.nix index 6d5a3c5..5a8fc0f 100644 --- a/modules/flake/deploy.nix +++ b/modules/flake/deploy.nix @@ -1,7 +1,7 @@ { lib, config, self, inputs, ... }: let - inherit (import ../../nix/utils.nix { inherit lib self; }) + inherit (import ../../nix/utils.nix { inherit lib config self; }) accumulateHosts configuration-type-to-deploy-type; in diff --git a/modules/flake/modules.nix b/modules/flake/modules.nix index 7479c3c..04997a6 100644 --- a/modules/flake/modules.nix +++ b/modules/flake/modules.nix @@ -1,8 +1,7 @@ { lib, config, self, inputs, ... }: let - outputs = self; - inherit (import ../../nix/utils.nix { inherit lib self; }) + inherit (import ../../nix/utils.nix { inherit lib config self; }) eq and hasFiles @@ -12,7 +11,7 @@ let # Modules helpers moduleTypes = ["nixos" "nix-on-droid" "nix-darwin" "home-manager" "flake"]; - createModules = baseDir: { passthru ? { inherit inputs outputs; }, ... }: + createModules = baseDir: { passthru ? { inherit inputs; }, ... }: lib.pipe baseDir [ # Read given directory builtins.readDir @@ -55,6 +54,7 @@ let if and [ (builtins.isFunction module) + # FIXME: check for subset, not `eq` (eq (lib.pipe module [ builtins.functionArgs builtins.attrNames ]) (lib.pipe passthru [ builtins.attrNames ])) @@ -104,6 +104,19 @@ in type = types.path; default = "${submodule.config.baseDir}/${moduleType}"; }; + result = lib.mkOption { + description = '' + The resulting automatic packages + ''; + # TODO: specify + type = types.unspecified; + readOnly = true; + internal = true; + default = + lib.optionalAttrs + config.flake.autoModules.${moduleType}.enable + (createModules config.flake.autoModules.${moduleType}.dir { }); + }; }; }; default = {}; @@ -123,22 +136,13 @@ in [ (builtins.map (moduleType: - lib.nameValuePair - "${configuration-type-to-outputs-modules moduleType}" - (if config.flake.autoModules.${moduleType}.enable - then createModules config.flake.autoModules.${moduleType}.dir { } - else { }))) + let + name = "${configuration-type-to-outputs-modules moduleType}"; + value = config.flake.autoModules.${moduleType}.result; + in + lib.nameValuePair name value)) builtins.listToAttrs ]; - in { - # NOTE: manually inheriting generated modules to avoid recursion - # (`autoModules` depends on `config.flake` itself) - inherit (autoModules) - nixosModules - nixOnDroidModules - darwinModules - homeManagerModules - flakeModules; - }; + in autoModules; }; } diff --git a/modules/flake/packages/default.nix b/modules/flake/packages/default.nix new file mode 100644 index 0000000..eafcee5 --- /dev/null +++ b/modules/flake/packages/default.nix @@ -0,0 +1,129 @@ +{ lib, config, self, inputs, ... }: + +let + inherit (import ../../../nix/utils.nix { inherit lib config self; }) + eq + and + hasFiles; +in +let + createPackages = baseDir: { passthru ? { inherit inputs; }, ... }: + lib.pipe baseDir [ + # Read given directory + builtins.readDir + # Map each entry to a package + (lib.mapAttrs' + (name: type: + let + packageDir = "${baseDir}/${name}"; + systems = let + systemsPath = "${baseDir}/${name}/systems.nix"; + in + # NOTE: If the package can restrict for which systems it wants to be built + if builtins.pathExists systemsPath + then import systemsPath + else lib.const true; + package = import packageDir; + result = { + inherit package systems; + }; + in + if and [ + (type == "directory") + (hasFiles [ "default.nix" ] (builtins.readDir packageDir)) + ] then + # NOTE: Classic package in a directory + lib.nameValuePair + name + result + else if and [ + (type == "regular") + (lib.hasSuffix ".nix" name) + ] then + # NOTE: Classic package in a file + lib.nameValuePair + (lib.removeSuffix ".nix" name) + result + else + # NOTE: Invalid package + lib.nameValuePair + name + null)) + # Filter invalid packages + (lib.filterAttrs + (packageName: package: + package != null)) + # Passthru if needed + (lib.mapAttrs + (packageName: package: + if and [ + (builtins.isFunction + package) + (eq + (lib.pipe package [ builtins.functionArgs builtins.attrNames ]) + (lib.pipe passthru [ builtins.attrNames ])) + ] + then package passthru + else package)) + ]; +in +{ + options = let + inherit (lib) types; + in { + flake.autoPackages = lib.mkOption { + description = '' + Automagically generate packages from walking directories with Nix files + ''; + type = types.submodule (submodule: { + options = { + enable = lib.mkEnableOption "Automatic packages extraction"; + dir = lib.mkOption { + description = '' + Base directory of the contained packages + ''; + type = types.path; + default = "${self}/pkgs"; + defaultText = ''''${self}/pkgs''; + }; + result = lib.mkOption { + description = '' + The resulting automatic packages + ''; + type = types.attrsOf (types.submodule { options = { + package = lib.mkOption { type = types.unspecified; }; + systems = lib.mkOption { type = types.functionTo types.bool; }; + };}); + readOnly = true; + internal = true; + default = + lib.optionalAttrs + config.flake.autoPackages.enable + (createPackages config.flake.autoPackages.dir { }); + }; + }; + }); + default = {}; + }; + }; + + config = { + perSystem = { lib, pkgs, system, ... }: let + packages = + lib.pipe + config.flake.autoPackages.result + [ + (lib.filterAttrs + (name: { package, systems }: + pkgs.callPackage systems { + inherit (pkgs) lib hostPlatform targetPlatform; + })) + (lib.mapAttrs + (name: { package, systems }: + pkgs.callPackage package { })) + ]; + in { + inherit packages; + }; + }; +} diff --git a/modules/flake/pkgs.nix b/modules/flake/pkgs.nix index e7b2e9c..9a0807b 100644 --- a/modules/flake/pkgs.nix +++ b/modules/flake/pkgs.nix @@ -4,6 +4,8 @@ perSystem = { system, ... }: { _module.args.pkgs = import inputs.nixpkgs { inherit system; + # WARN: not including `self.packages` overylay + # because it causes an infinite recursion overlays = lib.attrValues self.overlays ++ [ inputs.neovim-nightly-overlay.overlays.default inputs.zig-overlay.overlays.default diff --git a/modules/home-manager/darwin-trampolines/default.nix b/modules/home-manager/darwin-trampolines/default.nix index 8afbd36..e2ae55a 100644 --- a/modules/home-manager/darwin-trampolines/default.nix +++ b/modules/home-manager/darwin-trampolines/default.nix @@ -1,4 +1,4 @@ -{ inputs, outputs, ... }: +{ inputs, ... }: { lib, pkgs, config, ... }: { diff --git a/modules/home-manager/nix-general/default.nix b/modules/home-manager/nix-general/default.nix index 9829568..13a3c58 100644 --- a/modules/home-manager/nix-general/default.nix +++ b/modules/home-manager/nix-general/default.nix @@ -1,4 +1,4 @@ -{ inputs, outputs, ... }: +{ inputs, ... }: { lib, pkgs, config, ... }: { @@ -22,7 +22,7 @@ # # # Use flake overlays by default # nixpkgs = { - # overlays = lib.attrValues outputs.overlays; + # overlays = lib.attrValues inputs.self.overlays; # # config.allowUnfree = true; # }; diff --git a/modules/home-manager/reo101-spotify/default.nix b/modules/home-manager/reo101-spotify/default.nix index 3856381..22a6df8 100644 --- a/modules/home-manager/reo101-spotify/default.nix +++ b/modules/home-manager/reo101-spotify/default.nix @@ -1,4 +1,4 @@ -{ inputs, outputs, ... }: +{ inputs, ... }: { lib, pkgs, config, ... }: let diff --git a/modules/nix-darwin/system/default.nix b/modules/nix-darwin/system/default.nix index e75cd0c..f62b586 100644 --- a/modules/nix-darwin/system/default.nix +++ b/modules/nix-darwin/system/default.nix @@ -1,4 +1,4 @@ -{ inputs, outputs, ... }: +{ inputs, ... }: { lib, pkgs, config, ... }: with lib; diff --git a/modules/nixos/agenix-rekey-default/default.nix b/modules/nixos/agenix-rekey-default/default.nix index 251d8d6..bb546e0 100644 --- a/modules/nixos/agenix-rekey-default/default.nix +++ b/modules/nixos/agenix-rekey-default/default.nix @@ -1,4 +1,4 @@ -{ inputs, outputs, lib, pkgs, config, options, ... }: +{ inputs, lib, pkgs, config, options, ... }: { config = { # NOTE: `(r)agenix` and `agenix-rekey` modules are imported by `../../../modules/flake/configurations.nix` diff --git a/nix/utils.nix b/nix/utils.nix index ec81582..9cf5f85 100644 --- a/nix/utils.nix +++ b/nix/utils.nix @@ -1,4 +1,4 @@ -{ lib, self, ... }: +{ lib, config, self, ... }: rec { # Boolean helpers @@ -109,10 +109,7 @@ rec { (lib.genAttrs configuration-types (configuration-type: - let - hosts = configuration-type-to-outputs-hosts configuration-type; - in - self.${hosts})) + config.flake.autoConfigurations.${configuration-type}.resultHosts)) (configuration-type: hosts: lib.pipe hosts diff --git a/overlays/default.nix b/overlays/default.nix index 17f79d7..3d449b3 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,10 +1,9 @@ # This file defines overlays { inputs, ... }: { - # This one brings our custom packages from the 'pkgs' directory - additions = final: _prev: import ../pkgs { - pkgs = final; - }; + # This one brings our custom packages + # BUG: causes infinite recursion + # additions = final: prev: inputs.self.packages.${prev.system}; # This one contains whatever you want to overlay # You can change versions, add patches, set compilation flags, anything really. @@ -30,7 +29,7 @@ }; }; - nix-monitored = inputs.nix-monitored.packages.${final.system}.default.override { + nix-monitored = inputs.nix-monitored.packages.${prev.system}.default.override { nix = prev.nix; nix-output-monitor = prev.nix-output-monitor; }; diff --git a/pkgs/default.nix b/pkgs/default.nix deleted file mode 100644 index 8297c98..0000000 --- a/pkgs/default.nix +++ /dev/null @@ -1,23 +0,0 @@ -# Custom packages, that can be defined similarly to ones from nixpkgs -# You can build them using 'nix build .#example' or (legacy) 'nix-build -A example' - -{ pkgs ? (import ../nixpkgs.nix) { } -, ... -}: { - # example = pkgs.callPackage ./example { }; - advcpmv = pkgs.callPackage ./advcpmv { }; - circom = pkgs.callPackage ./circom { }; - circom-lsp = pkgs.callPackage ./circom-lsp { }; - envsub = pkgs.callPackage ./envsub { }; - fennel-language-server = pkgs.callPackage ./fennel-language-server { }; - flamelens = pkgs.callPackage ./flamelens { }; - parinfer-rust = pkgs.callPackage ./parinfer-rust { }; - pest-ide-tools = pkgs.callPackage ./pest-ide-tools { }; - # FIXME: only buildable on darwin - # pngpaste = pkgs.callPackage ./pngpaste { }; - srtool-cli = pkgs.callPackage ./srtool-cli { }; - # FIXME: does not build - # swww = pkgs.callPackage ./swww { }; - vim-fmi-cli = pkgs.callPackage ./vim-fmi-cli { }; - win2xcur = pkgs.callPackage ./win2xcur { }; -} diff --git a/pkgs/pngpaste/systems.nix b/pkgs/pngpaste/systems.nix new file mode 100644 index 0000000..3ae6942 --- /dev/null +++ b/pkgs/pngpaste/systems.nix @@ -0,0 +1,2 @@ +{ lib, hostPlatform, targetPlatform, ... }: +targetPlatform.isDarwin diff --git a/pkgs/swww/systems.nix b/pkgs/swww/systems.nix new file mode 100644 index 0000000..1134ddf --- /dev/null +++ b/pkgs/swww/systems.nix @@ -0,0 +1,3 @@ +{ lib, hostPlatform, targetPlatform, ... }: +# BUG: does not build +false