From 75ca1eb38f72d544a2cbc5375accabf5b4b224ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikodem=20Rabuli=C5=84ski?= Date: Mon, 31 Mar 2025 23:54:18 +0200 Subject: [PATCH] modules/nilla: flake compatibility module --- flake.nix | 53 +-------------------------------------- modules/nilla/default.nix | 1 + modules/nilla/flake.nix | 31 +++++++++++++++++++++++ 3 files changed, 33 insertions(+), 52 deletions(-) create mode 100644 modules/nilla/flake.nix diff --git a/flake.nix b/flake.nix index d54c0be..ea0a9e0 100644 --- a/flake.nix +++ b/flake.nix @@ -1,34 +1,5 @@ { - outputs = - inputs: - let - nilla = import ./nilla.nix { inherit inputs; }; - systems = [ - "x86_64-linux" - "aarch64-linux" - "aarch64-darwin" - ]; - # NOTE: Assumes every package is available for every system. - # For now let's say this is always the case. - transpose = - attrs: - let - inherit (inputs.nixpkgs) lib; - mappedForSystem = system: builtins.mapAttrs (_: pkg: pkg.result.${system}) attrs; - in - lib.genAttrs systems mappedForSystem; - in - { - inherit (nilla) nixosModules; - inherit (nilla) darwinModules; - inherit (nilla) homeModules; - inherit (nilla) nixosConfigurations; - inherit (nilla) darwinConfigurations; - inherit (nilla) homeConfigurations; - devShells = transpose nilla.shells; - packages = transpose nilla.packages; - formatter = nilla.packages.formatter.result; - }; + outputs = inputs: (import ./nilla.nix { inherit inputs; }).flake; inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixpkgs-unstable"; @@ -128,26 +99,4 @@ flake = false; }; }; - - /* - TODO: Uncomment once (if ever?) nixConfig makes sense in flakes - nixConfig = { - extra-substituters = [ - "https://hyprland.cachix.org" - "https://cache.garnix.io" - "https://nix-community.cachix.org" - "https://hercules-ci.cachix.org" - "https://nrabulinski.cachix.org" - "https://cache.nrab.lol" - ]; - extra-trusted-public-keys = [ - "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" - "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - "hercules-ci.cachix.org-1:ZZeDl9Va+xe9j+KqdzoBZMFJHVQ42Uu/c/1/KMC5Lw0=" - "nrabulinski.cachix.org-1:Q5FD7+1c68uH74CQK66UWNzxhanZW8xcg1LFXxGK8ic=" - "cache.nrab.lol-1:CJl1TouOyuJ1Xh4tZSXLwm3Upt06HzUNZmeyuEB9EZg=" - ]; - }; - */ } diff --git a/modules/nilla/default.nix b/modules/nilla/default.nix index bfcd452..71aed0d 100644 --- a/modules/nilla/default.nix +++ b/modules/nilla/default.nix @@ -4,5 +4,6 @@ ./services.nix ./configurations.nix ./modules.nix + ./flake.nix ]; } diff --git a/modules/nilla/flake.nix b/modules/nilla/flake.nix new file mode 100644 index 0000000..f3fe6f1 --- /dev/null +++ b/modules/nilla/flake.nix @@ -0,0 +1,31 @@ +{ lib, config }: +let + systems = [ + "x86_64-linux" + "aarch64-linux" + "aarch64-darwin" + ]; + transpose = + attrs: lib.attrs.generate systems (system: builtins.mapAttrs (_: pkg: pkg.result.${system}) attrs); +in +{ + options.flake = lib.options.create { + type = lib.types.attrs.of lib.types.raw; + }; + + config.flake = { + inherit (config) + nixosModules + darwinModules + homeModules + nixosConfigurations + darwinConfigurations + homeConfigurations + ; + + devShells = transpose config.shells; + packages = transpose config.packages; + + formatter = config.packages.formatter.result; + }; +}