From dee6c5d9cbc12ff3012a27a5e69dfe331089310b Mon Sep 17 00:00:00 2001 From: seth Date: Sat, 7 Sep 2024 11:51:57 -0400 Subject: tree-wide: use flake module for configurations --- lib/README.md | 8 --- lib/builders.nix | 181 ------------------------------------------------------- lib/default.nix | 14 +---- lib/lib.nix | 20 ------ 4 files changed, 3 insertions(+), 220 deletions(-) delete mode 100644 lib/builders.nix delete mode 100644 lib/lib.nix (limited to 'lib') diff --git a/lib/README.md b/lib/README.md index bde1e94..97814c5 100644 --- a/lib/README.md +++ b/lib/README.md @@ -1,13 +1,5 @@ # ./lib/ -## lib.nix - -Top-level declaration of my functions - -## builders.nix - -Wrappers around configurations builders such as `nixosSystem` and `darwinSystem` - ## nginx.nix Small helpers to avoid boilerplate in the `services.nginx` module diff --git a/lib/builders.nix b/lib/builders.nix deleted file mode 100644 index 34c8cb9..0000000 --- a/lib/builders.nix +++ /dev/null @@ -1,181 +0,0 @@ -{ - lib, - inputs, - self, -}: -let - /** - Wrap the `args` applied to `builder` with the result of `apply` - - # Type - - ``` - wrapBuilderWith :: (AttrSet -> AttrSet) -> (AttrSet -> AttrSet) -> AttrSet -> AttrSet - ``` - */ - wrapBuilderWith = - apply: builder: args: - builder (apply args); - - /** - Wrap the `args` applied to `builder` with the result of `apply` - - # Type - - ``` - wrapBuilder :: String -> (AttrSet -> AttrSet) -> AttrSet -> AttrSet - ``` - */ - wrapBuilder = - type: - wrapBuilderWith ( - { - modules ? [ ], - specialArgs ? { }, - ... - }@args: - args - // { - modules = modules ++ lib.attrValues (self."${type}Modules" or { }); - - specialArgs = specialArgs // { - inherit inputs; - }; - } - ); - - /** - Wrap the `args` to the NixOS `builder` function with nice defaults - - # Type - - ``` - wrapNixOS :: (AttrSet -> AttrSet) -> AttrSet -> AttrSet - ``` - */ - wrapNixOS = builder: args: wrapBuilder "nixos" builder args; - - /** - Wrap the `args` to the nix-darwin `builder` function with nice defaults - - # Type - - ``` - wrapDarwin :: (AttrSet -> AttrSet) -> AttrSet -> AttrSet - ``` - */ - wrapDarwin = builder: args: wrapBuilder "darwin" builder args; - - /** - Wrap the `args` to the home-manager `builder` function with nice defaults - - # Type - - ``` - wrapUser :: (AttrSet -> AttrSet) -> AttrSet -> AttrSet - ``` - */ - wrapUser = - builder: args: - wrapBuilderWith ( - { - modules ? [ ], - extraSpecialArgs ? { }, - ... - }@args: - args - // { - modules = modules ++ lib.attrValues (self.homeManagerModules or { }); - - extraSpecialArgs = extraSpecialArgs // { - inherit inputs; - }; - } - ) builder args; -in -{ - - /** - Wrap the `args` to `nixpkgs.lib.nixosSystem` function with nice defaults - - # Example - - ``` - nixosSystem { module = [ ./configuration.nix ]; } - ``` - - # Type - - ``` - nixosSystem :: AttrSet -> AttrSet - ``` - - # Arguments - - - [args] Base arguments to `nixpkgs.lib.nixosSystem` - */ - nixosSystem = wrapNixOS inputs.nixpkgs.lib.nixosSystem; - - /** - Wrap the `args` to `nixpkgs-stable.lib.nixosSystem` with nice defaults - - # Example - - ``` - nixosSystemStable { module = [ ./configuration.nix ]; } - ``` - - # Type - - ``` - nixosSystemStable :: AttrSet -> AttrSet - ``` - - # Arguments - - - [args] Base arguments to `nixpkgs.lib.nixosSystem` - */ - nixosSystemStable = wrapNixOS inputs.nixpkgs-stable.lib.nixosSystem; - - /** - Wrap the `args` to `nix-darwin.lib.darwinSystem` with nice defaults - - # Example - - ``` - darwinSystem { module = [ ./configuration.nix ]; } - ``` - - # Type - - ``` - darwinSystem :: AttrSet -> AttrSet - ``` - - # Arguments - - - [args] Base arguments to `nix-darwin.lib.darwinSystem` - */ - darwinSystem = wrapDarwin inputs.nix-darwin.lib.darwinSystem; - - /** - Wrap the `args` to `home-manager.lib.homeManagerConfiguration` with nice defaults - - # Example - - ``` - homeManagerConfiguration { module = [ ./configuration.nix ]; } - ``` - - # Type - - ``` - homeManagerConfiguration :: AttrSet -> AttrSet - ``` - - # Arguments - - - [args] Base arguments to `home-manager.lib.homeManagerConfiguration` - */ - homeManagerConfiguration = wrapUser inputs.home-manager.lib.homeManagerConfiguration; -} diff --git a/lib/default.nix b/lib/default.nix index 7a0cd74..df8d9fb 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,17 +1,9 @@ { lib, - self, - inputs, ... }: { - flake.lib = - (lib.extend ( - final: _: { - my = import ./lib.nix { - inherit self inputs; - lib = final; - }; - } - )).my; + flake.lib = { + nginx = import ./nginx.nix lib; + }; } diff --git a/lib/lib.nix b/lib/lib.nix deleted file mode 100644 index 54d6712..0000000 --- a/lib/lib.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ - lib, - inputs, - self, -}: -let - builders = import ./builders.nix { inherit lib inputs self; }; -in -{ - inherit builders; - - inherit (builders) - nixosSystem - nixosSystemStable - darwinSystem - homeManagerConfiguration - ; - - nginx = import ./nginx.nix lib; -} -- cgit v1.2.3