diff --git a/flake.nix b/flake.nix index e1d48e45..735ba49b 100644 --- a/flake.nix +++ b/flake.nix @@ -49,83 +49,21 @@ pkgs = mkPkgs inputs.nixpkgs; unstable = mkPkgs inputs.nixpkgs-unstable; - oldPkgs = mkPkgs inputs.oldNixpkgs; privateRepo = lib.my.pkgs.importPkgs ./pkgs; lib = nixpkgs.lib.extend (sefl: super: { hm = home-manager.lib.hm; - my = import ./lib { inherit lib system inputs pkgs unstable privateRepo oldPkgs; }; + my = import ./lib { inherit lib system inputs pkgs unstable privateRepo; }; }); - - templatesDirs = builtins.attrNames - (lib.filterAttrs (n: v: v == "directory") - (builtins.readDir ./templates)); - - templates = lib.lists.forEach templatesDirs (name: { - inherit name; - - value = { - path = ./templates/${name}; - description = "Template for ${name}"; - }; - }); - - devShells = - let - shellPkgs = import inputs.nixpkgs-unstable { - inherit system; - - config = { - allowUnfree = true; - allowBroken = true; - }; - }; - names = lib.my.string.mkNixNamesFromDir ./shells; - mkShellAttrs = name: { - inherit name; - value = pkgs.callPackage (./shells + "/${name}.nix") { unstable = shellPkgs; }; - }; - shells = builtins.listToAttrs (builtins.map mkShellAttrs names); - in - shells; in { lib = lib.my; - nixosConfigurations = - let - inherit (lib.attrsets) nameValuePair; - inherit (lib.my.hosts) mkHost; - inherit (lib.lists) flatten; - - hosts = builtins.attrNames (builtins.readDir ./hosts); - desktopHosts = lib.my.string.mkNixNamesFromDir ./modules/desktop/wm; - - finalHosts = (flatten (builtins.map (x: builtins.map (d: "${x}-${d}") desktopHosts) hosts)) ++ hosts; - - devHosts = builtins.listToAttrs (builtins.map - (n: - let devName = "${n}-dev"; - in - nameValuePair (devName) (mkHost { - name = devName; - isDevMode = true; - })) - finalHosts); - - normalHosts = builtins.listToAttrs (builtins.map - (name: { - inherit name; - value = mkHost { inherit name; }; - }) - finalHosts); - in - normalHosts // devHosts; - + nixosConfigurations = import ./nixos-configs.nix { inherit lib; }; overlays.default = overlays.overlay; - devShells.${pkgs.system} = devShells; + devShells.${system} = import ./shells.nix { inherit inputs lib pkgs; }; packages.${system} = privateRepo; - templates = builtins.listToAttrs templates; + templates = import ./templates.nix { inherit lib; }; }; } diff --git a/lib/default.nix b/lib/default.nix index 54c29de9..c92a4b1a 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,4 +1,4 @@ -{ lib, system, inputs, pkgs, unstable, privateRepo, oldPkgs, ... }: +{ lib, system, inputs, pkgs, unstable, privateRepo, ... }: with lib; let dotfilesPath = ./../dotfiles; @@ -7,6 +7,6 @@ in attrsets.mapAttrs' (n: v: { name = strings.removeSuffix ".nix" n; - value = import (./. + "/${n}") { inherit lib pkgs dotfilesPath privateRepo unstable inputs system secretDir oldPkgs; }; + value = import (./. + "/${n}") { inherit lib pkgs dotfilesPath privateRepo unstable inputs system secretDir; }; }) (builtins.readDir ./.) diff --git a/lib/desktop.nix b/lib/desktop.nix index 1896b904..57f967e8 100644 --- a/lib/desktop.nix +++ b/lib/desktop.nix @@ -1,4 +1,4 @@ -{ pkgs, lib, unstable, secretDir, oldPkgs, ... }: +{ pkgs, lib, unstable, secretDir, ... }: with lib; with lib.my; let @@ -30,7 +30,7 @@ let ''; mkDesktopApp = config: dotfiles: name: desktopName: import (./../modules/desktop/submodules + "/${name}.nix") { - inherit pkgs dotfiles config unstable lib desktopName secretDir oldPkgs; + inherit pkgs dotfiles config unstable lib desktopName secretDir; }; in { diff --git a/lib/hosts.nix b/lib/hosts.nix index 9c648d35..e23f8313 100644 --- a/lib/hosts.nix +++ b/lib/hosts.nix @@ -1,4 +1,4 @@ -{ lib, system, pkgs, unstable, privateRepo, inputs, dotfilesPath, secretDir, oldPkgs, ... }: +{ lib, system, pkgs, unstable, privateRepo, inputs, dotfilesPath, secretDir, ... }: with lib; with lib.my; let @@ -39,7 +39,7 @@ in inherit system; specialArgs = { - inherit pkgs unstable lib dotfiles isDevMode inputs privateRepo system hostname desktopName secretDir oldPkgs; + inherit pkgs unstable lib dotfiles isDevMode inputs privateRepo system hostname desktopName secretDir; templateDir = ./../templates; }; diff --git a/nixos-configs.nix b/nixos-configs.nix new file mode 100644 index 00000000..9c49f61e --- /dev/null +++ b/nixos-configs.nix @@ -0,0 +1,29 @@ +{ lib, ... }: +let + inherit (lib.attrsets) nameValuePair; + inherit (lib.my.hosts) mkHost; + inherit (lib.lists) flatten; + + hosts = builtins.attrNames (builtins.readDir ./hosts); + desktopHosts = lib.my.string.mkNixNamesFromDir ./modules/desktop/wm; + + finalHosts = (flatten (builtins.map (x: builtins.map (d: "${x}-${d}") desktopHosts) hosts)) ++ hosts; + + devHosts = builtins.listToAttrs (builtins.map + (n: + let devName = "${n}-dev"; + in + nameValuePair (devName) (mkHost { + name = devName; + isDevMode = true; + })) + finalHosts); + + normalHosts = builtins.listToAttrs (builtins.map + (name: { + inherit name; + value = mkHost { inherit name; }; + }) + finalHosts); +in +normalHosts // devHosts diff --git a/shells.nix b/shells.nix new file mode 100644 index 00000000..bd0c1c26 --- /dev/null +++ b/shells.nix @@ -0,0 +1,17 @@ +{ inputs, lib, pkgs, ... }: with lib; +with lib.my; let + shellPkgs = import inputs.nixpkgs-unstable { + inherit system; + + config = { + allowUnfree = true; + allowBroken = true; + }; + }; + names = lib.my.string.mkNixNamesFromDir ./shells; + mkShellAttrs = name: { + inherit name; + value = pkgs.callPackage (./shells + "/${name}.nix") { unstable = shellPkgs; }; + }; +in +builtins.listToAttrs (builtins.map mkShellAttrs names) diff --git a/templates.nix b/templates.nix new file mode 100644 index 00000000..52f9a3da --- /dev/null +++ b/templates.nix @@ -0,0 +1,15 @@ +{ lib, ... }: with lib; with lib.my; let + templatesDirs = builtins.attrNames + (lib.filterAttrs (n: v: v == "directory") + (builtins.readDir ./templates)); + + templates = lists.forEach templatesDirs (name: { + inherit name; + + value = { + path = ./templates/${name}; + description = "Template for ${name}"; + }; + }); +in +builtins.listToAttrs templates