diff --git a/devShells/_default.nix b/devShells/_default.nix new file mode 100644 index 0000000..ad4c030 --- /dev/null +++ b/devShells/_default.nix @@ -0,0 +1,30 @@ +{ inputs', ... }: +let + inherit (inputs'.unstable) lib; + pkgs = inputs'.unstable.legacyPackages; +in +lib.pipe ./. [ + builtins.readDir + builtins.attrNames + (builtins.filter (x: x != "_default.nix")) + (map ( + x: + let + fullPath = ./. + "/${x}"; + in + { + ${lib.removeSuffix ".nix" x} = lib.callPackageWith ( + pkgs + // pkgs.xorg + // { + inherit inputs'; + self' = inputs'.self; + # npins sources if i ever use them + # sources = lib.mapAttrs (_: pkgs.npins.mkSource) (lib.importJSON "${self}/packages/sources.json").pins; + } + ) fullPath { }; + } + )) + + lib.mergeAttrsList +] diff --git a/devShells/default.nix b/devShells/default.nix new file mode 100644 index 0000000..0a5a283 --- /dev/null +++ b/devShells/default.nix @@ -0,0 +1 @@ +{ mkShellNoCC, sops }: mkShellNoCC { packages = [ sops ]; } diff --git a/diskoConfigurations/_default.nix b/diskoConfigurations/_default.nix new file mode 100644 index 0000000..6d21a6b --- /dev/null +++ b/diskoConfigurations/_default.nix @@ -0,0 +1,18 @@ +inputs: +let + inherit (inputs.unstable) lib; +in +lib.pipe ./. [ + builtins.readDir + (lib.filterAttrs (n: v: v == "regular" && lib.hasSuffix ".nix" n && n != "_default.nix")) + builtins.attrNames + (map (x: { + name = lib.pipe x [ + (lib.removeSuffix (toString ./.)) + (lib.removeSuffix ".nix") + (x: "disko-${x}") + ]; + value.disko.devices = import "${./.}/${x}" lib; + })) + builtins.listToAttrs +] diff --git a/disko/gerg-desktop.nix b/diskoConfigurations/gerg-desktop.nix similarity index 100% rename from disko/gerg-desktop.nix rename to diskoConfigurations/gerg-desktop.nix diff --git a/disko/media-laptop.nix b/diskoConfigurations/media-laptop.nix similarity index 100% rename from disko/media-laptop.nix rename to diskoConfigurations/media-laptop.nix diff --git a/disko/proxy.nix b/diskoConfigurations/proxy.nix similarity index 100% rename from disko/proxy.nix rename to diskoConfigurations/proxy.nix diff --git a/flake.lock b/flake.lock index d956fd0..3c86d88 100644 --- a/flake.lock +++ b/flake.lock @@ -241,11 +241,11 @@ }, "master": { "locked": { - "lastModified": 1737083351, - "narHash": "sha256-hCddtSuk6m6XROmdOC0te0j2sLeUr28QIzNRk0qF1as=", + "lastModified": 1737155754, + "narHash": "sha256-dIjCfIEkHUQI8WMkHLhAXyrYsk2RNqqIFAXFQdwTQn0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "0993fc268872148cebcd1fac8660a8b8ced49542", + "rev": "7d5856e1fbacca23cca90549b81e5aacbc76e9c7", "type": "github" }, "original": { @@ -570,6 +570,7 @@ "spicetify-nix": "spicetify-nix", "stable": "stable", "suckless": "suckless", + "systems": "systems", "unstable": "unstable" } }, @@ -619,11 +620,11 @@ ] }, "locked": { - "lastModified": 1736808430, - "narHash": "sha256-wlgdf/n7bJMLBheqt1jmPoxJFrUP6FByKQFXuM9YvIk=", + "lastModified": 1737107480, + "narHash": "sha256-GXUE9+FgxoZU8v0p6ilBJ8NH7k8nKmZjp/7dmMrCv3o=", "owner": "mic92", "repo": "sops-nix", - "rev": "553c7cb22fed19fd60eb310423fdc93045c51ba8", + "rev": "4c4fb93f18b9072c6fa1986221f9a3d7bf1fe4b6", "type": "github" }, "original": { @@ -689,13 +690,28 @@ "type": "github" } }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "unstable": { "locked": { - "lastModified": 1736883708, - "narHash": "sha256-uQ+NQ0/xYU0N1CnXsa2zghgNaOPxWpMJXSUJJ9W7140=", + "lastModified": 1737062831, + "narHash": "sha256-Tbk1MZbtV2s5aG+iM99U8FqwxU/YNArMcWAv6clcsBc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "eb62e6aa39ea67e0b8018ba8ea077efe65807dc8", + "rev": "5df43628fdf08d642be8ba5b3625a6c70731c19c", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 6ec18e9..bcf8fe4 100644 --- a/flake.nix +++ b/flake.nix @@ -94,8 +94,41 @@ repo = "reboot-bot"; inputs.nixpkgs.follows = "unstable"; }; + systems = { + type = "github"; + owner = "nix-systems"; + repo = "default"; + }; }; - - outputs = x: import ./outputs.nix x; + outputs = + inputs: + let + inherit (inputs.unstable) lib; + myLib = import (./. + /lib/_default.nix) inputs; + in + lib.pipe ./. [ + builtins.readDir + (lib.filterAttrs (n: v: v == "directory" && !lib.hasPrefix "." n)) + (lib.flip ( + system: + (builtins.mapAttrs ( + n: _: + let + imported = import (./. + "/${n}/_default.nix"); + in + if myLib.needsSystem n then + { + ${system} = imported { + inputs' = myLib.constructInputs' system inputs; + inherit system; + }; + } + else + imported inputs + )) + )) + (lib.flip map (import inputs.systems)) + (lib.foldAttrs (l: r: if myLib.needsSystem l then l else l // r) { }) + ]; } diff --git a/formatter/_default.nix b/formatter/_default.nix new file mode 100644 index 0000000..632505b --- /dev/null +++ b/formatter/_default.nix @@ -0,0 +1 @@ +{ inputs', ... }: inputs'.self.packages.lint diff --git a/lib/_default.nix b/lib/_default.nix new file mode 100644 index 0000000..f7d5e2a --- /dev/null +++ b/lib/_default.nix @@ -0,0 +1,139 @@ +{ + unstable, + self, + ... +}@inputs: +let + inherit (unstable) lib; +in +lib.fix (myLib: { + wrench = lib.flip lib.pipe; + + needsSystem = lib.flip builtins.elem [ + "defaultPackage" + "devShell" + "devShells" + "formatter" + "legacyPackages" + "packages" + ]; + + constructInputs' = + system: + myLib.wrench [ + (lib.filterAttrs (_: lib.isType "flake")) + (lib.mapAttrs ( + _: lib.mapAttrs (name: value: if myLib.needsSystem name then value.${system} else value) + )) + ]; + + listNixFilesRecursive = myLib.wrench [ + builtins.unsafeDiscardStringContext + lib.filesystem.listFilesRecursive + (builtins.filter (x: !lib.hasPrefix "_" (builtins.baseNameOf x) && lib.hasSuffix ".nix" x)) + ]; + + addSchizophreniaToModule = + x: + let + # the imported module + imported = import x; + in + /* + If the module isn't a function then + it doesn't need arguments and error + message locations will function correctly + */ + if !lib.isFunction imported then + x + else + let + # all arguments defined in the module + funcArgs = lib.functionArgs imported; + /* + The names of all arguments which will be + available to be inserted into the module arguments + */ + argNames = builtins.attrNames inputs ++ [ + "inputs" + "inputs'" + "self'" + "_dir" + ]; + + /* + arguments to be passed minus + per system attributes + for example flake-parts-esque inputs' + */ + argsPre = { + inherit inputs self; + /* + _dir is the "self" derived + path to the directory containing the module + */ + _dir = builtins.dirOf x; + }; + + /* + arguments which will be inserted + set to the before per-system values + */ + providedArgs = lib.pipe funcArgs [ + (lib.filterAttrs (n: _: builtins.elem n argNames)) + (lib.mapAttrs (n: _: argsPre.${n} or { })) + ]; + + /* + arguments which the module system + not provided here. either to be + provided by the module system or invalid + */ + neededArgs = lib.filterAttrs (n: _: !builtins.elem n argNames) funcArgs; + in + { + __functionArgs = neededArgs // { + /* + always require pkgs to be passed + to derive system from pkgs.stdenv.system + */ + pkgs = false; + }; + + __functor = + /* + args is specialArgs + _module.args which are needed + and always pkgs + */ + _: args: + imported ( + /* + take module system provided arguments + filter them so only the required ones are passed + */ + (lib.filterAttrs (n: _: neededArgs ? ${n}) args) + # add needed arguments + // ( + providedArgs + # add system dependent arguments + // ( + let + inputs' = myLib.constructInputs' args.pkgs.stdenv.system inputs; + + actuallyAllArgs = inputs' // { + inherit inputs'; + self' = inputs'.self; + inherit (inputs) self; + }; + in + lib.filterAttrs (n: _: providedArgs ? ${n}) actuallyAllArgs + ) + ) + ) + # add _file to the final module attribute set + // { + _file = x; + }; + }; + +}) diff --git a/lib/default.nix b/lib/default.nix deleted file mode 100644 index dd74269..0000000 --- a/lib/default.nix +++ /dev/null @@ -1,282 +0,0 @@ -inputs@{ - unstable, - self, - disko, - ... -}: -let - inherit (unstable) lib; -in -# Only good use case for rec -rec { - wrench = lib.flip lib.pipe; - - needsSystem = lib.flip builtins.elem [ - "defaultPackage" - "devShell" - "devShells" - "formatter" - "legacyPackages" - "packages" - ]; - - constructInputs' = - system: - wrench [ - (lib.filterAttrs (_: lib.isType "flake")) - (lib.mapAttrs (_: lib.mapAttrs (name: value: if needsSystem name then value.${system} else value))) - ]; - - listNixFilesRecursive = wrench [ - builtins.unsafeDiscardStringContext - lib.filesystem.listFilesRecursive - (builtins.filter (x: !lib.hasPrefix "_" (builtins.baseNameOf x) && lib.hasSuffix ".nix" x)) - ]; - - mkModules = - path: - lib.pipe path [ - listNixFilesRecursive - (map (name: { - name = lib.pipe name [ - (lib.removeSuffix ".nix") - (lib.removePrefix "${path}/") - ]; - value = addSchizophreniaToModule name; - })) - builtins.listToAttrs - ]; - - addSchizophreniaToModule = - x: - let - # the imported module - imported = import x; - in - /* - If the module isn't a function then - it doesn't need arguments and error - message locations will function correctly - */ - if !lib.isFunction imported then - x - else - let - # all arguments defined in the module - funcArgs = lib.functionArgs imported; - /* - The names of all arguments which will be - available to be inserted into the module arguments - */ - argNames = builtins.attrNames inputs ++ [ - "inputs" - "inputs'" - "self'" - "_dir" - ]; - - /* - arguments to be passed minus - per system attributes - for example flake-parts-esque inputs' - */ - argsPre = { - inherit inputs self; - /* - _dir is the "self" derived - path to the directory containing the module - */ - _dir = builtins.dirOf x; - }; - - /* - arguments which will be inserted - set to the before per-system values - */ - providedArgs = lib.pipe funcArgs [ - (lib.filterAttrs (n: _: builtins.elem n argNames)) - (lib.mapAttrs (n: _: argsPre.${n} or { })) - ]; - - /* - arguments which the module system - not provided here. either to be - provided by the module system or invalid - */ - neededArgs = lib.filterAttrs (n: _: !builtins.elem n argNames) funcArgs; - in - { - __functionArgs = neededArgs // { - /* - always require pkgs to be passed - to derive system from pkgs.stdenv.system - */ - pkgs = false; - }; - - __functor = - /* - args is specialArgs + _module.args which are needed - and always pkgs - */ - _: args: - imported ( - /* - take module system provided arguments - filter them so only the required ones are passed - */ - (lib.filterAttrs (n: _: neededArgs ? ${n}) args) - # add needed arguments - // ( - providedArgs - # add system dependent arguments - // ( - let - inputs' = constructInputs' args.pkgs.stdenv.system inputs; - - actuallyAllArgs = inputs' // { - inherit inputs'; - self' = inputs'.self; - inherit (inputs) self; - }; - in - lib.filterAttrs (n: _: providedArgs ? ${n}) actuallyAllArgs - ) - ) - ) - # add _file to the final module attribute set - // { - _file = x; - }; - }; - - gerg-utils = - pkgsf: outputs: - lib.pipe - [ - "x86_64-linux" - "aarch64-linux" - ] - [ - (map ( - system: - builtins.mapAttrs ( - name: value: if needsSystem name then { ${system} = value (pkgsf system); } else value - ) outputs - )) - (lib.foldAttrs lib.mergeAttrs { }) - ]; - - mkHosts = wrench [ - builtins.readDir - (lib.filterAttrs (_: v: v == "directory")) - builtins.attrNames - (map (x: { - name = x; - value = lib.evalModules { - specialArgs.modulesPath = "${unstable}/nixos/modules"; - modules = builtins.concatLists [ - (builtins.attrValues self.nixosModules) - (map addSchizophreniaToModule (listNixFilesRecursive "${self}/hosts/${x}")) - (import "${unstable}/nixos/modules/module-list.nix") - (lib.optionals (self.diskoConfigurations ? "disko-${x}") [ - self.diskoConfigurations."disko-${x}" - disko.nixosModules.default - ]) - ]; - }; - })) - builtins.listToAttrs - ]; - - mkDisko = - path: - lib.pipe path [ - builtins.readDir - (lib.filterAttrs (n: v: v == "regular" && lib.hasSuffix ".nix" n)) - builtins.attrNames - (map (x: { - name = lib.pipe x [ - (lib.removeSuffix path) - (lib.removeSuffix ".nix") - (x: "disko-${x}") - ]; - value.disko.devices = import "${path}/${x}" lib; - })) - builtins.listToAttrs - ]; - - /* - / -> packages named by directory - //call.nix -> callPackage override imported via import pkgs - call.nix example - {python3Packages}: { - inherit (python3Packages) callPackage; - args = {}; - } - - //package.nix -> the package itself - //wrapper.nix: - a optional wrapper for the package - which is callPackage'd with the original package - as an argument named -unwrapped - */ - mkPackages = - path: pkgs: - lib.pipe path [ - builtins.readDir - (lib.filterAttrs (_: v: v == "directory")) - builtins.attrNames - (map ( - n: - let - p = "${path}/${n}"; - - callPackage = - file: args: - let - defaultArgs = - pkgs - // pkgs.xorg - // ( - let - inputs' = constructInputs' pkgs.stdenv.system inputs; - in - { - inherit inputs' inputs; - self' = inputs'.self; - inherit (inputs) self; - # npins sources if i ever use them - # sources = lib.mapAttrs (_: pkgs.npins.mkSource) (lib.importJSON "${self}/packages/sources.json").pins; - } - ); - _callPackage = lib.callPackageWith defaultArgs; - fullPath = "${p}/${file}.nix"; - callPath = "${p}/call.nix"; - in - assert lib.assertMsg (builtins.pathExists fullPath) - "File attempting to be callPackage'd '${fullPath}' does not exist"; - - if builtins.pathExists callPath then - let - x = _callPackage callPath { }; - in - x.callPackage or _callPackage fullPath (x.args or defaultArgs // args) - - else - _callPackage fullPath args; - in - - if builtins.pathExists "${p}/wrapper.nix" then - # My distaste for rec grows ever stronger - let - set."${n}-unwrapped" = callPackage "package" { }; - in - { ${n} = callPackage "wrapper" set; } // set - else - { ${n} = callPackage "package" { }; } - - )) - lib.mergeAttrsList - ]; -} diff --git a/nixosConfigurations/_default.nix b/nixosConfigurations/_default.nix new file mode 100644 index 0000000..9d90595 --- /dev/null +++ b/nixosConfigurations/_default.nix @@ -0,0 +1,29 @@ +{ + self, + unstable, + disko, + ... +}: +let + myLib = self.lib; + inherit (unstable) lib; +in +lib.pipe ./. [ + builtins.readDir + (lib.filterAttrs (_: v: v == "directory")) + (builtins.mapAttrs ( + x: _: + lib.evalModules { + specialArgs.modulesPath = "${unstable}/nixos/modules"; + modules = builtins.concatLists [ + (builtins.attrValues self.nixosModules) + (map myLib.addSchizophreniaToModule (myLib.listNixFilesRecursive (./. + "/${x}"))) + (import "${unstable}/nixos/modules/module-list.nix") + (lib.optionals (self.diskoConfigurations ? "disko-${x}") [ + self.diskoConfigurations."disko-${x}" + disko.nixosModules.default + ]) + ]; + } + )) +] diff --git a/hosts/gerg-desktop/1_mon.conf b/nixosConfigurations/gerg-desktop/1_mon.conf similarity index 100% rename from hosts/gerg-desktop/1_mon.conf rename to nixosConfigurations/gerg-desktop/1_mon.conf diff --git a/hosts/gerg-desktop/2_mon.conf b/nixosConfigurations/gerg-desktop/2_mon.conf similarity index 100% rename from hosts/gerg-desktop/2_mon.conf rename to nixosConfigurations/gerg-desktop/2_mon.conf diff --git a/hosts/gerg-desktop/Windows.xml b/nixosConfigurations/gerg-desktop/Windows.xml similarity index 100% rename from hosts/gerg-desktop/Windows.xml rename to nixosConfigurations/gerg-desktop/Windows.xml diff --git a/hosts/gerg-desktop/_vfio.nix b/nixosConfigurations/gerg-desktop/_vfio.nix similarity index 100% rename from hosts/gerg-desktop/_vfio.nix rename to nixosConfigurations/gerg-desktop/_vfio.nix diff --git a/hosts/gerg-desktop/boot.nix b/nixosConfigurations/gerg-desktop/boot.nix similarity index 100% rename from hosts/gerg-desktop/boot.nix rename to nixosConfigurations/gerg-desktop/boot.nix diff --git a/hosts/gerg-desktop/git.nix b/nixosConfigurations/gerg-desktop/git.nix similarity index 100% rename from hosts/gerg-desktop/git.nix rename to nixosConfigurations/gerg-desktop/git.nix diff --git a/hosts/gerg-desktop/kernelConfig b/nixosConfigurations/gerg-desktop/kernelConfig similarity index 100% rename from hosts/gerg-desktop/kernelConfig rename to nixosConfigurations/gerg-desktop/kernelConfig diff --git a/hosts/gerg-desktop/main.nix b/nixosConfigurations/gerg-desktop/main.nix similarity index 100% rename from hosts/gerg-desktop/main.nix rename to nixosConfigurations/gerg-desktop/main.nix diff --git a/hosts/gerg-desktop/secrets.yaml b/nixosConfigurations/gerg-desktop/secrets.yaml similarity index 100% rename from hosts/gerg-desktop/secrets.yaml rename to nixosConfigurations/gerg-desktop/secrets.yaml diff --git a/hosts/gerg-desktop/services/ddns.nix b/nixosConfigurations/gerg-desktop/services/ddns.nix similarity index 100% rename from hosts/gerg-desktop/services/ddns.nix rename to nixosConfigurations/gerg-desktop/services/ddns.nix diff --git a/hosts/gerg-desktop/services/ddns_script.sh b/nixosConfigurations/gerg-desktop/services/ddns_script.sh similarity index 100% rename from hosts/gerg-desktop/services/ddns_script.sh rename to nixosConfigurations/gerg-desktop/services/ddns_script.sh diff --git a/hosts/gerg-desktop/services/forgejo.nix b/nixosConfigurations/gerg-desktop/services/forgejo.nix similarity index 100% rename from hosts/gerg-desktop/services/forgejo.nix rename to nixosConfigurations/gerg-desktop/services/forgejo.nix diff --git a/hosts/gerg-desktop/services/immich.nix b/nixosConfigurations/gerg-desktop/services/immich.nix similarity index 100% rename from hosts/gerg-desktop/services/immich.nix rename to nixosConfigurations/gerg-desktop/services/immich.nix diff --git a/hosts/gerg-desktop/services/minecraft.nix b/nixosConfigurations/gerg-desktop/services/minecraft.nix similarity index 100% rename from hosts/gerg-desktop/services/minecraft.nix rename to nixosConfigurations/gerg-desktop/services/minecraft.nix diff --git a/hosts/gerg-desktop/services/miniflux.nix b/nixosConfigurations/gerg-desktop/services/miniflux.nix similarity index 100% rename from hosts/gerg-desktop/services/miniflux.nix rename to nixosConfigurations/gerg-desktop/services/miniflux.nix diff --git a/hosts/gerg-desktop/services/nginx.nix b/nixosConfigurations/gerg-desktop/services/nginx.nix similarity index 100% rename from hosts/gerg-desktop/services/nginx.nix rename to nixosConfigurations/gerg-desktop/services/nginx.nix diff --git a/hosts/gerg-desktop/services/nix-serve.nix b/nixosConfigurations/gerg-desktop/services/nix-serve.nix similarity index 100% rename from hosts/gerg-desktop/services/nix-serve.nix rename to nixosConfigurations/gerg-desktop/services/nix-serve.nix diff --git a/hosts/gerg-desktop/services/parrot.nix b/nixosConfigurations/gerg-desktop/services/parrot.nix similarity index 100% rename from hosts/gerg-desktop/services/parrot.nix rename to nixosConfigurations/gerg-desktop/services/parrot.nix diff --git a/hosts/gerg-desktop/services/postgresql.nix b/nixosConfigurations/gerg-desktop/services/postgresql.nix similarity index 100% rename from hosts/gerg-desktop/services/postgresql.nix rename to nixosConfigurations/gerg-desktop/services/postgresql.nix diff --git a/hosts/gerg-desktop/services/reboot-bot.nix b/nixosConfigurations/gerg-desktop/services/reboot-bot.nix similarity index 100% rename from hosts/gerg-desktop/services/reboot-bot.nix rename to nixosConfigurations/gerg-desktop/services/reboot-bot.nix diff --git a/hosts/gerg-desktop/services/searxng.nix b/nixosConfigurations/gerg-desktop/services/searxng.nix similarity index 100% rename from hosts/gerg-desktop/services/searxng.nix rename to nixosConfigurations/gerg-desktop/services/searxng.nix diff --git a/hosts/gerg-desktop/shared.conf b/nixosConfigurations/gerg-desktop/shared.conf similarity index 100% rename from hosts/gerg-desktop/shared.conf rename to nixosConfigurations/gerg-desktop/shared.conf diff --git a/hosts/gerg-desktop/spicetify.nix b/nixosConfigurations/gerg-desktop/spicetify.nix similarity index 100% rename from hosts/gerg-desktop/spicetify.nix rename to nixosConfigurations/gerg-desktop/spicetify.nix diff --git a/hosts/gerg-desktop/zfs.nix b/nixosConfigurations/gerg-desktop/zfs.nix similarity index 100% rename from hosts/gerg-desktop/zfs.nix rename to nixosConfigurations/gerg-desktop/zfs.nix diff --git a/hosts/iso/main.nix b/nixosConfigurations/iso/main.nix similarity index 100% rename from hosts/iso/main.nix rename to nixosConfigurations/iso/main.nix diff --git a/hosts/media-laptop/main.nix b/nixosConfigurations/media-laptop/main.nix similarity index 100% rename from hosts/media-laptop/main.nix rename to nixosConfigurations/media-laptop/main.nix diff --git a/hosts/media-laptop/secrets.yaml b/nixosConfigurations/media-laptop/secrets.yaml similarity index 100% rename from hosts/media-laptop/secrets.yaml rename to nixosConfigurations/media-laptop/secrets.yaml diff --git a/hosts/proxy/main.nix b/nixosConfigurations/proxy/main.nix similarity index 100% rename from hosts/proxy/main.nix rename to nixosConfigurations/proxy/main.nix diff --git a/hosts/proxy/server.nix b/nixosConfigurations/proxy/server.nix similarity index 100% rename from hosts/proxy/server.nix rename to nixosConfigurations/proxy/server.nix diff --git a/modules/DE/dwm.nix b/nixosModules/DE/dwm.nix similarity index 100% rename from modules/DE/dwm.nix rename to nixosModules/DE/dwm.nix diff --git a/modules/DE/gnome.nix b/nixosModules/DE/gnome.nix similarity index 100% rename from modules/DE/gnome.nix rename to nixosModules/DE/gnome.nix diff --git a/modules/DE/xfce.nix b/nixosModules/DE/xfce.nix similarity index 100% rename from modules/DE/xfce.nix rename to nixosModules/DE/xfce.nix diff --git a/modules/DM/autoLogin.nix b/nixosModules/DM/autoLogin.nix similarity index 100% rename from modules/DM/autoLogin.nix rename to nixosModules/DM/autoLogin.nix diff --git a/modules/DM/lightDM.nix b/nixosModules/DM/lightDM.nix similarity index 100% rename from modules/DM/lightDM.nix rename to nixosModules/DM/lightDM.nix diff --git a/modules/X11.nix b/nixosModules/X11.nix similarity index 100% rename from modules/X11.nix rename to nixosModules/X11.nix diff --git a/nixosModules/_default.nix b/nixosModules/_default.nix new file mode 100644 index 0000000..c9cf15b --- /dev/null +++ b/nixosModules/_default.nix @@ -0,0 +1,20 @@ +{ + self, + unstable, + ... +}: +let + myLib = self.lib; + inherit (unstable) lib; +in +lib.pipe ./. [ + myLib.listNixFilesRecursive + (map (name: { + name = lib.pipe name [ + (lib.removeSuffix ".nix") + (lib.removePrefix "${./.}/") + ]; + value = myLib.addSchizophreniaToModule name; + })) + builtins.listToAttrs +] diff --git a/modules/boot/other.nix b/nixosModules/boot/other.nix similarity index 100% rename from modules/boot/other.nix rename to nixosModules/boot/other.nix diff --git a/modules/boot/silent.nix b/nixosModules/boot/silent.nix similarity index 100% rename from modules/boot/silent.nix rename to nixosModules/boot/silent.nix diff --git a/modules/builders.nix b/nixosModules/builders.nix similarity index 100% rename from modules/builders.nix rename to nixosModules/builders.nix diff --git a/modules/hardware.nix b/nixosModules/hardware.nix similarity index 100% rename from modules/hardware.nix rename to nixosModules/hardware.nix diff --git a/modules/keys.nix b/nixosModules/keys.nix similarity index 100% rename from modules/keys.nix rename to nixosModules/keys.nix diff --git a/modules/misc.nix b/nixosModules/misc.nix similarity index 100% rename from modules/misc.nix rename to nixosModules/misc.nix diff --git a/modules/nix.nix b/nixosModules/nix.nix similarity index 100% rename from modules/nix.nix rename to nixosModules/nix.nix diff --git a/modules/packages.nix b/nixosModules/packages.nix similarity index 100% rename from modules/packages.nix rename to nixosModules/packages.nix diff --git a/modules/page.nix b/nixosModules/page.nix similarity index 100% rename from modules/page.nix rename to nixosModules/page.nix diff --git a/modules/security.nix b/nixosModules/security.nix similarity index 100% rename from modules/security.nix rename to nixosModules/security.nix diff --git a/modules/shell.nix b/nixosModules/shell.nix similarity index 100% rename from modules/shell.nix rename to nixosModules/shell.nix diff --git a/modules/sops.nix b/nixosModules/sops.nix similarity index 74% rename from modules/sops.nix rename to nixosModules/sops.nix index 954bf5e..862cdd8 100644 --- a/modules/sops.nix +++ b/nixosModules/sops.nix @@ -9,7 +9,7 @@ options.local.sops.disable = lib.mkEnableOption ""; config = lib.mkIf (!config.local.sops.disable) { sops = { - defaultSopsFile = "${self'}/hosts/${config.networking.hostName}/secrets.yaml"; + defaultSopsFile = "${self'}/nixosConfigurations/${config.networking.hostName}/secrets.yaml"; age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; }; }; diff --git a/modules/theming.nix b/nixosModules/theming.nix similarity index 100% rename from modules/theming.nix rename to nixosModules/theming.nix diff --git a/modules/zsh.nix b/nixosModules/zsh.nix similarity index 100% rename from modules/zsh.nix rename to nixosModules/zsh.nix diff --git a/packages/_default.nix b/packages/_default.nix new file mode 100644 index 0000000..1783e53 --- /dev/null +++ b/packages/_default.nix @@ -0,0 +1,70 @@ +/* + / -> packages named by directory + //call.nix -> callPackage override imported via import pkgs + call.nix example + {python3Packages}: { + inherit (python3Packages) callPackage; + args = {}; + } + + //package.nix -> the package itself + //wrapper.nix: + a optional wrapper for the package + which is callPackage'd with the original package + as an argument named -unwrapped +*/ +{ inputs', ... }: +let + inherit (inputs'.unstable) lib; + pkgs = inputs'.unstable.legacyPackages; +in +lib.pipe ./. [ + builtins.readDir + (lib.filterAttrs (_: v: v == "directory")) + builtins.attrNames + (map ( + n: + let + p = ./. + "/${n}"; + + callPackage = + file: args: + let + defaultArgs = + pkgs + // pkgs.xorg + // { + inherit inputs'; + self' = inputs'.self; + # npins sources if i ever use them + # sources = lib.mapAttrs (_: pkgs.npins.mkSource) (lib.importJSON "${self}/packages/sources.json").pins; + }; + _callPackage = lib.callPackageWith defaultArgs; + fullPath = p + "/${file}.nix"; + callPath = p + /call.nix; + in + assert lib.assertMsg (builtins.pathExists fullPath) + "File attempting to be callPackage'd '${fullPath}' does not exist"; + + if builtins.pathExists callPath then + let + x = _callPackage callPath { }; + in + x.callPackage or _callPackage fullPath (x.args or defaultArgs // args) + + else + _callPackage fullPath args; + in + + if builtins.pathExists (p + /wrapper.nix) then + # My distaste for rec grows ever stronger + let + set."${n}-unwrapped" = callPackage "package" { }; + in + { ${n} = callPackage "wrapper" set; } // set + else + { ${n} = callPackage "package" { }; } + + )) + lib.mergeAttrsList +]