From cd32ad1c61f15289f2ff69ffb8a5eb1186283f6d Mon Sep 17 00:00:00 2001 From: Jo Date: Fri, 25 Apr 2025 16:49:34 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20Work=20on=20fixing=20booting=20i?= =?UTF-8?q?ssues=20and=20various=20other=20things?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 6 ++++ flake.lock | 24 ++++++------- homes/nixos/jo/default.nix | 3 -- homes/x86_64-linux/jo/default.nix | 11 ++++++ modules/flake/modules.nix | 8 ++--- modules/home/desktop/gnome/default.nix | 12 +++---- modules/nixos/common/grub/default.nix | 34 ++++++++++++++++++ modules/nixos/users/default.nix | 35 ++++++++----------- systems/x86_64-nixos/puzzlevision/default.nix | 14 ++++---- 9 files changed, 95 insertions(+), 52 deletions(-) delete mode 100644 homes/nixos/jo/default.nix create mode 100644 homes/x86_64-linux/jo/default.nix create mode 100644 modules/nixos/common/grub/default.nix diff --git a/.gitignore b/.gitignore index 55a9045..48b3472 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,9 @@ ### Jetbrains /.idea + +### Zed Editor +/.zed + +### VSCode +/.vscode diff --git a/flake.lock b/flake.lock index aa9aa81..b25f4a9 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "easy-hosts": { "locked": { - "lastModified": 1739315072, - "narHash": "sha256-m0Lzdrj95GbdmKhqlTKkr4vvHy2Ghdi1GxISOKqUeSA=", + "lastModified": 1743693165, + "narHash": "sha256-BAYno/4P0hq3aaqfVLbDmv8pgvzJWcN+4L8jK8SzaMo=", "owner": "tgirlcloud", "repo": "easy-hosts", - "rev": "e96af44cae1f48a1a94f2471faee92caf22aa45f", + "rev": "611cc21942feb55c6a38410dfe8eee3fb5f08c8d", "type": "github" }, "original": { @@ -22,11 +22,11 @@ ] }, "locked": { - "lastModified": 1741352980, - "narHash": "sha256-+u2UunDA4Cl5Fci3m7S643HzKmIDAe+fiXrLqYsR2fs=", + "lastModified": 1743550720, + "narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "f4330d22f1c5d2ba72d3d22df5597d123fdb60a9", + "rev": "c621e8422220273271f52058f618c94e405bb0f5", "type": "github" }, "original": { @@ -42,11 +42,11 @@ ] }, "locked": { - "lastModified": 1742305478, - "narHash": "sha256-iYCinzZnnUeCkZ031qGRwPdwRsqW6o9Y0MgGpA7Zva4=", + "lastModified": 1745494811, + "narHash": "sha256-YZCh2o9Ua1n9uCvrvi5pRxtuVNml8X2a03qIFfRKpFs=", "owner": "nix-community", "repo": "home-manager", - "rev": "fb74bb76d94a6c55632376c931fc108131260ee9", + "rev": "abfad3d2958c9e6300a883bd443512c55dfeb1be", "type": "github" }, "original": { @@ -57,11 +57,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1742069588, - "narHash": "sha256-C7jVfohcGzdZRF6DO+ybyG/sqpo1h6bZi9T56sxLy+k=", + "lastModified": 1745391562, + "narHash": "sha256-sPwcCYuiEopaafePqlG826tBhctuJsLx/mhKKM5Fmjo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "c80f6a7e10b39afcc1894e02ef785b1ad0b0d7e5", + "rev": "8a2f738d9d1f1d986b5a4cd2fd2061a7127237d7", "type": "github" }, "original": { diff --git a/homes/nixos/jo/default.nix b/homes/nixos/jo/default.nix deleted file mode 100644 index 18cc357..0000000 --- a/homes/nixos/jo/default.nix +++ /dev/null @@ -1,3 +0,0 @@ -{ ... }: { - home.stateVersion = "25.05"; -} diff --git a/homes/x86_64-linux/jo/default.nix b/homes/x86_64-linux/jo/default.nix new file mode 100644 index 0000000..21cf78b --- /dev/null +++ b/homes/x86_64-linux/jo/default.nix @@ -0,0 +1,11 @@ +{ + pkgs, + ... +}: { + home.packages = with pkgs; [ + vscodium + cmatrix + ]; + + home.stateVersion = "25.05"; +} diff --git a/modules/flake/modules.nix b/modules/flake/modules.nix index 9c3c01b..9fa3d3e 100644 --- a/modules/flake/modules.nix +++ b/modules/flake/modules.nix @@ -1,10 +1,10 @@ { self, ... }: { flake = { - nixosModules.puzzlevision = self.lib.mkModule { - class = "nixos"; - modules = self.lib.dirToModuleList ../nixos; - }; + #nixosModules.puzzlevision = self.lib.mkModule { + # class = "nixos"; + # modules = self.lib.dirToModuleList ../nixos; + #}; homeModules.puzzlevision = self.lib.mkModule { class = "home"; diff --git a/modules/home/desktop/gnome/default.nix b/modules/home/desktop/gnome/default.nix index 5d29baf..daa75f5 100644 --- a/modules/home/desktop/gnome/default.nix +++ b/modules/home/desktop/gnome/default.nix @@ -21,13 +21,13 @@ in { }; config = mkIf osConfig.${namespace}.desktop.gnome.enable { - home.packages = cfg.enabled-extensions; + home.packages = cfg.enabled-extensions; - dconf.settings = { - "org/gnome/shell" = { - enabled-extensions = lib.forEach cfg.enabled-extensions (x: x.extensionUuid); - disabled-extensions = []; # Make sure none of our extensions are disabled on system rebuild - }; + dconf.settings = { + "org/gnome/shell" = { + enabled-extensions = lib.forEach cfg.enabled-extensions (x: x.extensionUuid); + disabled-extensions = []; # Make sure none of our extensions are disabled on system rebuild }; + }; }; } diff --git a/modules/nixos/common/grub/default.nix b/modules/nixos/common/grub/default.nix new file mode 100644 index 0000000..5ec7745 --- /dev/null +++ b/modules/nixos/common/grub/default.nix @@ -0,0 +1,34 @@ +{ + lib, + self, + config, + ... +}: +let + inherit (lib) mkEnableOption mkIf; + inherit (self) namespace; + + cfg = config.${namespace}.common.grub; +in { + options.${namespace}.common.grub = { enable = mkEnableOption "grub"; }; + + config = mkIf cfg.enable { + boot.loader.systemd-boot.enable = false; + + boot.loader.grub = { + enable = true; + devices = [ "nodev" ]; + efiInstallAsRemovable = true; + efiSupport = true; + + extraEntries = '' + menuentry "Reboot" { + reboot + } + menuentry "Poweroff" { + halt + } + ''; + }; + }; +} diff --git a/modules/nixos/users/default.nix b/modules/nixos/users/default.nix index 71988ce..ef2d6dc 100644 --- a/modules/nixos/users/default.nix +++ b/modules/nixos/users/default.nix @@ -2,6 +2,7 @@ lib, config, self, + pkgs, ... }: let inherit (lib) mkEnableOption mkIf mkOption types; @@ -10,17 +11,15 @@ cfg = config.${namespace}.users; - system = builtins.currentSystem; - systemClass = - if builtins.match ".*-linux" system != null then "nixos" - else if builtins.match ".*-darwin" system != null then "darwin" - else "nixos"; # Default fallback + # The identifier of the current system type, e.g. "x86_64-linux" or "aarch64-darwin" + system = pkgs.system; # Type for a user configuration userType = types.submodule { options = { - enable = mkEnableOption "Enable this user"; + enable = mkEnableOption "this user"; initialPassword = mkOpt (types.nullOr types.str) null "Initial password for the user"; + password = mkOpt (types.nullOr types.str) null "Plaintext password for the user"; hashedPassword = mkOpt (types.nullOr types.str) null "Hashed password for the user"; isNormalUser = mkOpt types.bool true "Whether this user is a normal user"; extraGroups = mkOpt (types.listOf types.str) [] "Extra groups for the user"; @@ -28,7 +27,7 @@ }; # Function to get home configuration path for a username - getHomeConfigPath = username: "${self.outPath}/homes/${systemClass}/${username}"; + getHomeConfigPath = username: "${self.outPath}/homes/${system}/${username}"; # Function to check if a home configuration exists for a username homeConfigExists = username: @@ -38,12 +37,6 @@ # Import all home-manager modules homeModules = dirToModuleList "${self.outPath}/modules/home"; in { - imports = [ - # Import home-manager NixOS module - # This assumes home-manager is available as a flake input - self.inputs.home-manager.nixosModules.home-manager - ]; - options.${namespace}.users = mkOption { type = types.attrsOf userType; default = {}; @@ -51,18 +44,18 @@ in { }; config = { - # Create the actual users + # Ensure users are fully managed by NixOS + users.mutableUsers = false; + + # Create the actual system users users.users = lib.mapAttrs (username: userConfig: mkIf userConfig.enable { name = username; - isNormalUser = userConfig.isNormalUser; - inherit (userConfig) extraGroups; - initialPassword = userConfig.initialPassword; - hashedPassword = userConfig.hashedPassword; + inherit (userConfig) extraGroups initialPassword hashedPassword isNormalUser password; } ) cfg; - # Configure home-manager with auto-imported configs + # Configure home-manager with auto-imported user configuration home-manager = { useGlobalPkgs = true; useUserPackages = true; @@ -77,7 +70,9 @@ in { { ... }: { imports = [ (getHomeConfigPath username) # Import the user's specific home configuration - ] ++ homeModules; # Include all home modules from /modules/home + ]; #++ homeModules; # Include all generalized home modules + + home.stateVersion = lib.mkDefault config.system.stateVersion; } ) ) cfg; diff --git a/systems/x86_64-nixos/puzzlevision/default.nix b/systems/x86_64-nixos/puzzlevision/default.nix index 79ef0c0..af76b22 100644 --- a/systems/x86_64-nixos/puzzlevision/default.nix +++ b/systems/x86_64-nixos/puzzlevision/default.nix @@ -1,29 +1,29 @@ -{pkgs, ...}: { +{ + pkgs, + ... +}: { imports = [ ./hardware.nix ]; - users.users.jo.isNormalUser = true; - users.users.jo.initialPassword = "balls"; - users.users.jo.createHome = true; - - # System configuration puzzlevision = { # TODO: improve home-manager configuration loading as development continues and make sure everything works correctly. users = { jo = { enable = true; initialPassword = "balls"; + extraGroups = [ "wheel" ]; }; }; desktop.gnome.enable = true; + utils.vm.enable = true; + common.grub.enable = true; }; environment.systemPackages = with pkgs; [ ghostty firefox - vscodium ]; system.stateVersion = "25.05";