diff --git a/devShells/_default.nix b/devShells/_default.nix deleted file mode 100644 index ad4c030..0000000 --- a/devShells/_default.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ 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 deleted file mode 100644 index 0a5a283..0000000 --- a/devShells/default.nix +++ /dev/null @@ -1 +0,0 @@ -{ mkShellNoCC, sops }: mkShellNoCC { packages = [ sops ]; } diff --git a/diskoConfigurations/gerg-desktop.nix b/disko/gerg-desktop.nix similarity index 100% rename from diskoConfigurations/gerg-desktop.nix rename to disko/gerg-desktop.nix diff --git a/diskoConfigurations/media-laptop.nix b/disko/media-laptop.nix similarity index 100% rename from diskoConfigurations/media-laptop.nix rename to disko/media-laptop.nix diff --git a/diskoConfigurations/proxy.nix b/disko/proxy.nix similarity index 100% rename from diskoConfigurations/proxy.nix rename to disko/proxy.nix diff --git a/diskoConfigurations/_default.nix b/diskoConfigurations/_default.nix deleted file mode 100644 index 6d21a6b..0000000 --- a/diskoConfigurations/_default.nix +++ /dev/null @@ -1,18 +0,0 @@ -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/flake.lock b/flake.lock index 552acbe..d956fd0 100644 --- a/flake.lock +++ b/flake.lock @@ -104,38 +104,6 @@ } }, "flake-compat_4": { - "flake": false, - "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-compat_5": { - "flake": false, - "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-compat_6": { "flake": false, "locked": { "lastModified": 1733328505, @@ -193,79 +161,6 @@ "type": "github" } }, - "flake-parts_3": { - "inputs": { - "nixpkgs-lib": [ - "nvim-flake", - "neovim-nightly", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1730504689, - "narHash": "sha256-hgmguH29K2fvs9szpq2r3pz2/8cJd2LPS+b4tfNFCwE=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "506278e768c2a08bec68eb62932193e341f55c90", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, - "flake-parts_4": { - "inputs": { - "nixpkgs-lib": [ - "nvim-flake", - "neovim-nightly", - "hercules-ci-effects", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1712014858, - "narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "9126214d0a59633752a136528f5f3b9aa8565b7d", - "type": "github" - }, - "original": { - "id": "flake-parts", - "type": "indirect" - } - }, - "git-hooks": { - "inputs": { - "flake-compat": "flake-compat_5", - "gitignore": "gitignore_2", - "nixpkgs": [ - "nvim-flake", - "neovim-nightly", - "nixpkgs" - ], - "nixpkgs-stable": [ - "nvim-flake", - "neovim-nightly", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1731363552, - "narHash": "sha256-vFta1uHnD29VUY4HJOO/D6p6rxyObnf+InnSMT4jlMU=", - "owner": "cachix", - "repo": "git-hooks.nix", - "rev": "cd1af27aa85026ac759d5d3fccf650abe7e1bbf0", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "git-hooks.nix", - "type": "github" - } - }, "git-hooks-nix": { "inputs": { "flake-compat": [ @@ -319,52 +214,6 @@ "type": "github" } }, - "gitignore_2": { - "inputs": { - "nixpkgs": [ - "nvim-flake", - "neovim-nightly", - "git-hooks", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1709087332, - "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", - "owner": "hercules-ci", - "repo": "gitignore.nix", - "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "gitignore.nix", - "type": "github" - } - }, - "hercules-ci-effects": { - "inputs": { - "flake-parts": "flake-parts_4", - "nixpkgs": [ - "nvim-flake", - "neovim-nightly", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1730903510, - "narHash": "sha256-mnynlrPeiW0nUQ8KGZHb3WyxAxA3Ye/BH8gMjdoKP6E=", - "owner": "hercules-ci", - "repo": "hercules-ci-effects", - "rev": "b89ac4d66d618b915b1f0a408e2775fe3821d141", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "hercules-ci-effects", - "type": "github" - } - }, "lanzaboote": { "inputs": { "crane": "crane", @@ -392,11 +241,11 @@ }, "master": { "locked": { - "lastModified": 1737176745, - "narHash": "sha256-fnOivdJWuL99CPTTRx4lFRSXTro5f+G2wpKOpbiFjBY=", + "lastModified": 1737083351, + "narHash": "sha256-hCddtSuk6m6XROmdOC0te0j2sLeUr28QIzNRk0qF1as=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6e0876c53ae460ac162a8931a537f951cbc0a0d5", + "rev": "0993fc268872148cebcd1fac8660a8b8ced49542", "type": "github" }, "original": { @@ -422,42 +271,18 @@ } }, "neovim-nightly": { - "inputs": { - "flake-compat": "flake-compat_4", - "flake-parts": "flake-parts_3", - "git-hooks": "git-hooks", - "hercules-ci-effects": "hercules-ci-effects", - "neovim-src": "neovim-src", - "nixpkgs": "nixpkgs_2" - }, - "locked": { - "lastModified": 1731500640, - "narHash": "sha256-bxtcbR33ftcSA+7+E52i+cqWAdoCQNFpxR1180HRX48=", - "owner": "nix-community", - "repo": "neovim-nightly-overlay", - "rev": "1329ddcc318e77e4629eb629d39f7f7c9b2632f6", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "neovim-nightly-overlay", - "rev": "1329ddcc318e77e4629eb629d39f7f7c9b2632f6", - "type": "github" - } - }, - "neovim-src": { "flake": false, "locked": { - "lastModified": 1731454739, - "narHash": "sha256-ihuASDo2BVZpUpsW6Z8Ll/xvczRPgGT/EGrrNt7NnwU=", - "owner": "neovim", - "repo": "neovim", - "rev": "1128d75550fa0b481b8953a194bae890d733a166", + "lastModified": 1737011565, + "narHash": "sha256-XMC2JCQzykiV9CtFh6YmPeoiRk065oExTB55Q0sBvCk=", + "owner": "nix-community", + "repo": "neovim-nightly-overlay", + "rev": "83062e5db634ba7a6a937f72e59b2c2224475a65", "type": "github" }, "original": { - "owner": "neovim", - "repo": "neovim", + "owner": "nix-community", + "repo": "neovim-nightly-overlay", "type": "github" } }, @@ -641,22 +466,6 @@ "type": "github" } }, - "nixpkgs_2": { - "locked": { - "lastModified": 1731245184, - "narHash": "sha256-vmLS8+x+gHRv1yzj3n+GTAEObwmhxmkkukB2DwtJRdU=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "aebe249544837ce42588aa4b2e7972222ba12e8f", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "nvim-flake": { "inputs": { "flake-compat": "flake-compat_3", @@ -664,15 +473,14 @@ "neovim-nightly": "neovim-nightly", "nixpkgs": [ "unstable" - ], - "systems": "systems" + ] }, "locked": { - "lastModified": 1737175973, - "narHash": "sha256-QWohIcALchkFJmMnVGKr9x7pLieYv/LO+sgXm4BRW4E=", + "lastModified": 1737087635, + "narHash": "sha256-tOo1OerWaVGcqtNQCFGBiI0646YevrKR9JoK/YzYSLI=", "owner": "Gerg-L", "repo": "nvim-flake", - "rev": "f3397fe34ac9b99f97f9e4f905098308f48dae95", + "rev": "88bdc350255f56e04218a13261f5c53b7a78b2bc", "type": "github" }, "original": { @@ -762,7 +570,6 @@ "spicetify-nix": "spicetify-nix", "stable": "stable", "suckless": "suckless", - "systems": "systems_2", "unstable": "unstable" } }, @@ -812,11 +619,11 @@ ] }, "locked": { - "lastModified": 1737107480, - "narHash": "sha256-GXUE9+FgxoZU8v0p6ilBJ8NH7k8nKmZjp/7dmMrCv3o=", + "lastModified": 1736808430, + "narHash": "sha256-wlgdf/n7bJMLBheqt1jmPoxJFrUP6FByKQFXuM9YvIk=", "owner": "mic92", "repo": "sops-nix", - "rev": "4c4fb93f18b9072c6fa1986221f9a3d7bf1fe4b6", + "rev": "553c7cb22fed19fd60eb310423fdc93045c51ba8", "type": "github" }, "original": { @@ -827,17 +634,17 @@ }, "spicetify-nix": { "inputs": { - "flake-compat": "flake-compat_6", + "flake-compat": "flake-compat_4", "nixpkgs": [ "unstable" ] }, "locked": { - "lastModified": 1737173687, - "narHash": "sha256-+WxaXc30KhTuCa9U8Nv2mJApIBq85CfA5fbcVsvdfxo=", + "lastModified": 1737087380, + "narHash": "sha256-T3WB7rwWDT8cWrwLR7fRRZ1gkgbk3A3dzefEfuGdMxk=", "owner": "Gerg-L", "repo": "spicetify-nix", - "rev": "c68c2ac0814ab386d2cbd3b9178e729b4fc805f0", + "rev": "6510ffbf4e3f9116923632da1e63e9a959d8aa94", "type": "github" }, "original": { @@ -882,43 +689,13 @@ "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" - } - }, - "systems_2": { - "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": 1737062831, - "narHash": "sha256-Tbk1MZbtV2s5aG+iM99U8FqwxU/YNArMcWAv6clcsBc=", + "lastModified": 1736883708, + "narHash": "sha256-uQ+NQ0/xYU0N1CnXsa2zghgNaOPxWpMJXSUJJ9W7140=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5df43628fdf08d642be8ba5b3625a6c70731c19c", + "rev": "eb62e6aa39ea67e0b8018ba8ea077efe65807dc8", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index bcf8fe4..6ec18e9 100644 --- a/flake.nix +++ b/flake.nix @@ -94,41 +94,8 @@ repo = "reboot-bot"; inputs.nixpkgs.follows = "unstable"; }; - systems = { - type = "github"; - owner = "nix-systems"; - repo = "default"; - }; }; - 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) { }) - ]; + + outputs = x: import ./outputs.nix x; } diff --git a/formatter/_default.nix b/formatter/_default.nix deleted file mode 100644 index 632505b..0000000 --- a/formatter/_default.nix +++ /dev/null @@ -1 +0,0 @@ -{ inputs', ... }: inputs'.self.packages.lint diff --git a/nixosConfigurations/gerg-desktop/1_mon.conf b/hosts/gerg-desktop/1_mon.conf similarity index 100% rename from nixosConfigurations/gerg-desktop/1_mon.conf rename to hosts/gerg-desktop/1_mon.conf diff --git a/nixosConfigurations/gerg-desktop/2_mon.conf b/hosts/gerg-desktop/2_mon.conf similarity index 100% rename from nixosConfigurations/gerg-desktop/2_mon.conf rename to hosts/gerg-desktop/2_mon.conf diff --git a/nixosConfigurations/gerg-desktop/Windows.xml b/hosts/gerg-desktop/Windows.xml similarity index 100% rename from nixosConfigurations/gerg-desktop/Windows.xml rename to hosts/gerg-desktop/Windows.xml diff --git a/nixosConfigurations/gerg-desktop/_vfio.nix b/hosts/gerg-desktop/_vfio.nix similarity index 100% rename from nixosConfigurations/gerg-desktop/_vfio.nix rename to hosts/gerg-desktop/_vfio.nix diff --git a/nixosConfigurations/gerg-desktop/boot.nix b/hosts/gerg-desktop/boot.nix similarity index 100% rename from nixosConfigurations/gerg-desktop/boot.nix rename to hosts/gerg-desktop/boot.nix diff --git a/nixosConfigurations/gerg-desktop/git.nix b/hosts/gerg-desktop/git.nix similarity index 100% rename from nixosConfigurations/gerg-desktop/git.nix rename to hosts/gerg-desktop/git.nix diff --git a/nixosConfigurations/gerg-desktop/kernelConfig b/hosts/gerg-desktop/kernelConfig similarity index 99% rename from nixosConfigurations/gerg-desktop/kernelConfig rename to hosts/gerg-desktop/kernelConfig index 993b971..6de70b8 100644 --- a/nixosConfigurations/gerg-desktop/kernelConfig +++ b/hosts/gerg-desktop/kernelConfig @@ -5326,7 +5326,7 @@ CONFIG_AUTOFS_FS=m CONFIG_FUSE_FS=m # CONFIG_CUSE is not set # CONFIG_VIRTIO_FS is not set -CONFIG_OVERLAY_FS=m +# CONFIG_OVERLAY_FS is not set # # Caches diff --git a/nixosConfigurations/gerg-desktop/main.nix b/hosts/gerg-desktop/main.nix similarity index 100% rename from nixosConfigurations/gerg-desktop/main.nix rename to hosts/gerg-desktop/main.nix diff --git a/nixosConfigurations/gerg-desktop/secrets.yaml b/hosts/gerg-desktop/secrets.yaml similarity index 100% rename from nixosConfigurations/gerg-desktop/secrets.yaml rename to hosts/gerg-desktop/secrets.yaml diff --git a/nixosConfigurations/gerg-desktop/services/ddns.nix b/hosts/gerg-desktop/services/ddns.nix similarity index 100% rename from nixosConfigurations/gerg-desktop/services/ddns.nix rename to hosts/gerg-desktop/services/ddns.nix diff --git a/nixosConfigurations/gerg-desktop/services/ddns_script.sh b/hosts/gerg-desktop/services/ddns_script.sh similarity index 100% rename from nixosConfigurations/gerg-desktop/services/ddns_script.sh rename to hosts/gerg-desktop/services/ddns_script.sh diff --git a/nixosConfigurations/gerg-desktop/services/forgejo.nix b/hosts/gerg-desktop/services/forgejo.nix similarity index 100% rename from nixosConfigurations/gerg-desktop/services/forgejo.nix rename to hosts/gerg-desktop/services/forgejo.nix diff --git a/nixosConfigurations/gerg-desktop/services/immich.nix b/hosts/gerg-desktop/services/immich.nix similarity index 100% rename from nixosConfigurations/gerg-desktop/services/immich.nix rename to hosts/gerg-desktop/services/immich.nix diff --git a/nixosConfigurations/gerg-desktop/services/minecraft.nix b/hosts/gerg-desktop/services/minecraft.nix similarity index 100% rename from nixosConfigurations/gerg-desktop/services/minecraft.nix rename to hosts/gerg-desktop/services/minecraft.nix diff --git a/nixosConfigurations/gerg-desktop/services/miniflux.nix b/hosts/gerg-desktop/services/miniflux.nix similarity index 100% rename from nixosConfigurations/gerg-desktop/services/miniflux.nix rename to hosts/gerg-desktop/services/miniflux.nix diff --git a/nixosConfigurations/gerg-desktop/services/nginx.nix b/hosts/gerg-desktop/services/nginx.nix similarity index 100% rename from nixosConfigurations/gerg-desktop/services/nginx.nix rename to hosts/gerg-desktop/services/nginx.nix diff --git a/nixosConfigurations/gerg-desktop/services/nix-serve.nix b/hosts/gerg-desktop/services/nix-serve.nix similarity index 100% rename from nixosConfigurations/gerg-desktop/services/nix-serve.nix rename to hosts/gerg-desktop/services/nix-serve.nix diff --git a/nixosConfigurations/gerg-desktop/services/parrot.nix b/hosts/gerg-desktop/services/parrot.nix similarity index 100% rename from nixosConfigurations/gerg-desktop/services/parrot.nix rename to hosts/gerg-desktop/services/parrot.nix diff --git a/nixosConfigurations/gerg-desktop/services/postgresql.nix b/hosts/gerg-desktop/services/postgresql.nix similarity index 100% rename from nixosConfigurations/gerg-desktop/services/postgresql.nix rename to hosts/gerg-desktop/services/postgresql.nix diff --git a/nixosConfigurations/gerg-desktop/services/reboot-bot.nix b/hosts/gerg-desktop/services/reboot-bot.nix similarity index 100% rename from nixosConfigurations/gerg-desktop/services/reboot-bot.nix rename to hosts/gerg-desktop/services/reboot-bot.nix diff --git a/nixosConfigurations/gerg-desktop/services/searxng.nix b/hosts/gerg-desktop/services/searxng.nix similarity index 100% rename from nixosConfigurations/gerg-desktop/services/searxng.nix rename to hosts/gerg-desktop/services/searxng.nix diff --git a/nixosConfigurations/gerg-desktop/shared.conf b/hosts/gerg-desktop/shared.conf similarity index 100% rename from nixosConfigurations/gerg-desktop/shared.conf rename to hosts/gerg-desktop/shared.conf diff --git a/nixosConfigurations/gerg-desktop/spicetify.nix b/hosts/gerg-desktop/spicetify.nix similarity index 100% rename from nixosConfigurations/gerg-desktop/spicetify.nix rename to hosts/gerg-desktop/spicetify.nix diff --git a/nixosConfigurations/gerg-desktop/zfs.nix b/hosts/gerg-desktop/zfs.nix similarity index 100% rename from nixosConfigurations/gerg-desktop/zfs.nix rename to hosts/gerg-desktop/zfs.nix diff --git a/nixosConfigurations/iso/main.nix b/hosts/iso/main.nix similarity index 100% rename from nixosConfigurations/iso/main.nix rename to hosts/iso/main.nix diff --git a/nixosConfigurations/media-laptop/main.nix b/hosts/media-laptop/main.nix similarity index 100% rename from nixosConfigurations/media-laptop/main.nix rename to hosts/media-laptop/main.nix diff --git a/nixosConfigurations/media-laptop/secrets.yaml b/hosts/media-laptop/secrets.yaml similarity index 100% rename from nixosConfigurations/media-laptop/secrets.yaml rename to hosts/media-laptop/secrets.yaml diff --git a/nixosConfigurations/proxy/main.nix b/hosts/proxy/main.nix similarity index 100% rename from nixosConfigurations/proxy/main.nix rename to hosts/proxy/main.nix diff --git a/nixosConfigurations/proxy/server.nix b/hosts/proxy/server.nix similarity index 100% rename from nixosConfigurations/proxy/server.nix rename to hosts/proxy/server.nix diff --git a/lib/_default.nix b/lib/_default.nix deleted file mode 100644 index f7d5e2a..0000000 --- a/lib/_default.nix +++ /dev/null @@ -1,139 +0,0 @@ -{ - 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 new file mode 100644 index 0000000..dd74269 --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,282 @@ +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/nixosModules/DE/dwm.nix b/modules/DE/dwm.nix similarity index 100% rename from nixosModules/DE/dwm.nix rename to modules/DE/dwm.nix diff --git a/nixosModules/DE/gnome.nix b/modules/DE/gnome.nix similarity index 100% rename from nixosModules/DE/gnome.nix rename to modules/DE/gnome.nix diff --git a/nixosModules/DE/xfce.nix b/modules/DE/xfce.nix similarity index 100% rename from nixosModules/DE/xfce.nix rename to modules/DE/xfce.nix diff --git a/nixosModules/DM/autoLogin.nix b/modules/DM/autoLogin.nix similarity index 100% rename from nixosModules/DM/autoLogin.nix rename to modules/DM/autoLogin.nix diff --git a/nixosModules/DM/lightDM.nix b/modules/DM/lightDM.nix similarity index 100% rename from nixosModules/DM/lightDM.nix rename to modules/DM/lightDM.nix diff --git a/nixosModules/X11.nix b/modules/X11.nix similarity index 100% rename from nixosModules/X11.nix rename to modules/X11.nix diff --git a/nixosModules/boot/other.nix b/modules/boot/other.nix similarity index 100% rename from nixosModules/boot/other.nix rename to modules/boot/other.nix diff --git a/nixosModules/boot/silent.nix b/modules/boot/silent.nix similarity index 100% rename from nixosModules/boot/silent.nix rename to modules/boot/silent.nix diff --git a/nixosModules/builders.nix b/modules/builders.nix similarity index 100% rename from nixosModules/builders.nix rename to modules/builders.nix diff --git a/nixosModules/hardware.nix b/modules/hardware.nix similarity index 100% rename from nixosModules/hardware.nix rename to modules/hardware.nix diff --git a/nixosModules/keys.nix b/modules/keys.nix similarity index 100% rename from nixosModules/keys.nix rename to modules/keys.nix diff --git a/nixosModules/misc.nix b/modules/misc.nix similarity index 100% rename from nixosModules/misc.nix rename to modules/misc.nix diff --git a/nixosModules/nix.nix b/modules/nix.nix similarity index 100% rename from nixosModules/nix.nix rename to modules/nix.nix diff --git a/nixosModules/packages.nix b/modules/packages.nix similarity index 100% rename from nixosModules/packages.nix rename to modules/packages.nix diff --git a/nixosModules/page.nix b/modules/page.nix similarity index 100% rename from nixosModules/page.nix rename to modules/page.nix diff --git a/nixosModules/security.nix b/modules/security.nix similarity index 100% rename from nixosModules/security.nix rename to modules/security.nix diff --git a/nixosModules/shell.nix b/modules/shell.nix similarity index 100% rename from nixosModules/shell.nix rename to modules/shell.nix diff --git a/nixosModules/sops.nix b/modules/sops.nix similarity index 74% rename from nixosModules/sops.nix rename to modules/sops.nix index 862cdd8..954bf5e 100644 --- a/nixosModules/sops.nix +++ b/modules/sops.nix @@ -9,7 +9,7 @@ options.local.sops.disable = lib.mkEnableOption ""; config = lib.mkIf (!config.local.sops.disable) { sops = { - defaultSopsFile = "${self'}/nixosConfigurations/${config.networking.hostName}/secrets.yaml"; + defaultSopsFile = "${self'}/hosts/${config.networking.hostName}/secrets.yaml"; age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; }; }; diff --git a/nixosModules/theming.nix b/modules/theming.nix similarity index 100% rename from nixosModules/theming.nix rename to modules/theming.nix diff --git a/nixosModules/zsh.nix b/modules/zsh.nix similarity index 100% rename from nixosModules/zsh.nix rename to modules/zsh.nix diff --git a/nixosConfigurations/_default.nix b/nixosConfigurations/_default.nix deleted file mode 100644 index 9d90595..0000000 --- a/nixosConfigurations/_default.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ - 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/nixosModules/_default.nix b/nixosModules/_default.nix deleted file mode 100644 index c9cf15b..0000000 --- a/nixosModules/_default.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ - 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/outputs.nix b/outputs.nix new file mode 100644 index 0000000..2c868d2 --- /dev/null +++ b/outputs.nix @@ -0,0 +1,18 @@ +inputs@{ self, unstable, ... }: +let + lib = import ./lib inputs; +in +lib.gerg-utils (s: unstable.legacyPackages.${s}) { + inherit lib; + nixosConfigurations = lib.mkHosts "${self}/hosts"; + + nixosModules = lib.mkModules "${self}/modules"; + + diskoConfigurations = lib.mkDisko "${self}/disko"; + + formatter = pkgs: inputs.self.packages.${pkgs.stdenv.system}.lint; + + devShells = pkgs: { default = pkgs.mkShellNoCC { packages = [ pkgs.sops ]; }; }; + + packages = lib.mkPackages "${self}/packages"; +} diff --git a/packages/_default.nix b/packages/_default.nix deleted file mode 100644 index 1783e53..0000000 --- a/packages/_default.nix +++ /dev/null @@ -1,70 +0,0 @@ -/* - / -> 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 -]