From 921076703628bb40e8227299532c7083e547be72 Mon Sep 17 00:00:00 2001 From: clerie Date: Mon, 13 May 2024 16:05:48 +0200 Subject: [PATCH] flake.nix: Centralize overlays --- flake.nix | 19 ++++--------------- flake/nixpkgs.nix | 17 +++++++++++++++++ flake/overlay.nix | 14 ++++++++++++++ lib/flake-helper.nix | 9 ++------- 4 files changed, 37 insertions(+), 22 deletions(-) create mode 100644 flake/nixpkgs.nix create mode 100644 flake/overlay.nix diff --git a/flake.nix b/flake.nix index 7019623..982a51c 100644 --- a/flake.nix +++ b/flake.nix @@ -35,6 +35,7 @@ outputs = { self, nixpkgs, nixos-hardware, chaosevents, fernglas, nixos-exporter, solid-xmpp-alarm, ssh-to-age, ... }@inputs: let lib = import ./lib inputs; helper = lib.flake-helper; + localNixpkgs = import ./flake/nixpkgs.nix inputs; in { clerie.hosts = { aluminium = { @@ -93,30 +94,18 @@ colmena = { meta = { - nixpkgs = import nixpkgs { - system = "x86_64-linux"; - }; + nixpkgs = localNixpkgs.x86_64-linux; }; } // helper.mapToColmenaHosts self.nixosConfigurations; overlays = { + nixfilesInputs = import ./flake/overlay.nix inputs; clerie = import ./pkgs/overlay.nix; default = self.overlays.clerie; }; packages = nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-linux" ] (system: let - pkgs = import nixpkgs { - inherit system; - overlays = [ - self.overlays.clerie - (_: _: { - inherit (chaosevents.packages.${system}) - chaosevents; - inherit (ssh-to-age.packages.${system}) - ssh-to-age; - }) - ]; - }; + pkgs = localNixpkgs.${system}; in { inherit (pkgs) clerie-keys diff --git a/flake/nixpkgs.nix b/flake/nixpkgs.nix new file mode 100644 index 0000000..08d7246 --- /dev/null +++ b/flake/nixpkgs.nix @@ -0,0 +1,17 @@ +{ self +, nixpkgs +, ... +}@inputs: + +let + mkNixpkgs = { system, ... }@args: + import nixpkgs { + inherit system; + overlays = [ + self.overlays.nixfilesInputs + self.overlays.clerie + ]; + }; + +in + nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-linux" ] (system: mkNixpkgs { inherit system; }) diff --git a/flake/overlay.nix b/flake/overlay.nix new file mode 100644 index 0000000..6b0e364 --- /dev/null +++ b/flake/overlay.nix @@ -0,0 +1,14 @@ +{ self +, bij +, chaosevents +, ssh-to-age +, ... +}@inputs: +final: prev: { + inherit (bij.packages.${final.system}) + bij; + inherit (chaosevents.packages.${final.system}) + chaosevents; + inherit (ssh-to-age.packages.${final.system}) + ssh-to-age; +} diff --git a/lib/flake-helper.nix b/lib/flake-helper.nix index 1778c7b..4557974 100644 --- a/lib/flake-helper.nix +++ b/lib/flake-helper.nix @@ -1,4 +1,4 @@ -{ self, nixpkgs, bij, chaosevents, fernglas, fieldpoc, nixos-exporter, solid-xmpp-alarm, sops-nix, ... }@inputs: +{ self, nixpkgs, fernglas, fieldpoc, nixos-exporter, solid-xmpp-alarm, sops-nix, ... }@inputs: rec { generateNixosSystem = { @@ -26,13 +26,8 @@ rec { ../users/clerie ({ ... }: { nixpkgs.overlays = [ + self.overlays.nixfilesInputs self.overlays.clerie - (_: _: { - inherit (bij.packages."${system}") - bij; - inherit (chaosevents.packages."x86_64-linux") - chaosevents; - }) ]; clerie.monitoring = nixpkgs.lib.attrsets.optionalAttrs (group != null) { serviceLevel = group; }; })