From eeae48b5d85e18c2dcb05a69530074382b502ea9 Mon Sep 17 00:00:00 2001 From: reo101 Date: Fri, 19 Jul 2024 12:35:01 +0300 Subject: [PATCH] refactor(flake): extract more stuff in flake modules `pkgs` redefinition (with overlays) `nix-topology` setup `agenix-rekey` setup --- flake.nix | 29 +++-------------------------- nix/agenix.nix | 15 +++++++++++++++ nix/pkgs.nix | 13 +++++++++++++ nix/topology.nix | 23 +++++++++++++++++++++++ 4 files changed, 54 insertions(+), 26 deletions(-) create mode 100644 nix/agenix.nix create mode 100644 nix/pkgs.nix create mode 100644 nix/topology.nix diff --git a/flake.nix b/flake.nix index ad8d707..a20e744 100644 --- a/flake.nix +++ b/flake.nix @@ -147,24 +147,16 @@ ]; imports = [ - inputs.agenix-rekey.flakeModule - inputs.nix-topology.flakeModule - ] ++ [ + ./nix/pkgs.nix ./nix/machines.nix ./nix/modules.nix ./nix/configurations.nix + ./nix/agenix.nix ./nix/deploy.nix + ./nix/topology.nix ]; perSystem = { lib, pkgs, system, ... }: { - _module.args.pkgs = import inputs.nixpkgs { - inherit system; - overlays = lib.attrValues outputs.overlays ++ [ - inputs.nix-topology.overlays.default - ]; - config = { }; - }; - # Packages (`nix build`) packages = import ./pkgs { inherit pkgs; }; @@ -176,21 +168,6 @@ # Formatter (`nix fmt`) formatter = pkgs.nixpkgs-fmt; - - topology = { - modules = [ - ]; - nixosConfigurations = { - inherit (self.nixosConfigurations) - jeeves; - }; - }; - - agenix-rekey = { - nodes = { - inherit (self.nixosConfigurations) jeeves; - }; - }; }; flake = { diff --git a/nix/agenix.nix b/nix/agenix.nix new file mode 100644 index 0000000..a82da6d --- /dev/null +++ b/nix/agenix.nix @@ -0,0 +1,15 @@ +{ lib, config, self, inputs, ... }: + +{ + imports = [ + inputs.agenix-rekey.flakeModule + ]; + + perSystem = { + agenix-rekey = { + nodes = { + inherit (self.nixosConfigurations) jeeves; + }; + }; + }; +} diff --git a/nix/pkgs.nix b/nix/pkgs.nix new file mode 100644 index 0000000..78c42e2 --- /dev/null +++ b/nix/pkgs.nix @@ -0,0 +1,13 @@ +{ lib, config, self, inputs, ... }: + +{ + perSystem = { lib, pkgs, system, ... }: { + _module.args.pkgs = import inputs.nixpkgs { + inherit system; + overlays = lib.attrValues self.overlays ++ [ + inputs.nix-topology.overlays.default + ]; + config = { }; + }; + }; +} diff --git a/nix/topology.nix b/nix/topology.nix new file mode 100644 index 0000000..411b9b0 --- /dev/null +++ b/nix/topology.nix @@ -0,0 +1,23 @@ +{ lib, config, self, inputs, ... }: + +let + modules = [ + { + } + ]; +in +{ + imports = [ + inputs.nix-topology.flakeModule + ]; + + perSystem = { + topology = { + inherit modules; + nixosConfigurations = { + inherit (self.nixosConfigurations) + jeeves; + }; + }; + }; +}