diff --git a/flake.nix b/flake.nix index e6fbc84..d213e67 100755 --- a/flake.nix +++ b/flake.nix @@ -2,6 +2,18 @@ description = "SerenityOS"; + # my 1 trillionth rewrite of my flake, hopefully more robust and easier to modify in future now + # rewriting using the 'dendritic' pattern using flake-parts and such, based on examples provided by: + # + # vimjoyer + # https://www.vimjoyer.com/nix/dendritic-home-manager + # + # v3rm1n + # https://codeberg.org/v3rm1n/dotfiles + # + # quantenzitrone + # https://codeberg.org/quantenzitrone/nixos-config + inputs = { # nix hardware - https://github.com/NixOS/nixos-hardware @@ -14,10 +26,7 @@ url = "github:nixos/nixpkgs/nixos-unstable"; }; - # dendritic stuff - https://www.vimjoyer.com/vid79-parts-wrapped - den = { - url = "github:vic/den/v0.17.0"; - }; + # dendritic stuff - https://github.com/mightyiam/dendritic flake-parts = { url = "github:hercules-ci/flake-parts"; }; @@ -27,9 +36,6 @@ import-tree = { url = "github:vic/import-tree"; }; - wrapper-modules = { - url = "github:BirdeeHub/nix-wrapper-modules"; - }; # sound driver optimisations - https://github.com/musnix/musnix musnix = { @@ -41,9 +47,6 @@ url = "github:fufexan/nix-gaming"; }; - # secrets management - https://github.com/Mic92/sops-nix - #sops-nix = { url = "github:Mic92/sops-nix"; }; - # declarative dots - https://github.com/nix-community/home-manager home-manager = { url = "github:nix-community/home-manager"; diff --git a/modules/features/desktop/default.nix b/modules/features/desktop/default.nix index a4f27e1..6f63210 100644 --- a/modules/features/desktop/default.nix +++ b/modules/features/desktop/default.nix @@ -1,18 +1,17 @@ -{ self, inputs, ... }: { +{ self, ... }: { - flake.nixosModules.desktop = { pkgs, ... }: { + flake.nixosModules.desktop = { + + # modules to include + imports = with self.nixosModules; [ + #greeter + niri + noctalia + #stylix + ]; #programs.foo = bar; }; - flake.homeModules.desktop = { self, inputs, ... }: { - - imports = with self.homeModules; [ - niri - terminal - ]; - - }; - } diff --git a/modules/features/desktop/niri.nix b/modules/features/desktop/niri.nix index 27ab3ae..9a7990a 100644 --- a/modules/features/desktop/niri.nix +++ b/modules/features/desktop/niri.nix @@ -1,50 +1,54 @@ { self, inputs, ... }: { # module declaration - flake.nixosModules.niri = { pkgs, ... }: { + flake.nixosModules.niri = { config, lib, pkgs, ... }: + + let + + username = config.userOptions.username; + + in - programs.niri = { + { + + imports = [ + + # for home manager functionality + inputs.home-manager.nixosModules.home-manager - # enables niri - enable = true; + # for noctalia shell atop niri + self.nixosModules.noctalia + + ]; + environment = { + + # packages for desktop environment + systemPackages = with pkgs; [ + foo + bar + ]; + }; - }; + # session management + programs.uwsm = { + enable = true; + }; - # defines a niri hm config - flake.homeModules.niri = - { - config, - pkgs, - lib, - ... - }: + # enables niri globally + programs.niri = { + enable = true; + }; - { - - imports = with self.homeModules; [ - # launcher - wofi - # desktop shell - noctalia - - ]; - - programs = { - - niri = { - - # enables niri - enable = true; - - # niri settings + # niri settings + home-manager.users.${username} = { + programs.niri = { + settings = { }; - }; - }; }; diff --git a/modules/features/desktop/noctalia.nix b/modules/features/desktop/noctalia.nix index 6c73c3e..c2a2716 100644 --- a/modules/features/desktop/noctalia.nix +++ b/modules/features/desktop/noctalia.nix @@ -1,19 +1,45 @@ -{ self, inputs, ... }: { +{ inputs, ... }: { - perSystem = { pkgs, ... }: { + flake.nixosModules.noctalia = + { config, lib, ... }: - # defines a custom noctalia package - packages.myNoctalia = inputs.wrapper-modules.wrappers.noctalia-shell.wrap { + let + username = config.userOptions.username; + hostName = config.userOptions.hostName; + wallpaper = config.userOptions.wallpaper; + in - # use global packages - inherit pkgs; + { - # use a separate json file to configure - # nixify this. - settings = (builtins.fromJSON (builtins.readFile ./noctalia.json)).settings; + # for home manager functionality + imports = [ inputs.home-manager.nixosModules.home-manager ]; + home-manager.users.${username} = { + imports = [ inputs.noctalia.homeModules.default ]; + programs.noctalia-shell = { + + # enables noctalia + enable = true; + systemd.enable = true; + + # noctalia settings + settings = { + + general = { }; + + location = { }; + + colorSchemes.predefinedscheme = "foobar"; + + dock = { + enabled = false; + }; + + bar = { }; + + }; + }; + }; }; - }; - } diff --git a/modules/hosts/hades/default.nix b/modules/hosts/hades/default.nix index 0d5dee7..10354b2 100644 --- a/modules/hosts/hades/default.nix +++ b/modules/hosts/hades/default.nix @@ -1,69 +1,25 @@ -{ - self, - inputs, - config, - ... -}: - -let - - # default username here - username = "serenity"; - -in +{ self, inputs, ... }: { - # defines the hades specific configuration (glue code?) + # defines the hades specific configuration flake.nixosConfigurations.hades = inputs.nixpkgs.lib.nixosSystem { # modules that comprise the host specific configuration modules = with self.nixosModules; [ - # actual desktop module set defined below - hades + # host-specific hardware options + hadesHardware + + # users to include on host + serenity + + # extra modules to include on host + desktop + terminal ]; }; - # module set that comprises the hades configuration - flake.nixosModules.hades = - { - pkgs, - inputs, - config, - ... - }: - - { - - imports = with self.nixosModules; [ - - # core system modules - core - - # hades system modules - hades-hardware - - # extra modules - gaming - - # users to include on host - serenity - - # home manager and home manager imports - inputs.home-manager.nixosModules.home-manager - { - home-manager.users.serenity = { - imports = with self.homeModules; [ - desktop - ]; - }; - } - - ]; - - }; - } diff --git a/modules/system/core-home.nix b/modules/system/core-home.nix deleted file mode 100644 index d39c679..0000000 --- a/modules/system/core-home.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ self, inputs, ... }: { - - flake.homeModules.core-home = { config, pkgs, ... }: { - - #modules = [ - #self.modules.terminal - #self.modules.theme - #]; - - imports = [ - #./terminal - self.modules.terminal - self.modules.desktop - #self.modules.theme - ]; - - home = { - username = "serenity"; - homeDirectory = "/home/serenity"; - stateVersion = "26.05"; - #extraOutputsToInstall = [ ]; - }; - - # disable manuals as nmd fails to build often - manual = { - html.enable = false; - json.enable = false; - manpages.enable = false; - }; - - # let HM manage itself when in standalone mode - programs.home-manager.enable = true; - }; -} diff --git a/modules/system/core.nix b/modules/system/core.nix index 82f2fb0..2dea0a5 100644 --- a/modules/system/core.nix +++ b/modules/system/core.nix @@ -1,20 +1,41 @@ -{ self, lib, ... }: +{ self, inputs, ... }: { - flake.nixosModules.core = { pkgs, ... }: { + flake.nixosModules.core = { config, pkgs, ... }: + + let + + # flakepath for QoL + flakePath = config.userOptions.flakePath + + # username + username = config.userOptions.username + + in + + { # other modules to load - imports = with self.nixosModules; [ - core-packages + imports = [ + + # core packages to load + self.nixosModules.core-packages + + # home manager functionality + inputs.home-manager.nixosModules.home-manager + ]; # extra features nix.settings.experimental-features = [ + # flake based config requires flakes "flakes" + #fancier nix usage "nix-command" + ]; # compresses half the ram for use as swap @@ -32,6 +53,19 @@ # meanjin time time.timeZone = lib.mkDefault "Austrlia/Brisbane"; + # home manager settings + home-manager = { + verbose = true; + overwriteBackup = true; + backupFileExtension = ".bak"; + useGlobalPkgs = true; + useUserPackages = true; + users.${username} = { + home.stateversion = "24.11"; + nixpkgs.config.allowUnfree = true; + }; + }; + # don't touch this system.stateVersion = lib.mkDefault "24.11"; documentation.dev.enable = true; diff --git a/modules/system/flake-parts.nix b/modules/system/flake-parts.nix index fdaac6f..a19cf3c 100644 --- a/modules/system/flake-parts.nix +++ b/modules/system/flake-parts.nix @@ -1,4 +1,11 @@ -{ +{ inputs, ... }: { + + imports = [ + + # necessary for home manager functionality + inputs.home-manager.flakeModules.home-manager + + ]; # misc flake-parts configuration config = { diff --git a/modules/users/options.nix b/modules/users/options.nix new file mode 100644 index 0000000..ea830f7 --- /dev/null +++ b/modules/users/options.nix @@ -0,0 +1,78 @@ +# User Options Module +# +# This module defines the core user-level configuration options that are used +# throughout the system. These options provide a centralized way to configure +# user-specific settings without modifying individual modules. +# +# Usage: +# Set these options in your host configuration (e.g., hosts/Desktop/modules/userOptions.nix): +# +# config.userOptions = { +# username = "myuser"; +# hostName = "myhost"; +# colorScheme = "kanagawa"; +# wallpaper = "kanagawa.png"; +# dots = "/home/myuser/.dotfiles"; +# }; +# +# These options are then accessible throughout all modules via `config.userOptions.*` +{ ... }: +{ + + flake.nixosModules.modulesUser = + { lib, ... }: + + { + options.userOptions = { + + colorScheme = lib.mkOption { + type = lib.types.str; + description = '' + The base16 color scheme name for Stylix theming. + This will be used to theme all compatible applications system-wide. + + Available schemes: https://github.com/tinted-theming/schemes + Popular options: "kanagawa", "catppuccin-macchiato", "tokyo-night", "gruvbox-dark-medium", "nord" + ''; + example = "kanagawa"; + }; + + dots = lib.mkOption { + type = lib.types.str; + description = '' + The absolute path to the dotfiles repository (flake root). + Used by various modules to reference assets and configuration files. + ''; + example = "/home/user/.dotfiles"; + }; + + hostName = lib.mkOption { + type = lib.types.str; + description = '' + The hostname for this system. + This will be set as the system hostname and can be used for host-specific configuration. + ''; + example = "Desktop"; + }; + + username = lib.mkOption { + type = lib.types.str; + description = '' + The primary user's username for this system. + This is used throughout the configuration for Home Manager and user-specific settings. + ''; + example = "myuser"; + }; + + wallpaper = lib.mkOption { + type = lib.types.str; + description = '' + The wallpaper filename (without path). + The file should be located in the assets/ directory of this repository. + Stylix will use this wallpaper and can optionally generate colors from it. + ''; + example = "kanagawa.png"; + }; + }; + }; +} diff --git a/modules/users/serenity.nix b/modules/users/serenity.nix index 50bcae7..0a9c205 100644 --- a/modules/users/serenity.nix +++ b/modules/users/serenity.nix @@ -1,60 +1,25 @@ -{ self, inputs, ... }: - -# let bindings -let - - # set your username here - username = "serenity"; - - # qol variable to make paths shorter - home = "/home/${username}"; - -in +{ inputs, ... }: { # user module declaration flake.nixosModules.serenity = - { pkgs, ... }: + { config, pkgs, ... }: + + let + + username = config.userOptions.username; + + in { - # modules to include - modules = [ - - # home-manager module - inputs.home-manager.nixosModules.home-manager - { - home-manager = { - - # home-manager settings - backupFileExtension = ".bak"; - overwriteBackup = true; - verbose = true; - - # set home-manager packages to follow system - useUserPackages = true; - useGlobalPkgs = true; - - # hm user declaration - users.serenity = { - - # user specific modules to import - imports = [ - self.flake.homeModules.core-home - #self.flake.homeModules.${name} - ]; - - }; - - }; - } - - ]; + # necessary for home manager function + imports = [ inputs.home-manager.nixosModules.home-manager ]; # user declaration - users.users.serenity = { + users.users.${username} = { # remember to change this initialPassword = "password";