diff --git a/flake.nix b/flake.nix index 79e5203..e9a0ee1 100644 --- a/flake.nix +++ b/flake.nix @@ -72,6 +72,12 @@ configuration = ./users/jan.nix; }; }; + "vm-audio" = mkConfig "x86_64-linux" ./machines/vm-audio.nix { + jan = { + sudo = true; + configuration = ./users/server.nix; + }; + }; }; lib = import ./shell-modules/default.nix self.inputs; }; diff --git a/machines/laptop.nix b/machines/laptop.nix index 335d3ac..cc3016c 100644 --- a/machines/laptop.nix +++ b/machines/laptop.nix @@ -15,7 +15,7 @@ # Enabled modules modules = { - base.enable = true; + base.desktop.enable = true; bluetooth.enable = true; power-saving.enable = false; networkmanager.enable = true; diff --git a/machines/vm-audio.nix b/machines/vm-audio.nix new file mode 100644 index 0000000..b117548 --- /dev/null +++ b/machines/vm-audio.nix @@ -0,0 +1,55 @@ +{ lib, ... }: + +{ + imports = [ + # Import environment + ./vm-base.nix + ]; + + config = { + # Machine hostname + networking.hostName = "vm-audio"; + + # Enabled modules + modules = { + }; + + # Hardware configuration + hardware.enableRedistributableFirmware = true; + boot.initrd.availableKernelModules = [ + "ata_piix" + "uhci_hcd" + "virtio_pci" + "virtio_scsi" + "sd_mod" + "sr_mod" + ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + hardware.cpu.intel.updateMicrocode = true; + + # Filesystems + fileSystems."/" = { + device = "/dev/disk/by-partlabel/root"; + fsType = "ext4"; + }; + + fileSystems."/boot" = { + device = "/dev/disk/by-partlabel/EFI"; + fsType = "vfat"; + options = [ + "fmask=0077" + "dmask=0077" + ]; + }; + + # Swapfile + swapDevices = [ + { + device = "/var/lib/swapfile"; + size = 6 * 1024; + } + ]; + }; +} diff --git a/machines/vm-base.nix b/machines/vm-base.nix new file mode 100644 index 0000000..63ac9be --- /dev/null +++ b/machines/vm-base.nix @@ -0,0 +1,60 @@ +{ lib, ... }: + +{ + imports = [ + # Import environment + ../default.nix + ]; + + config = { + # State version + system.stateVersion = "24.11"; + + # Machine hostname + networking.hostName = lib.mkDefault "vm-base"; + + # Enabled modules + modules = { + base.enable = true; + ssh.enable = true; + }; + + # Hardware configuration + hardware.enableRedistributableFirmware = true; + boot.initrd.availableKernelModules = [ + "ata_piix" + "uhci_hcd" + "virtio_pci" + "virtio_scsi" + "sd_mod" + "sr_mod" + ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + hardware.cpu.intel.updateMicrocode = true; + + # Filesystems + fileSystems."/" = { + device = "/dev/disk/by-partlabel/root"; + fsType = "ext4"; + }; + + fileSystems."/boot" = { + device = "/dev/disk/by-partlabel/EFI"; + fsType = "vfat"; + options = [ + "fmask=0077" + "dmask=0077" + ]; + }; + + # Swapfile + swapDevices = [ + { + device = "/var/lib/swapfile"; + size = 6 * 1024; + } + ]; + }; +} diff --git a/modules/base/default.nix b/modules/base/default.nix index 792d24e..3ce0ef3 100644 --- a/modules/base/default.nix +++ b/modules/base/default.nix @@ -27,42 +27,13 @@ in pciutils zip unzip - - # TODO: MOVE - quickemu # TODO: Reenable once building this is fixed - pdftk - - # TODO: Move to USB module - # usbutils - # udiskie - # udisks - brightnessctl ]; - security.krb5 = { - enable = true; - settings = { - libdefaults = { - rdns = false; - }; - realms = { - "GEWISWG.GEWIS.NL" = { - kdc = [ - "https://gewisvdesktop.gewis.nl/KdcProxy" - ]; - }; - }; - }; - }; - modules = { # Enable base modules clean-tmp.enable = true; - fontconfig.enable = true; neovim.enable = true; systemd-boot.enable = true; - nixgreety.enable = true; - pipewire.enable = true; }; # TODO: Remove everything below, it is here out of convenience and should be elsewhere @@ -75,34 +46,9 @@ in enable = true; }; networking.firewall.enable = true; - programs.dconf.enable = true; - services.libinput.enable = true; - services.upower.enable = true; # For battery percentage in gnome modules.unfree.enable = true; - modules.unfree.allowedPackages = [ - "nvidia-x11" - "nvidia-settings" - ]; nix.settings.experimental-features = "nix-command flakes"; - # networking.useDHCP = true; nixpkgs.hostPlatform = "x86_64-linux"; - networking.firewall.allowedTCPPortRanges = [ - { - from = 10000; - to = 11000; - } - ]; - networking.firewall.allowedUDPPortRanges = [ - { - from = 10000; - to = 11000; - } - ]; - security.rtkit.enable = true; - - # TODO: Move to USB module - # services.gvfs.enable = true; - services.udisks2.enable = true; console.packages = [ pkgs.dina-psfu diff --git a/modules/base/desktop.nix b/modules/base/desktop.nix new file mode 100644 index 0000000..6195450 --- /dev/null +++ b/modules/base/desktop.nix @@ -0,0 +1,81 @@ +{ + lib, + config, + pkgs, + ... +}: + +with lib; +let + cfg = config.modules.base.desktop; +in +{ + options.modules.base.desktop = { + enable = mkEnableOption "desktop"; + }; + + config = mkIf cfg.enable { + environment.systemPackages = with pkgs; [ + # TODO: MOVE + quickemu # TODO: Reenable once building this is fixed + pdftk + + # TODO: Move to USB module + # usbutils + # udiskie + # udisks + brightnessctl + ]; + + # Move to Realm module + security.krb5 = { + enable = true; + settings = { + libdefaults = { + rdns = false; + }; + realms = { + "GEWISWG.GEWIS.NL" = { + kdc = [ + "https://gewisvdesktop.gewis.nl/KdcProxy" + ]; + }; + }; + }; + }; + + modules = { + # Enable base modules + base.enable = true; + fontconfig.enable = true; + nixgreety.enable = true; + pipewire.enable = true; + graphics.enable = true; + }; + + programs.dconf.enable = true; + services.libinput.enable = true; + services.upower.enable = true; # For battery percentage in gnome + modules.unfree.allowedPackages = [ + "nvidia-x11" + "nvidia-settings" + ]; + networking.firewall.allowedTCPPortRanges = [ + { + from = 10000; + to = 11000; + } + ]; + networking.firewall.allowedUDPPortRanges = [ + { + from = 10000; + to = 11000; + } + ]; + security.rtkit.enable = true; + + # TODO: Move to USB module + # services.gvfs.enable = true; + services.udisks2.enable = true; + }; +} diff --git a/modules/default.nix b/modules/default.nix index 7c03df9..fa59cc0 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -10,6 +10,7 @@ with lib; imports = [ # Import modules ./base/default.nix + ./base/desktop.nix ./bluetooth/default.nix ./boot/clean-tmp.nix ./boot/silent-boot.nix @@ -28,6 +29,7 @@ with lib; ./power-saving/default.nix ./printing/default.nix ./sound/pipewire.nix + ./ssh/default.nix ./users/default.nix ./unfree/default.nix ./vpn/tailscale.nix diff --git a/modules/graphics/default.nix b/modules/graphics/default.nix index bb83d2a..42e8265 100644 --- a/modules/graphics/default.nix +++ b/modules/graphics/default.nix @@ -5,8 +5,15 @@ ... }: +with lib; +let + cfg = config.modules.fontconfig; +in { - config = { + options.modules.graphics = { + enable = mkEnableOption "graphics"; + }; + config = mkIf cfg.enable { # TODO: Modularize further, especially modesetting should be its own module. # Set up graphics hardware.graphics.enable32Bit = true; diff --git a/modules/ssh/default.nix b/modules/ssh/default.nix new file mode 100644 index 0000000..e619d5b --- /dev/null +++ b/modules/ssh/default.nix @@ -0,0 +1,20 @@ +{ + lib, + config, + pkgs, + ... +}: + +with lib; +let + cfg = config.modules.ssh; +in +{ + options.modules.ssh = { + enable = mkEnableOption "ssh"; + }; + + config = mkIf cfg.enable { + services.openssh.enable = true; + }; +} diff --git a/user-modules/desktop/custom/default.nix b/user-modules/desktop/custom/default.nix index 2910b45..5274974 100644 --- a/user-modules/desktop/custom/default.nix +++ b/user-modules/desktop/custom/default.nix @@ -37,7 +37,7 @@ in }; }; - config = + config = mkIf config.desktop.enable ( lib.recursiveUpdate { # Ensure desktop related systemd services (xdg) have access to session variables. @@ -84,5 +84,6 @@ in # } # ."${cfg.decorations}" { } - ); + ) + ); } diff --git a/user-modules/desktop/default.nix b/user-modules/desktop/default.nix index d95e016..3441b9e 100644 --- a/user-modules/desktop/default.nix +++ b/user-modules/desktop/default.nix @@ -54,6 +54,7 @@ in ]; options.desktop = { + enable = mkEnableOption "desktop"; name = mkOption { type = types.str; default = "Shell"; @@ -90,7 +91,7 @@ in }; }; - config = { + config = mkIf cfg.enable { specialisation = mapAttrs (name: value: { configuration = (environmentBuilders."${value.type}" value); }) cfg.environments; diff --git a/user-modules/desktop/theming/colors.nix b/user-modules/desktop/theming/colors.nix new file mode 100644 index 0000000..faa3d9b --- /dev/null +++ b/user-modules/desktop/theming/colors.nix @@ -0,0 +1,156 @@ +{ + pkgs, + lib, + config, + ... +}: + +with lib; +let + cfg = config.desktop.theming; +in +{ + imports = [ + # Import all themes + ./themes/catppuccin.nix + ./themes/gruvbox.nix + ./themes/oxocarbon.nix + ./themes/papercolor.nix + ./themes/sakura.nix + ./themes/nord.nix + ]; + + options.desktop.theming = + let + colors = config.desktop.theming.schemeColors; + in + { + darkMode = mkOption { + type = types.bool; + default = false; + example = true; + description = "Whether the app should use dark mode."; + }; + + colorScheme = mkOption { + type = types.nullOr types.str; + default = "${pkgs.base16-schemes}/share/themes/catppuccin-mocha.yaml"; + description = "Base 16 color scheme to use for styling. See stylix documentation for more information."; + }; + + schemeColors = mkOption { + type = types.attrsOf types.anything; + default = config.lib.stylix.colors; + description = "Generated colors from scheme"; + }; + + colors = { + bg = mkOption { + type = types.str; + default = colors.base00; + }; + fg = mkOption { + type = types.str; + default = colors.base05; + }; + bg-status = mkOption { + type = types.str; + default = colors.base01; + }; + fg-status = mkOption { + type = types.str; + default = colors.base04; + }; + bg-selection = mkOption { + type = types.str; + default = colors.base02; + }; + bg-highlight = mkOption { + type = types.str; + default = colors.base03; + }; + fg-search = mkOption { + type = types.str; + default = colors.base0A; + }; + accent = mkOption { + type = types.str; + default = colors.base0E; + }; + border-focused = mkOption { + type = types.str; + default = cfg.colors.fg; + }; + border-unfocused = mkOption { + type = types.str; + default = cfg.colors.bg-selection; + }; + }; + + colorsCSS = mkOption { + type = types.lines; + default = + ":root {\n" + + concatStrings ( + map (color: " --nix-color-${color.name}: #${color.value};\n") (attrsToList cfg.colors) + ) + + "}\n\n"; + description = "Colors as css variables"; + }; + }; + + config = { + # Configure gnome theme + dconf.settings = { + "org/gnome/desktop/interface" = { + color-scheme = if cfg.darkMode then "prefer-dark" else "prefer-light"; + }; + }; + + # Configure qt theme + qt = { + enable = true; + platformTheme.name = "adwaita"; + style.name = if cfg.darkMode then "adwaita-dark" else "adwaita-light"; + }; + + # Configure gtk theme + gtk = { + enable = true; + theme = { + name = if cfg.darkMode then "Adwaita-dark" else "Adwaita-light"; + package = pkgs.gnome-themes-extra; + }; + }; + + # TODO: This should just straight up not be here + programs.direnv = { + enable = true; + nix-direnv.enable = true; + }; + modules.git.ignores = [ + ".direnv" + ]; + + # Enable stylix + # TODO: Move to own module + stylix = { + enable = true; + autoEnable = false; + + targets = { + foot.enable = true; + nixvim.enable = true; + qutebrowser.enable = true; + vscode = { + enable = true; + profileNames = [ "Default" ]; + }; + zathura.enable = true; + }; + + base16Scheme = cfg.colorScheme; + polarity = if cfg.darkMode then "dark" else "light"; + }; + }; +} diff --git a/user-modules/desktop/theming/default.nix b/user-modules/desktop/theming/default.nix index daf938a..5e512e0 100644 --- a/user-modules/desktop/theming/default.nix +++ b/user-modules/desktop/theming/default.nix @@ -91,186 +91,88 @@ in { imports = [ ./background.nix - - # Import all themes - ./themes/catppuccin.nix - ./themes/gruvbox.nix - ./themes/oxocarbon.nix - ./themes/papercolor.nix - ./themes/sakura.nix - ./themes/nord.nix + ./colors.nix ]; - options.desktop.theming = - let - colors = config.desktop.theming.schemeColors; - in - { - darkMode = mkOption { - type = types.bool; - default = false; - example = true; - description = "Whether the app should use dark mode."; + options.desktop.theming = { + layout = { + borderRadius = mkOption { + type = types.int; + default = 0; + description = "Border radius of windows."; }; - colorScheme = mkOption { - type = types.nullOr types.str; - default = null; - description = "Base 16 color scheme to use for styling. See stylix documentation for more information."; + borderSize = mkOption { + type = types.int; + default = 1; + description = "Size of borders used throughout UI."; }; - schemeColors = mkOption { - type = types.attrsOf types.anything; - default = config.lib.stylix.colors; - description = "Generated colors from scheme"; - }; - - colors = { - bg = mkOption { - type = types.str; - default = colors.base00; - }; - fg = mkOption { - type = types.str; - default = colors.base05; - }; - bg-status = mkOption { - type = types.str; - default = colors.base01; - }; - fg-status = mkOption { - type = types.str; - default = colors.base04; - }; - bg-selection = mkOption { - type = types.str; - default = colors.base02; - }; - bg-highlight = mkOption { - type = types.str; - default = colors.base03; - }; - fg-search = mkOption { - type = types.str; - default = colors.base0A; - }; - accent = mkOption { - type = types.str; - default = colors.base0E; - }; - border-focused = mkOption { - type = types.str; - default = cfg.colors.fg; - }; - border-unfocused = mkOption { - type = types.str; - default = cfg.colors.bg-selection; - }; - }; - - colorsCSS = mkOption { - type = types.lines; - default = - ":root {\n" - + concatStrings ( - map (color: " --nix-color-${color.name}: #${color.value};\n") (attrsToList cfg.colors) - ) - + "}\n\n"; - description = "Colors as css variables"; - }; - - layout = { - borderRadius = mkOption { - type = types.int; - default = 0; - description = "Border radius of windows."; - }; - - borderSize = mkOption { - type = types.int; - default = 1; - description = "Size of borders used throughout UI."; - }; - - windowPadding = mkOption { - type = types.int; - default = 2; - description = "Margin of each window, actual space between windows will be twice this number."; - }; - }; - - fonts = { - pkgs = mkOption { - type = types.attrsOf fontModule; - default = builtins.listToAttrs ( - map (module: { - name = module.name; - value = module; - }) (map (module: (import module) { inherit lib config pkgs; }) fontModules) - ); - description = "All available font modules."; - }; - - installed = mkOption { - type = types.listOf types.str; - default = fontNameList; - description = "List of installed fonts."; - }; - - serif = mkOption { - type = fontModule; - description = "Default serif font"; - }; - - sansSerif = mkOption { - type = fontModule; - description = "Default sansSerif font."; - }; - - monospace = mkOption { - type = fontModule; - description = "Default monospace font."; - }; - - emoji = mkOption { - type = fontModule; - description = "Default emoji font."; - }; - - interface = mkOption { - type = fontModule; - description = "Default emoji font."; - }; - - extraFonts = mkOption { - type = types.listOf fontModule; - default = [ ]; - description = "Additional fonts to install."; - }; + windowPadding = mkOption { + type = types.int; + default = 2; + description = "Margin of each window, actual space between windows will be twice this number."; }; }; - config = { + fonts = { + pkgs = mkOption { + type = types.attrsOf fontModule; + default = builtins.listToAttrs ( + map (module: { + name = module.name; + value = module; + }) (map (module: (import module) { inherit lib config pkgs; }) fontModules) + ); + description = "All available font modules."; + }; + + installed = mkOption { + type = types.listOf types.str; + default = fontNameList; + description = "List of installed fonts."; + }; + + serif = mkOption { + type = fontModule; + description = "Default serif font"; + }; + + sansSerif = mkOption { + type = fontModule; + description = "Default sansSerif font."; + }; + + monospace = mkOption { + type = fontModule; + description = "Default monospace font."; + }; + + emoji = mkOption { + type = fontModule; + description = "Default emoji font."; + }; + + interface = mkOption { + type = fontModule; + description = "Default emoji font."; + }; + + extraFonts = mkOption { + type = types.listOf fontModule; + default = [ ]; + description = "Additional fonts to install."; + }; + }; + }; + + config = mkIf config.desktop.enable { # Enable fontconfig modules.fontconfig.enable = true; # Install configured fonts home.packages = fontPackageList; - # Configure gnome theme - dconf.settings = { - "org/gnome/desktop/interface" = { - color-scheme = if cfg.darkMode then "prefer-dark" else "prefer-light"; - }; - }; - - # Configure qt theme - qt = { - enable = true; - platformTheme.name = "adwaita"; - style.name = if cfg.darkMode then "adwaita-dark" else "adwaita-light"; - }; - # Configure gtk theme gtk = let @@ -287,26 +189,11 @@ in in { enable = true; - - theme = { - name = if cfg.darkMode then "Adwaita-dark" else "Adwaita-light"; - package = pkgs.gnome-themes-extra; - }; - # TODO: Toggles gtk3.extraCss = disableCSD; gtk4.extraCss = disableCSD; }; - # TODO: This should just straight up not be here - programs.direnv = { - enable = true; - nix-direnv.enable = true; - }; - modules.git.ignores = [ - ".direnv" - ]; - # TODO: Make cursors configurable using modules. home.pointerCursor = { gtk.enable = true; @@ -322,23 +209,6 @@ in # Enable stylix # TODO: Move to own module stylix = { - enable = true; - autoEnable = false; - - targets = { - foot.enable = true; - nixvim.enable = true; - qutebrowser.enable = true; - vscode = { - enable = true; - profileNames = [ "NixOS" ]; - }; - zathura.enable = true; - }; - - base16Scheme = cfg.colorScheme; - polarity = if cfg.darkMode then "dark" else "light"; - fonts = { serif = getAttrs [ "name" diff --git a/users/jan.nix b/users/jan.nix index d215b0e..3d614eb 100644 --- a/users/jan.nix +++ b/users/jan.nix @@ -27,6 +27,7 @@ ]; # desktop.development = "river-light"; + desktop.enable = true; desktop.environments = { river-dark = { name = "River Dark"; diff --git a/users/server.nix b/users/server.nix new file mode 100644 index 0000000..547bd29 --- /dev/null +++ b/users/server.nix @@ -0,0 +1,62 @@ +# How Jan likes his linux to be configured on servers + +{ + pkgs, + ... +}: + +{ + config = { + # State version + home.stateVersion = "24.11"; + + # TODO: Move into modules + home.packages = with pkgs; [ + libreoffice-still + remmina + pinentry + thunderbird + signal-desktop + prusa-slicer + freecad-wayland + inkscape + ente-auth + bitwarden + ]; + + # Enabled modules + modules = { + # Tools + git = { + enable = true; + user = "Jan-Bulthuis"; + email = "git@bulthuis.dev"; + # TODO: Move + ignores = [ + ".envrc" + ".direnv" + "flake.nix" + "flake.lock" + ]; + }; + btop.enable = true; + fish.enable = true; + keyring.enable = true; + scripts.enable = true; + + # Development + neovim.enable = true; + + # Languages + haskell.enable = false; + js.enable = true; + nix.enable = true; + rust.enable = true; + python.enable = true; + cpp.enable = true; + + # Enable unfree + unfree.enable = true; + }; + }; +}