diff --git a/README.md b/README.md index e3c0592..ca5afee 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,8 @@ This config uses two systems: Flakes, and Home-manager. - Flakes are the entrypoint, via `flake.nix`. This is where you include Flake modules and define Flake-specific options. - Home-manager configs live in the `users/` folders. Each user gets its own `home-manager.nix` file too. - Modules are stored in `modules`. All of these files are imported, and you enable the ones you want to use. For example, to install Flatpak, set `host.ui.flatpak.enable = true;`. - - After adding a new module, make sure to `git add` it _and_ `import` it in `default.nix`. + - After adding a new module, make sure to `git add` it. + - Modules are automatically imported - see `autoimport.nix`. ### Adding a host diff --git a/flake.lock b/flake.lock index d3b7414..b6e7a78 100644 --- a/flake.lock +++ b/flake.lock @@ -235,40 +235,6 @@ "type": "github" } }, - "nixpkgs_3": { - "locked": { - "lastModified": 1714404219, - "narHash": "sha256-1YdyaIv7WM3snp3E5Ib4Fsr4Z6/IbR5aKqVo3VXkfEA=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "aa30bcc07ba66e96bb6467e4a42f7845f11b6942", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "master", - "repo": "nixpkgs", - "type": "github" - } - }, - "nypkgs": { - "inputs": { - "nixpkgs": "nixpkgs_3" - }, - "locked": { - "lastModified": 1714404288, - "narHash": "sha256-CTGtSlkTtETcDbt61jtXqIIy89Fzf/+8aEClPO/bcAg=", - "owner": "yunfachi", - "repo": "nypkgs", - "rev": "27648b0d368a565ff415fcd240056b41a97c0e7b", - "type": "github" - }, - "original": { - "owner": "yunfachi", - "repo": "nypkgs", - "type": "github" - } - }, "pre-commit-hooks-nix": { "inputs": { "flake-compat": [ @@ -306,8 +272,7 @@ "lanzaboote": "lanzaboote", "nix-flatpak": "nix-flatpak", "nixos-hardware": "nixos-hardware", - "nixpkgs": "nixpkgs_2", - "nypkgs": "nypkgs" + "nixpkgs": "nixpkgs_2" } }, "rust-overlay": { diff --git a/flake.nix b/flake.nix index 5f26ed8..37c3db4 100644 --- a/flake.nix +++ b/flake.nix @@ -16,9 +16,6 @@ # Hardware configurations nixos-hardware.url = "github:NixOS/nixos-hardware"; - # Auto-import modules - nypkgs.url = "github:yunfachi/nypkgs"; - # Home-manager home-manager = { url = "github:nix-community/home-manager/master"; @@ -28,7 +25,7 @@ # TODO: Add Disko - https://github.com/nix-community/disko }; - outputs = inputs@{ self, nixpkgs, lanzaboote, nix-flatpak, home-manager, nixos-hardware, nypkgs,... }: + outputs = inputs@{ self, nixpkgs, lanzaboote, nix-flatpak, home-manager, nixos-hardware, ... }: let forAllSystems = function: nixpkgs.lib.genAttrs [ @@ -56,10 +53,6 @@ backupFileExtension = "home-manager-backup"; }; } - nypkgs.ylib.umport { - paths = [ ../modules ]; - recursive = true; - } ]; }; in { diff --git a/hosts/default.nix b/hosts/default.nix index d658dce..acfc3d0 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -10,6 +10,6 @@ let in{ imports = [ "${nix-secrets}/default.nix" - ../modules + ../modules/autoimport.nix ]; } diff --git a/modules/apps/default.nix b/modules/apps/default.nix deleted file mode 100644 index d556592..0000000 --- a/modules/apps/default.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ ... }: { - imports = [ - ./development.nix - ./dj.nix - ./gaming.nix - ./kdeconnect.nix - ./media.nix - ./office.nix - ./recording.nix - ./social.nix - ./writing.nix - ]; -} diff --git a/modules/apps/development.nix b/modules/apps/development.nix index 148d492..9dcacfb 100644 --- a/modules/apps/development.nix +++ b/modules/apps/development.nix @@ -20,13 +20,16 @@ with lib; "com.vscodium.codium" "dev.k8slens.OpenLens" ]; + + environment.systemPackages = with pkgs; [ + statix # Nix linting tool + ]; }) (mkIf cfg.kubernetes.enable { environment.systemPackages = with pkgs; [ kubectl kubernetes-helm kubevirt # Virtctl command-line tool - statix # Nix linting tool ]; }) ]; diff --git a/modules/autoimport.nix b/modules/autoimport.nix new file mode 100644 index 0000000..5e065fc --- /dev/null +++ b/modules/autoimport.nix @@ -0,0 +1,26 @@ +# Auto-import modules in this folder, recursively. +# Sourced from https://github.com/evanjs/nixos_cfg/blob/4bb5b0b84a221b25cf50853c12b9f66f0cad3ea4/config/new-modules/default.nix +{ lib, ... }: +with lib; +let + # Recursively constructs an attrset of a given folder, recursing on directories, value of attrs is the filetype + getDir = dir: mapAttrs + (file: type: + if type == "directory" then getDir "${dir}/${file}" else type + ) + (builtins.readDir dir); + + # Collects all files of a directory as a list of strings of paths + files = dir: collect isString (mapAttrsRecursive (path: type: concatStringsSep "/" path) (getDir dir)); + + # Filters out directories that belong to home-manager, and don't end with .nix or are this file. + # Also, make the strings absolute + validFiles = dir: map + (file: ./. + "/${file}") + (filter + (file: ! hasInfix "home-manager" file && file != "autoimport.nix" && hasSuffix ".nix" file) + (files dir)); +in +{ + imports = validFiles ./.; +} \ No newline at end of file diff --git a/modules/base/default.nix b/modules/base/default.nix deleted file mode 100644 index aa0e31c..0000000 --- a/modules/base/default.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ ... }: { - imports = [ - ./bluetooth.nix - ./bootloader.nix - ./network.nix - ./nix.nix - ./programs.nix - ./shell.nix - ./system.nix - ]; -} \ No newline at end of file diff --git a/modules/default.nix b/modules/default.nix deleted file mode 100644 index 543d511..0000000 --- a/modules/default.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ ... }: { - imports = [ - ./apps - ./base - ./roles - ./services - ./ui - ./users - ]; -} \ No newline at end of file diff --git a/modules/roles/default.nix b/modules/roles/default.nix index 39006e2..c945f9d 100644 --- a/modules/roles/default.nix +++ b/modules/roles/default.nix @@ -2,11 +2,6 @@ with lib; { - imports = [ - ./server.nix - ./workstation.nix - ]; - options = { host.role = mkOption { type = types.enum [ diff --git a/modules/services/default.nix b/modules/services/default.nix deleted file mode 100644 index aad0471..0000000 --- a/modules/services/default.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ ... }: { - imports = [ - ./apcupsd.nix - ./btrfs.nix - ./duplicacy-web.nix - ./k3s.nix - ./msmtp.nix - ./smartd.nix - ./systemd.nix - ]; -} \ No newline at end of file diff --git a/modules/ui/default.nix b/modules/ui/default.nix deleted file mode 100644 index 7f28c3d..0000000 --- a/modules/ui/default.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ ... }: - -{ - imports = [ - ./audio.nix - ./flatpak.nix - ./gnome.nix - ]; -} \ No newline at end of file diff --git a/modules/users/aires/default.nix b/modules/users/aires/default.nix index 2701169..2c50b8e 100644 --- a/modules/users/aires/default.nix +++ b/modules/users/aires/default.nix @@ -44,8 +44,8 @@ with lib; # Configure home-manager home-manager.users.aires = { imports = [ - ../common/gnome.nix - ../common/zsh.nix + ../common/home-manager/gnome.nix + ../common/home-manager/zsh.nix ]; home = { diff --git a/modules/users/common/gnome.nix b/modules/users/common/home-manager/gnome.nix similarity index 100% rename from modules/users/common/gnome.nix rename to modules/users/common/home-manager/gnome.nix diff --git a/modules/users/common/zsh.nix b/modules/users/common/home-manager/zsh.nix similarity index 100% rename from modules/users/common/zsh.nix rename to modules/users/common/home-manager/zsh.nix diff --git a/modules/users/default.nix b/modules/users/default.nix deleted file mode 100644 index f11382f..0000000 --- a/modules/users/default.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ ... }: { - imports = [ - ./aires - ./gremlin - ./media - ]; -} \ No newline at end of file diff --git a/modules/users/gremlin/default.nix b/modules/users/gremlin/default.nix index 619af70..d576c87 100644 --- a/modules/users/gremlin/default.nix +++ b/modules/users/gremlin/default.nix @@ -43,8 +43,8 @@ with lib; home-manager.users.gremlin = { imports = [ - ../common/gnome.nix - ../common/zsh.nix + ../common/home-manager/gnome.nix + ../common/home-manager/zsh.nix ]; home = {