diff --git a/flake.nix b/flake.nix index c8708c09f..96f57b98e 100644 --- a/flake.nix +++ b/flake.nix @@ -17,7 +17,14 @@ , nixpkgs , nixpkgs-stable , flake-utils - }: { + }: + let + importPkgs = path: attrs: import path (attrs // { + config.allowAliases = false; + overlays = [ self.overlays.default ]; + }); + in + { # self: super: must be named final: prev: for `nix flake check` to be happy overlays = { default = final: prev: import ./overlays final prev; @@ -26,41 +33,24 @@ }; # for backward compatibility, is safe to delete, not referenced anywhere overlay = self.overlays.default; - } // flake-utils.lib.eachDefaultSystem (system: ( - let + } // flake-utils.lib.eachSystem [ "x86_64-linux" ] (system: + let + pkgs = importPkgs nixpkgs { inherit system; }; + inherit (pkgs) lib; + in + { + hydraJobs = + let + mkHydraJobs = pkgs: + let + mkEmacsSet = emacs: pkgs.recurseIntoAttrs ( + lib.filterAttrs + (n: v: builtins.typeOf v == "set" && ! lib.isDerivation v) + (pkgs.emacsPackagesFor emacs) + ); - importPkgs = path: import path { - inherit system; - config.allowAliases = false; - overlays = [ self.overlays.default ]; - }; - pkgs = importPkgs nixpkgs; - - inherit (pkgs) lib; - overlayAttributes = lib.pipe (import ./. pkgs pkgs) [ - builtins.attrNames - (lib.partition (n: lib.isDerivation pkgs.${n})) - ]; - attributesToAttrset = attributes: lib.pipe attributes [ - (map (n: lib.nameValuePair n pkgs.${n})) - lib.listToAttrs - ]; - - in - { - lib = attributesToAttrset overlayAttributes.wrong; - packages = attributesToAttrset overlayAttributes.right; - - hydraJobs = - let - mkHydraJobs = pkgs: let - mkEmacsSet = emacs: pkgs.recurseIntoAttrs ( - lib.filterAttrs - (n: v: builtins.typeOf v == "set" && ! lib.isDerivation v) - (pkgs.emacsPackagesFor emacs) - ); - - in { + in + { emacsen = { inherit (pkgs) emacsUnstable emacsUnstable-nox; inherit (pkgs) emacsGit emacsGit-nox; @@ -85,17 +75,33 @@ })) crossTargets); - packages = mkEmacsSet pkgs.emacs; packages-unstable = mkEmacsSet pkgs.emacsUnstable; }; - in - { - "22.11" = mkHydraJobs (importPkgs nixpkgs-stable); - "unstable" = mkHydraJobs pkgs; - }; + in + { + "22.11" = mkHydraJobs (importPkgs nixpkgs-stable { inherit system; }); + "unstable" = mkHydraJobs pkgs; + }; + }) // flake-utils.lib.eachDefaultSystem (system: ( + let + pkgs = importPkgs nixpkgs { inherit system; }; + inherit (pkgs) lib; + overlayAttributes = lib.pipe (import ./. pkgs pkgs) [ + builtins.attrNames + (lib.partition (n: lib.isDerivation pkgs.${n})) + ]; + attributesToAttrset = attributes: lib.pipe attributes [ + (map (n: lib.nameValuePair n pkgs.${n})) + lib.listToAttrs + ]; + + in + { + lib = attributesToAttrset overlayAttributes.wrong; + packages = attributesToAttrset overlayAttributes.right; } ));