diff --git a/configs/neovim.nix b/common/configs/neovim.nix similarity index 100% rename from configs/neovim.nix rename to common/configs/neovim.nix diff --git a/configs/tmux.nix b/common/configs/tmux.nix similarity index 100% rename from configs/tmux.nix rename to common/configs/tmux.nix diff --git a/configs/zsh.nix b/common/configs/zsh.nix similarity index 100% rename from configs/zsh.nix rename to common/configs/zsh.nix diff --git a/configuration.nix b/common/default.nix similarity index 100% rename from configuration.nix rename to common/default.nix diff --git a/scripts/impermanence.sh b/common/scripts/impermanence.sh similarity index 100% rename from scripts/impermanence.sh rename to common/scripts/impermanence.sh diff --git a/flake.nix b/flake.nix index c79d4f4..e35f5b4 100644 --- a/flake.nix +++ b/flake.nix @@ -21,13 +21,14 @@ }; }; - outputs = { self, nixpkgs, ... } @ inputs: - { + outputs = { self, nixpkgs, ... } @ inputs: { nixosConfigurations.eirene-vm = nixpkgs.lib.nixosSystem { specialArgs = { inherit inputs; }; system = "x86_64-linux"; modules = [ - ./hosts/eirene/vm/configuration.nix + ./common + ./hosts/eirene + ./hosts/eirene/vm inputs.disko.nixosModules.default inputs.impermanence.nixosModules.impermanence inputs.home-manager.nixosModules.default diff --git a/hosts/eirene/configuration.nix b/hosts/eirene/default.nix similarity index 69% rename from hosts/eirene/configuration.nix rename to hosts/eirene/default.nix index 69abd0d..7100fae 100644 --- a/hosts/eirene/configuration.nix +++ b/hosts/eirene/default.nix @@ -1,12 +1,8 @@ { inputs, ... }: -let - vars = import ../../users/nick/vars.nix; -in { imports = [ - ../../configuration.nix - ../../users/nick/home.nix + ../../user ./configs/pipewire.nix ]; @@ -23,5 +19,7 @@ in }; systemd.tmpfiles.rules = [ "d /persist/home/ 0755 root root -" ]; - services.getty.autologinUser = vars.user; + + user.vars = import ../../user/nick.nix; + user.autologin = true; } diff --git a/hosts/eirene/disko.nix b/hosts/eirene/disko.nix deleted file mode 100644 index 9ae88ca..0000000 --- a/hosts/eirene/disko.nix +++ /dev/null @@ -1,63 +0,0 @@ -{ - disko.devices = { - disk.main = { - type = "disk"; - content = { - type = "gpt"; - partitions = { - boot = { - name = "boot"; - size = "1M"; - type = "EF02"; - }; - esp = { - name = "esp"; - size = "512M"; - type = "EF00"; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; - }; - }; - swap = { - name = "swap"; - size = "32G"; - content = { - type = "swap"; - resumeDevice = true; - }; - }; - root = { - name = "root"; - size = "100%"; - content = { - name = "luks"; - type = "luks"; - settings = { - allowDiscards = true; - }; - content = { - type = "btrfs"; - extraArgs = ["-f"]; - subvolumes = { - "/root" = { - mountpoint = "/"; - }; - "/persist" = { - mountpoint = "/persist"; - mountOptions = ["subvol=persist" "compress=zstd" "noatime"]; - }; - "/nix" = { - mountpoint = "/nix"; - mountOptions = ["subvol=nix" "compress=zstd" "noatime"]; - }; - }; - }; - }; - }; - }; - }; - }; - }; -} diff --git a/hosts/eirene/format.nix b/hosts/eirene/format.nix new file mode 100644 index 0000000..6b3b130 --- /dev/null +++ b/hosts/eirene/format.nix @@ -0,0 +1,78 @@ +{ config, lib, ... }: + +let + cfg = config.format; +in +{ + options.format = { + device = lib.mkOption { + type = lib.types.str; + description = "The device to format"; + }; + }; + + config = { + disko.devices = { + disk.main = { + type = "disk"; + device = cfg.device; + content = { + type = "gpt"; + partitions = { + boot = { + name = "boot"; + size = "1M"; + type = "EF02"; + }; + esp = { + name = "esp"; + size = "512M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + }; + swap = { + name = "swap"; + size = "32G"; + content = { + type = "swap"; + resumeDevice = true; + }; + }; + root = { + name = "root"; + size = "100%"; + content = { + name = "luks"; + type = "luks"; + settings = { + allowDiscards = true; + }; + content = { + type = "btrfs"; + extraArgs = ["-f"]; + subvolumes = { + "/root" = { + mountpoint = "/"; + }; + "/persist" = { + mountpoint = "/persist"; + mountOptions = ["subvol=persist" "compress=zstd" "noatime"]; + }; + "/nix" = { + mountpoint = "/nix"; + mountOptions = ["subvol=nix" "compress=zstd" "noatime"]; + }; + }; + }; + }; + }; + }; + }; + }; + }; + }; +} diff --git a/hosts/eirene/vm/configuration.nix b/hosts/eirene/vm/configuration.nix deleted file mode 100644 index 48b9ac1..0000000 --- a/hosts/eirene/vm/configuration.nix +++ /dev/null @@ -1,22 +0,0 @@ -let - vars = import ../../../users/nick/vars.nix; -in -{ - imports = [ - ../configuration.nix - ../disko.nix - ./hardware-configuration.nix - ]; - - disko.devices.disk.main.device = "/dev/vda"; - - boot.kernelParams = [ "video=Virtual-1:2560x1600@60" ]; - home-manager.users."${vars.user}".wayland.windowManager.hyprland.settings.monitor = "Virtual-1, 2560x1600@60, 0x0, 1"; - - networking.hostName = "eirene-vm"; - - fileSystems."/host" = { - device = "host"; - fsType = "virtiofs"; - }; -} diff --git a/hosts/eirene/vm/default.nix b/hosts/eirene/vm/default.nix new file mode 100644 index 0000000..b619a38 --- /dev/null +++ b/hosts/eirene/vm/default.nix @@ -0,0 +1,15 @@ +{ + imports = [ + ../format.nix + ./hardware-configuration.nix + ]; + + format.device = "/dev/vda"; + networking.hostName = "eirene-vm"; + boot.kernelParams = [ "video=Virtual-1:2560x1600@60" ]; + + fileSystems."/host" = { + device = "host"; + fsType = "virtiofs"; + }; +} diff --git a/users/nick/configs/firefox.nix b/user/configs/firefox.nix similarity index 100% rename from users/nick/configs/firefox.nix rename to user/configs/firefox.nix diff --git a/user/configs/git.nix b/user/configs/git.nix new file mode 100644 index 0000000..2647a29 --- /dev/null +++ b/user/configs/git.nix @@ -0,0 +1,22 @@ +{ config, lib, ... }: + +let + cfg = config.git; +in +{ + options.git = { + vars = lib.mkOption { + type = lib.types.attrs; + description = "Variables for the user"; + }; + }; + + config = { + programs.git = { + enable = true; + lfs.enable = true; + userEmail = cfg.vars.email; + userName = cfg.vars.fullName; + }; + }; +} diff --git a/user/configs/hyprland.nix b/user/configs/hyprland.nix new file mode 100644 index 0000000..2482637 --- /dev/null +++ b/user/configs/hyprland.nix @@ -0,0 +1,81 @@ +{ config, lib, ... }: + +let + cfg = config.hyprland; +in +{ + options.hyprland = { + initScript = lib.mkOption { + type = lib.types.nullOr lib.types.str; + description = "Script to execute on startup"; + default = null; + }; + }; + + config = { + wayland.windowManager.hyprland = { + enable = true; + settings = { + "$mod" = "SUPER"; + "$term" = "kitty"; + + bind = [ + "$mod, Return, exec, $term" + "$mod, r, exec, rofi -show drun" + "$mod, b, exec, firefox" + + "$mod, left, movefocus, l" + "$mod, h, movefocus, l" + "$mod, down, movefocus, d" + "$mod, j, movefocus, d" + "$mod, up, movefocus, u" + "$mod, k, movefocus, u" + "$mod, right, movefocus, r" + "$mod, l, movefocus, r" + + "$mod_SHIFT, left, movewindow, l" + "$mod_SHIFT, h, movewindow, l" + "$mod_SHIFT, down, movewindow, d" + "$mod_SHIFT, j, movewindow, d" + "$mod_SHIFT, up, movewindow, u" + "$mod_SHIFT, k, movewindow, u" + "$mod_SHIFT, right, movewindow, r" + "$mod_SHIFT, l, movewindow, r" + + "$mod_CTRL, left, resizeactive, -20 0" + "$mod_CTRL, h, resizeactive, -20 0" + "$mod_CTRL, down, resizeactive, 0 20" + "$mod_CTRL, j, resizeactive, 0 20" + "$mod_CTRL, up, resizeactive, 0 -20" + "$mod_CTRL, k, resizeactive, 0 -20" + "$mod_CTRL, right, resizeactive, 20 0" + "$mod_CTRL, l, resizeactive, 20 0" + + "$mod, Tab, cyclenext" + "$mod, Tab, bringactivetotop" + "$mod_SHIFT, Tab, cyclenext, prev" + "$mod_SHIFT, Tab, bringactivetotop" + + "$mod, f, fullscreen, 0" + "$mod, Space, togglefloating" + "$mod, Space, centerwindow" + "$mod, q, killactive" + + "CTRL_ALT, Delete, exit" + ]; + + bindm = [ + "$mod, mouse:272, movewindow" + "$mod, mouse:273, resizewindow" + ]; + + misc = { + "disable_hyprland_logo" = true; + "disable_splash_rendering" = true; + }; + + exec-once = cfg.initScript; + }; + }; + }; +} diff --git a/users/nick/configs/kitty.nix b/user/configs/kitty.nix similarity index 100% rename from users/nick/configs/kitty.nix rename to user/configs/kitty.nix diff --git a/user/configs/stylix.nix b/user/configs/stylix.nix new file mode 100644 index 0000000..eaf51a2 --- /dev/null +++ b/user/configs/stylix.nix @@ -0,0 +1,21 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.stylix; +in +{ + options.stylix = { + wallpaper = lib.mkOption { + type = lib.types.path; + description = "The path to the wallpaper"; + }; + }; + + config = { + stylix = { + enable = true; + base16Scheme = "${pkgs.base16-schemes}/share/themes/da-one-sea.yaml"; + image = cfg.wallpaper; + }; + }; +} diff --git a/users/nick/configs/zsh.nix b/user/configs/zsh.nix similarity index 100% rename from users/nick/configs/zsh.nix rename to user/configs/zsh.nix diff --git a/user/default.nix b/user/default.nix new file mode 100644 index 0000000..5596778 --- /dev/null +++ b/user/default.nix @@ -0,0 +1,92 @@ +{ config, inputs, lib, pkgs, ... }: + +let + wallpaper = ./wallpapers/clouds.png; + init = pkgs.pkgs.writeShellScriptBin "hyprland-init" '' + ${pkgs.swww}/bin/swww-daemon &> /tmp/swww.log & + + while ! swww query &> /dev/null; do + sleep 0.1 + done + + ${pkgs.swww}/bin/swww img ${wallpaper} + ''; + cfg = config.user; +in +{ + options.user = { + vars = lib.mkOption { + type = lib.types.attrs; + description = "Variables for the user"; + }; + + autologin = lib.mkOption { + type = lib.types.bool; + description = "Automatically log in the user on boot"; + default = false; + }; + }; + + config = { + users.users."${cfg.vars.user}" = { + isNormalUser = true; + createHome = true; + home = "/home/${cfg.vars.user}"; + description = cfg.vars.fullName; + hashedPassword = "***REMOVED***"; + extraGroups = [ "wheel" ]; + linger = true; + uid = 1000; + }; + + systemd.tmpfiles.rules = [ "d /persist/home/${cfg.vars.user} 0700 ${cfg.vars.user} users -" ]; + services.getty.autologinUser = lib.mkIf cfg.autologin cfg.vars.user; + programs.hyprland.enable = true; + + home-manager.users."${cfg.vars.user}" = { + imports = [ + inputs.impermanence.nixosModules.home-manager.impermanence + inputs.stylix.homeManagerModules.stylix + ./configs/stylix.nix + ./configs/hyprland.nix + ./configs/zsh.nix + ./configs/kitty.nix + ./configs/firefox.nix + ./configs/git.nix + ]; + + home = { + persistence."/persist/home/${cfg.vars.user}" = { + directories = [ + "Documents" + "Downloads" + "Music" + "Pictures" + "Videos" + "Templates" + "VMs" + "git" + ".mozilla" + ]; + files = [ + ".zsh_history" + ]; + allowOther = true; + }; + + packages = with pkgs; [ + rofi-wayland + swww + ]; + + stateVersion = "24.05"; + }; + + git.vars = cfg.vars; + hyprland.initScript = "${init}/bin/hyprland-init"; + stylix.wallpaper = wallpaper; + + systemd.user.startServices = "sd-switch"; + }; + }; +} diff --git a/users/nick/vars.nix b/user/nick.nix similarity index 100% rename from users/nick/vars.nix rename to user/nick.nix diff --git a/users/nick/scripts/hyprland-init.sh b/user/scripts/hyprland-init.sh similarity index 100% rename from users/nick/scripts/hyprland-init.sh rename to user/scripts/hyprland-init.sh diff --git a/users/nick/secrets/.gitignore b/user/secrets/.gitignore similarity index 100% rename from users/nick/secrets/.gitignore rename to user/secrets/.gitignore diff --git a/users/nick/wallpapers/car.jpg b/user/wallpapers/car.jpg similarity index 100% rename from users/nick/wallpapers/car.jpg rename to user/wallpapers/car.jpg diff --git a/users/nick/wallpapers/cats.jpg b/user/wallpapers/cats.jpg similarity index 100% rename from users/nick/wallpapers/cats.jpg rename to user/wallpapers/cats.jpg diff --git a/users/nick/wallpapers/clouds.png b/user/wallpapers/clouds.png similarity index 100% rename from users/nick/wallpapers/clouds.png rename to user/wallpapers/clouds.png diff --git a/users/nick/wallpapers/girl.png b/user/wallpapers/girl.png similarity index 100% rename from users/nick/wallpapers/girl.png rename to user/wallpapers/girl.png diff --git a/users/nick/wallpapers/mountain.jpg b/user/wallpapers/mountain.jpg similarity index 100% rename from users/nick/wallpapers/mountain.jpg rename to user/wallpapers/mountain.jpg diff --git a/users/nick/wallpapers/plane.jpg b/user/wallpapers/plane.jpg similarity index 100% rename from users/nick/wallpapers/plane.jpg rename to user/wallpapers/plane.jpg diff --git a/users/nick/wallpapers/snow.jpg b/user/wallpapers/snow.jpg similarity index 100% rename from users/nick/wallpapers/snow.jpg rename to user/wallpapers/snow.jpg diff --git a/users/nick/configs/git.nix b/users/nick/configs/git.nix deleted file mode 100644 index 94c61f8..0000000 --- a/users/nick/configs/git.nix +++ /dev/null @@ -1,11 +0,0 @@ -let - vars = import ../vars.nix; -in -{ - programs.git = { - enable = true; - lfs.enable = true; - userEmail = vars.email; - userName = vars.fullName; - }; -} diff --git a/users/nick/configs/hyprland.nix b/users/nick/configs/hyprland.nix deleted file mode 100644 index 53fda3c..0000000 --- a/users/nick/configs/hyprland.nix +++ /dev/null @@ -1,64 +0,0 @@ -{ - wayland.windowManager.hyprland = { - enable = true; - settings = { - "$mod" = "SUPER"; - "$term" = "kitty"; - - bind = [ - "$mod, Return, exec, $term" - "$mod, r, exec, rofi -show drun" - "$mod, b, exec, firefox" - - "$mod, left, movefocus, l" - "$mod, h, movefocus, l" - "$mod, down, movefocus, d" - "$mod, j, movefocus, d" - "$mod, up, movefocus, u" - "$mod, k, movefocus, u" - "$mod, right, movefocus, r" - "$mod, l, movefocus, r" - - "$mod_SHIFT, left, movewindow, l" - "$mod_SHIFT, h, movewindow, l" - "$mod_SHIFT, down, movewindow, d" - "$mod_SHIFT, j, movewindow, d" - "$mod_SHIFT, up, movewindow, u" - "$mod_SHIFT, k, movewindow, u" - "$mod_SHIFT, right, movewindow, r" - "$mod_SHIFT, l, movewindow, r" - - "$mod_CTRL, left, resizeactive, -20 0" - "$mod_CTRL, h, resizeactive, -20 0" - "$mod_CTRL, down, resizeactive, 0 20" - "$mod_CTRL, j, resizeactive, 0 20" - "$mod_CTRL, up, resizeactive, 0 -20" - "$mod_CTRL, k, resizeactive, 0 -20" - "$mod_CTRL, right, resizeactive, 20 0" - "$mod_CTRL, l, resizeactive, 20 0" - - "$mod, Tab, cyclenext" - "$mod, Tab, bringactivetotop" - "$mod_SHIFT, Tab, cyclenext, prev" - "$mod_SHIFT, Tab, bringactivetotop" - - "$mod, f, fullscreen, 0" - "$mod, Space, togglefloating" - "$mod, Space, centerwindow" - "$mod, q, killactive" - - "CTRL_ALT, Delete, exit" - ]; - - bindm = [ - "$mod, mouse:272, movewindow" - "$mod, mouse:273, resizewindow" - ]; - - misc = { - "disable_hyprland_logo" = true; - "disable_splash_rendering" = true; - }; - }; - }; -} diff --git a/users/nick/configs/stylix.nix b/users/nick/configs/stylix.nix deleted file mode 100644 index b5d1cfb..0000000 --- a/users/nick/configs/stylix.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ pkgs, ... }: - -{ - stylix = { - enable = true; - base16Scheme = "${pkgs.base16-schemes}/share/themes/da-one-sea.yaml"; - }; -} diff --git a/users/nick/home.nix b/users/nick/home.nix deleted file mode 100644 index d244845..0000000 --- a/users/nick/home.nix +++ /dev/null @@ -1,76 +0,0 @@ -{ inputs, pkgs, ... }: - -let - wallpaper = ./wallpapers/clouds.png; - init = pkgs.pkgs.writeShellScriptBin "hyprland-init" '' - ${pkgs.swww}/bin/swww-daemon &> /tmp/swww.log & - - while ! swww query &> /dev/null; do - sleep 0.1 - done - - ${pkgs.swww}/bin/swww img ${wallpaper} - ''; - vars = import ./vars.nix; -in -{ - users.users."${vars.user}" = { - isNormalUser = true; - createHome = true; - home = "/home/${vars.user}"; - description = vars.fullName; - hashedPassword = "***REMOVED***"; - extraGroups = [ "wheel" ]; - linger = true; - uid = 1000; - }; - - systemd.tmpfiles.rules = [ "d /persist/home/${vars.user} 0700 ${vars.user} users -" ]; - - programs.hyprland.enable = true; - - home-manager.users."${vars.user}" = { - imports = [ - inputs.impermanence.nixosModules.home-manager.impermanence - inputs.stylix.homeManagerModules.stylix - ./configs/stylix.nix - ./configs/hyprland.nix - ./configs/zsh.nix - ./configs/kitty.nix - ./configs/firefox.nix - ./configs/git.nix - ]; - - home = { - persistence."/persist/home/${vars.user}" = { - directories = [ - "Documents" - "Downloads" - "Music" - "Pictures" - "Videos" - "Templates" - "VMs" - "git" - ".mozilla" - ]; - files = [ - ".zsh_history" - ]; - allowOther = true; - }; - - packages = with pkgs; [ - rofi-wayland - swww - ]; - - stateVersion = "24.05"; - }; - - stylix.image = wallpaper; - wayland.windowManager.hyprland.settings.exec-once = "${init}/bin/hyprland-init"; - - systemd.user.startServices = "sd-switch"; - }; -}