From 63f79df82b4f7ae58dd68e603b5235dc4a0e974f Mon Sep 17 00:00:00 2001 From: SebastianStork Date: Fri, 12 Jul 2024 00:31:20 +0200 Subject: [PATCH] Modularize flake outputs --- flake.nix | 52 +++++------------------------------ flake/devShells.nix | 14 ++++++++++ flake/formatter.nix | 13 +++++++++ flake/nixosConfigurations.nix | 30 ++++++++++++++++++++ 4 files changed, 64 insertions(+), 45 deletions(-) create mode 100644 flake/devShells.nix create mode 100644 flake/formatter.nix create mode 100644 flake/nixosConfigurations.nix diff --git a/flake.nix b/flake.nix index 6806cbf..552c4ec 100644 --- a/flake.nix +++ b/flake.nix @@ -52,52 +52,14 @@ }; outputs = - inputs: - inputs.flake-parts.lib.mkFlake { inherit inputs; } { + { flake-parts, ... }@inputs: + flake-parts.lib.mkFlake { inherit inputs; } { systems = [ "x86_64-linux" ]; - flake = { - nixosConfigurations = { - north = inputs.nixpkgs.lib.nixosSystem { - specialArgs = { - inherit (inputs) self; - inherit inputs; - }; - modules = [ - ./hosts/north - "${inputs.self}/users/seb/@north" - ]; - }; - inspiron = inputs.nixpkgs.lib.nixosSystem { - specialArgs = { - inherit (inputs) self; - inherit inputs; - }; - modules = [ - ./hosts/inspiron - "${inputs.self}/users/seb/@inspiron" - ]; - }; - }; - }; - - perSystem = - { pkgs, ... }: - { - devShells.sops = pkgs.mkShell { - packages = [ - pkgs.sops - pkgs.age - pkgs.ssh-to-age - ]; - }; - - formatter = - (inputs.treefmt-nix.lib.evalModule pkgs { - projectRootFile = "flake.nix"; - programs.nixfmt.enable = true; - programs.prettier.enable = true; - }).config.build.wrapper; - }; + imports = [ + ./flake/nixosConfigurations.nix + ./flake/devShells.nix + ./flake/formatter.nix + ]; }; } diff --git a/flake/devShells.nix b/flake/devShells.nix new file mode 100644 index 0000000..d78f79b --- /dev/null +++ b/flake/devShells.nix @@ -0,0 +1,14 @@ +{ ... }: +{ + perSystem = + { pkgs, ... }: + { + devShells.sops = pkgs.mkShell { + packages = [ + pkgs.sops + pkgs.age + pkgs.ssh-to-age + ]; + }; + }; +} diff --git a/flake/formatter.nix b/flake/formatter.nix new file mode 100644 index 0000000..f6bf331 --- /dev/null +++ b/flake/formatter.nix @@ -0,0 +1,13 @@ +{ inputs, ... }: +{ + perSystem = + { pkgs, ... }: + { + formatter = + (inputs.treefmt-nix.lib.evalModule pkgs { + projectRootFile = "flake.nix"; + programs.nixfmt.enable = true; + programs.prettier.enable = true; + }).config.build.wrapper; + }; +} diff --git a/flake/nixosConfigurations.nix b/flake/nixosConfigurations.nix new file mode 100644 index 0000000..1842e1b --- /dev/null +++ b/flake/nixosConfigurations.nix @@ -0,0 +1,30 @@ +{ + nixpkgs, + self, + inputs, + ... +}: +{ + flake = { + nixosConfigurations = { + north = inputs.nixpkgs.lib.nixosSystem { + specialArgs = { + inherit self inputs; + }; + modules = [ + "${self}/hosts/north" + "${self}/users/seb/@north" + ]; + }; + inspiron = inputs.nixpkgs.lib.nixosSystem { + specialArgs = { + inherit self inputs; + }; + modules = [ + "${self}/hosts/inspiron" + "${self}/users/seb/@inspiron" + ]; + }; + }; + }; +}