diff --git a/home/profiles/base.nix b/home/profiles/base.nix new file mode 100644 index 00000000..efe70297 --- /dev/null +++ b/home/profiles/base.nix @@ -0,0 +1,2 @@ +{ config, ... }: { +} diff --git a/nixos/modules/gnome.nix b/nixos/modules/gnome.nix new file mode 100644 index 00000000..e29db84f --- /dev/null +++ b/nixos/modules/gnome.nix @@ -0,0 +1,15 @@ +{ config, lib, pkgs, ... }: let + inherit (lib.modules) mkIf; +in { + config = mkIf config.role.gnome { + services.xserver = { + desktopManager.gnome.enable = true; + displayManager.gdm.enable = true; + }; + + environment.systemPackages = with pkgs.gnomeExtensions; [ + dash-to-dock + gsconnect + ]; + }; +} diff --git a/nixos/modules/home.nix b/nixos/modules/home.nix new file mode 100644 index 00000000..85c5ef5b --- /dev/null +++ b/nixos/modules/home.nix @@ -0,0 +1,14 @@ +{ config, tree, machine, ... }: { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + sharedModules = [ + tree.home.modules + tree.system.modules + ]; + extraSpecialArgs = { + inherit tree machine; + nixos = config; + }; + }; +} diff --git a/nixos/modules/laptop.nix b/nixos/modules/laptop.nix new file mode 100644 index 00000000..8d68baba --- /dev/null +++ b/nixos/modules/laptop.nix @@ -0,0 +1,8 @@ +{ config, lib, ... }: let + inherit (lib.modules) mkIf mkDefault; +in { + config = mkIf config.role.laptop { + powerManagement.cpuFreqGovernor = mkDefault "powersave"; + programs.light.enable = true; + }; +} diff --git a/nixos/modules/personal.nix b/nixos/modules/personal.nix new file mode 100644 index 00000000..fe807146 --- /dev/null +++ b/nixos/modules/personal.nix @@ -0,0 +1,7 @@ +{ config, lib, ... }: let + inherit (lib.modules) mkIf; +in { + config = mkIf config.role.personal { + services.fstrim.enable = true; + }; +} diff --git a/nixos/modules/server.nix b/nixos/modules/server.nix index 3717b7fb..931c630b 100644 --- a/nixos/modules/server.nix +++ b/nixos/modules/server.nix @@ -1,16 +1,7 @@ { config, lib, ... }: let - inherit (lib.options) mkOption mdDoc; inherit (lib.modules) mkIf; inherit (lib.attrsets) mapAttrsToList; - inherit (lib.types) bool; in { - options = { - role.server = mkOption { - type = bool; - description = mdDoc "Is this system's role a server?"; - default = false; - }; - }; config = mkIf config.role.server { # Prevent services from being automatically killed on log-out # https://wiki.archlinux.org/title/systemd/User#Automatic_start-up_of_systemd_user_instances diff --git a/nixos/systems/koishi.nix b/nixos/systems/koishi.nix index efe70297..9e2033ed 100644 --- a/nixos/systems/koishi.nix +++ b/nixos/systems/koishi.nix @@ -1,2 +1,51 @@ { config, ... }: { + role = { + laptop = true; + personal = true; + gnome = true; + }; + + fileSystems = { + "/" = { + device = "/dev/disk/by-uuid/a664de0f-9883-420e-acc5-b9602a23e816"; + fsType = "xfs"; + }; + "/boot" = { + device = "/dev/disk/by-uuid/DEBC-8F03"; + fsType = "vfat"; + }; + }; + + swapDevices = [ + { device = "/dev/disk/by-uuid/0d846453-95b4-46e1-8eaf-b910b4321ef0"; } + ]; + + boot = { + supportedFilesystems = [ "xfs" ]; + initrd.luks.devices."cryptroot".device = "/dev/disk/by-uuid/f0ea08b4-6af7-4d90-a2ad-edd5672a2105"; + loader = { + efi = { + canTouchEfiVariables = true; + efiSysMountPoint = "/boot"; + }; + grub = { + devices = [ "nodev" ]; + efiSupport = true; + enable = true; + extraEntries = '' + menuentry "Windows" { + insmod part_gpt + insmod fat + insmod search_fs_uuid + insmod chain + search --fs-uuid --set=root DEBC-8F03 + chainloader /EFI/Microsoft/Boot/bootmgfw.efi + } + ''; + version = 2; + }; + }; + }; + + system.stateVersion = "21.11"; } diff --git a/nixos/users/kat.nix b/nixos/users/kat.nix index 4f4b3843..e963974b 100644 --- a/nixos/users/kat.nix +++ b/nixos/users/kat.nix @@ -1,6 +1,4 @@ -{ tree, config, ... }: with lib; - -{ +{ tree, config, ... }: { users.users.kat = { uid = 1000; isNormalUser = true; @@ -10,6 +8,13 @@ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAII74JrgGsDQ6r7tD7+k3ykxXV7DpeeFRscPMxrBsDPhz kat@goliath" ]; shell = pkgs.zsh; - extraGroups = [ "wheel" "video" "systemd-journal" "plugdev" "bird2" "vfio" "input" "uinput" ]; + extraGroups = [ + "wheel" + "video" + "systemd-journal" + "plugdev" + "input" + "uinput" + ]; }; } diff --git a/outputs.nix b/outputs.nix index 5740f6a3..66b1cd48 100644 --- a/outputs.nix +++ b/outputs.nix @@ -9,6 +9,11 @@ "default" ]; }; + "system/modules" = { + functor = { + enable = true; + }; + }; "nixos/modules" = { functor = { enable = true; @@ -27,14 +32,11 @@ ]; }; }; - "home".evaluateDefault = true; - "home/*" = { - functor.enable = true; - }; }; }).impure; lib = inputs.nixpkgs.lib; inherit (lib.attrsets) mapAttrs; + inherit (builtins) removeAttrs; inherit (lib.lists) singleton; in utils.lib.mkFlake { inherit self inputs; @@ -43,6 +45,9 @@ in utils.lib.mkFlake { hostDefaults = { system = "x86_64-linux"; + modules = [ + tree.system.modules + ]; extraArgs = { inherit inputs tree; }; @@ -96,18 +101,14 @@ in utils.lib.mkFlake { extraSpecialArgs = { inherit inputs tree; machine = name; + nixos = {}; }; modules = [ - ({ config, ... }: { - home = { - username = "kat"; - stateVersion = "22.11"; - homeDirectory = "/home/kat"; - }; - }) + tree.system.modules + tree.home.common path ]; - }) tree.home; + }) tree.home.profiles; inherit tree; }; diff --git a/system/modules/roles.nix b/system/modules/roles.nix new file mode 100644 index 00000000..9c238811 --- /dev/null +++ b/system/modules/roles.nix @@ -0,0 +1,30 @@ +{ config, lib, ... }: let + inherit (lib.options) mkOption mdDoc; + inherit (lib.modules) mkIf mkDefault; + inherit (lib.types) bool; +in { + options = { + role = { + server = mkOption { + type = bool; + description = mdDoc "Is this system's role as a server?"; + default = false; + }; + personal = mkOption { + type = bool; + description = mdDoc "Is this system's role as a personal device?"; + default = false; + }; + laptop = mkOption { + type = bool; + description = mdDoc "Is this system's role as a laptop?"; + default = false; + }; + gnome = mkOption { + type = bool; + description = mdDoc "Does this system's role include running GNOME?"; + default = false; + }; + }; + }; +}