diff --git a/README.md b/README.md index ba91ecc..fd355d2 100644 --- a/README.md +++ b/README.md @@ -53,4 +53,9 @@ Parts of this flake were inspired by the likes of: - [isabelroses](https://github.com/isabelroses) - [uncenter](https://github.com/uncenter) -Many thanks to their hard work! +and documentations such as: + +- [flake-parts](https://flake.parts) +- [NixOS and Flakes book](https://nixos-and-flakes.thiscute.world) + +many thanks to their hard work! diff --git a/flake.nix b/flake.nix index 20f1294..c6fc6b7 100644 --- a/flake.nix +++ b/flake.nix @@ -3,29 +3,31 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + easy-hosts.url = "github:isabelroses/easy-hosts"; - # Flake parts, a library that provides utilites for creating flakes flake-parts = { url = "github:hercules-ci/flake-parts"; inputs.nixpkgs-lib.follows = "nixpkgs"; }; - # Provides an easy interface for loading systems from a directory - easy-hosts.url = "github:isabelroses/easy-hosts"; - - # home-manager = { - url = "github:nix-community/home-manager"; - inputs.nixpkgs.follows = "nixpkgs"; + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = inputs@{ flake-parts, ... }: flake-parts.lib.mkFlake { inherit inputs; } { + debug = true; + imports = [ - ./systems + ./modules/flake ]; systems = [ "x86_64-linux" ]; + flake = { + # Exposing the flake namespace + namespace = "puzzlevision"; + }; }; } diff --git a/homes/default.nix b/homes/default.nix deleted file mode 100644 index 0967ef4..0000000 --- a/homes/default.nix +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/homes/jo/default.nix b/homes/jo/default.nix deleted file mode 100644 index 0967ef4..0000000 --- a/homes/jo/default.nix +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/modules/flake/arguments.nix b/modules/flake/arguments.nix new file mode 100644 index 0000000..a7b2aa2 --- /dev/null +++ b/modules/flake/arguments.nix @@ -0,0 +1,20 @@ +{ + inputs, + config, + ... +}: +{ + # Overwrite and add new arguments to all flake modules. + _module.args = { + namespace = config.flake.namespace; + + # Initialize nixpkgs instance with custom overlays. + pkgs = import inputs.nixpkgs { + overlays = [ + (final: prev: { + # Todo: actually append overlays from "/overlays/overlay-name/default.nix" files. + }) + ]; + }; + }; +} diff --git a/modules/flake/default.nix b/modules/flake/default.nix new file mode 100644 index 0000000..afd8c27 --- /dev/null +++ b/modules/flake/default.nix @@ -0,0 +1,10 @@ +{ + imports = [ + # Automagically imports overlays from "/overlays/overlay-name" and applies them to pkgs. + # Also applies some other useful arguments, like namespace, to all flake modules. + ./arguments.nix + + # Automagically imports systems from "/systems/arch-classname/system-name". + ./systems.nix + ]; +} diff --git a/modules/flake/systems.nix b/modules/flake/systems.nix new file mode 100644 index 0000000..f9e76d6 --- /dev/null +++ b/modules/flake/systems.nix @@ -0,0 +1,30 @@ +{ + inputs, + namespace, + ... +}: +{ + imports = [ inputs.easy-hosts.flakeModule ]; + + easyHosts = { + autoConstruct = true; + path = ../../systems; + + shared = { + specialArgs = { + inherit namespace; + }; + }; + + perClass = class: { + modules = [ + # Import modules based on current classname. + ../${class} + + (inputs.nixpkgs.lib.optionals (class == "nixos") [ + inputs.home-manager.nixosModules.default + ]) + ]; + }; + }; +} diff --git a/modules/home/default.nix b/modules/home/default.nix deleted file mode 100644 index 0967ef4..0000000 --- a/modules/home/default.nix +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/systems/default.nix b/systems/default.nix deleted file mode 100644 index ca0838f..0000000 --- a/systems/default.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ - lib, - self, - inputs, - ... -}: -{ - imports = [ inputs.easy-hosts.flakeModule ]; - - easyHosts = { - autoConstruct = true; - path = ../systems; - - shared.modules = [ - ../homes - ]; - - perClass = - class: - { - modules = [ - "${self}/modules/${class}" - - (lib.optionals (class == "nixos") [ - inputs.home-manager.nixosModules.home-manager - ]) - ]; - }; - }; -} diff --git a/systems/x86_64-nixos/puzzlevision/default.nix b/systems/x86_64-nixos/puzzlevision/default.nix index e7653fb..d0874c5 100644 --- a/systems/x86_64-nixos/puzzlevision/default.nix +++ b/systems/x86_64-nixos/puzzlevision/default.nix @@ -7,18 +7,20 @@ ./hardware.nix ]; + # Todo: pass a set of users to enable from within easy-hosts and automatically map the corresponding home-manager configurations + # ${namespace} = { + # mainUser = "jo"; + # users = [ "jo" ]; + # }; + users.users.jo.isNormalUser = true; + users.users.jo.initialPassword = "balls"; + users.users.jo.createHome = true; + # Enable Plasma6 services.xserver.enable = true; services.displayManager.sddm.wayland.enable = true; services.desktopManager.plasma6.enable = true; - # Todo: pass a set of users to enable from within easy-hosts and automatically map the corresponding home-manager configurations - # Register "jo" as a user - users.users.jo.isNormalUser = true; - users.users.jo.extraGroups = [ "dialout" "docker" ]; - users.users.jo.initialPassword = "balls"; - users.users.jo.createHome = true; - environment.systemPackages = with pkgs; [ ghostty ];