diff --git a/README.md b/README.md index f5efc51..77f04da 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,4 @@ big warning shouting at them, I feel like showing off. :^) - [tinted-theming](https://github.com/tinted-theming) - used their base16 stuff when needed. - [fdncred](https://github.com/fdncred) - made the `ls` alias i use +- [diniamo](https://github.com/diniamo) - used his idea of importing a custom lib into nixos diff --git a/hosts/default.nix b/hosts/default.nix index e16da21..9289433 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -3,10 +3,10 @@ self, ... }: let - inherit (self) lib; + inherit (self.lib) mkHosts; in { flake = { - nixosConfigurations = builtins.mapAttrs (n: v: lib.mkHost (v // {host = n;})) { + nixosConfigurations = mkHosts { solterra = { system = "x86_64-linux"; extraModules = [ diff --git a/lib/default.nix b/lib/default.nix index 4bacfb5..8b4c4e7 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -3,46 +3,55 @@ self, ... }: { - flake.lib = inputs.nixpkgs.lib.extend (_: _: { + flake.lib = let + inherit (inputs.nixpkgs.lib) nixosSystem; + inherit (builtins) mapAttrs; mkHost = { - host, + hostname, system, extraModules ? [], + extraSpecialArgs ? {}, }: - inputs.nixpkgs.lib.nixosSystem { + nixosSystem { inherit system; + specialArgs = {inherit inputs self;} // extraSpecialArgs; modules = - extraModules - ++ [ - ../hosts/${host} - inputs.self.nixosModules.default - ({config, ...}: { - config = { - nix = { - settings.extra-experimental-features = [ - "nix-command" - "flakes" - ]; - gc = { - automatic = true; - dates = "weekly"; - }; - }; - nixpkgs.config.allowUnfree = true; - environment.shellAliases = { - rebs = "nixos-rebuild --use-remote-sudo switch --flake .#${host}"; - rebt = "nixos-rebuild --use-remote-sudo test --flake .#${host}"; - }; - networking.hostName = host; - systemd.oomd = { - enableRootSlice = true; + [ + ../hosts/${hostname} + self.nixosModules.default + { + _module.args = { + lib' = self.lib; + inherit system; + }; + + nixpkgs = { + inherit system; + config.allowUnfree = true; + }; + } + { + networking.hostName = hostname; + nix = { + settings.extra-experimental-features = [ + "nix-command" + "flakes" + ]; + gc = { + automatic = true; + dates = "weekly"; }; }; - }) - ]; - specialArgs = { - inherit inputs self; - }; + systemd.oomd = { + enableRootSlice = true; + extraConfig = {DefaultMemoryPressureDurationSec = "20s";}; + }; + } + ] + ++ extraModules; }; - }); + mkHosts = mapAttrs (hostname: args: mkHost (args // {inherit hostname;})); + in { + inherit mkHosts; + }; }