From c5e248e9ff6c44fc4282560bf36debf3eb4f9a4e Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Mon, 3 Jul 2023 01:34:00 +0200 Subject: [PATCH] expose helpers in self.lib --- flake.nix | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/flake.nix b/flake.nix index cffaf8b..d7d6f71 100644 --- a/flake.nix +++ b/flake.nix @@ -40,25 +40,28 @@ ... } @ inputs: let - systems = [ + flake = inputs: system: nixpkgs.lib.mapAttrs (name: flake: { + # TODO filter non-flake inputs + nixos = flake.nixosModules + or null; + pkgs = flake.packages.${system} + or flake.legacyPackages.${system} + or null; + lib = flake.lib.${system} + or flake.lib + or null; + }) inputs; + forSystems = systems: f: nixpkgs.lib.genAttrs systems (system: f rec { + inherit system; + pkgs = nixpkgs.legacyPackages.${system}; + lib = nixpkgs.legacyPackages.${system}.lib; + flakes = flake inputs system; + }); + forAllSystems = forSystems [ "x86_64-linux" "aarch64-linux" #"riscv64-linux" ]; - flake = system: nixpkgs.lib.mapAttrs (name: flake: { - # TODO filter non-flake inputs - lib = flake.lib.${system} or null; - nixos = flake.nixosModules or null; - pkgs = flake.packages.${system} - or flake.legacyPackages.${system} - or null; - }) inputs; - forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f rec { - inherit system; - pkgs = nixpkgs.legacyPackages.${system}; - lib = nixpkgs.legacyPackages.${system}.lib; - flakes = flake system; - }); # TODO: move unstable here? tmpConfig = { @@ -73,7 +76,7 @@ inherit system; specialArgs = { inherit inputs; - flakes = flake system; + flakes = flake inputs system; }; modules = modules ++ [ ./base.nix "${self}/hosts/${hostname}" tmpConfig ({ home-manager.extraSpecialArgs = { @@ -109,6 +112,12 @@ mpv-webm = pkgs.callPackage ./pkgs/mpv-webm.nix {}; # https://github.com/NixOS/nixpkgs/pull/238659 }); + lib = { + inherit flake forSystems; + } // forAllSystems({ ... }: { + inherit flake forSystems; + }); + nixosConfigurations = let nm = nixos-hardware.nixosModules; in { # TODO: move nixos-hardware imports to the nixos configs? noximilien = mkConfig "noximilien" "pbsds.net" "x86_64-linux" (with nm; [ common-pc common-pc-ssd common-cpu-intel ]);