diff --git a/machines/asus-gl553vd/default.nix b/machines/asus-gl553vd/default.nix index 3acaa67..7d72ee7 100644 --- a/machines/asus-gl553vd/default.nix +++ b/machines/asus-gl553vd/default.nix @@ -7,7 +7,12 @@ in imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix - ../common.nix + ../modules/common.nix + ../modules/sound.nix + ../modules/window_manager.nix + ../modules/fonts.nix + ../modules/gnupg.nix + ../modules/nix.nix ]; # Use latest kernel @@ -23,10 +28,13 @@ in hostName = "laptop"; # Define your hostname. inherit (secrets.networking) extraHosts; + useDHCP = false; interfaces = { enp3s0.useDHCP = true; wlp2s0.useDHCP = true; }; + + networkmanager.enable = true; }; # enable bluetooth @@ -36,12 +44,12 @@ in # configure mouse and touchpad services.xserver.libinput = { enable = true; - mouse = { - accelSpeed = "1.0"; - }; touchpad = { accelSpeed = "0.5"; disableWhileTyping = true; }; }; + + # Enable the Docker + virtualisation.docker.enable = true; } diff --git a/machines/common.nix b/machines/common.nix deleted file mode 100644 index 36bdd15..0000000 --- a/machines/common.nix +++ /dev/null @@ -1,160 +0,0 @@ -# Edit this configuration file to define what should be installed on -# your system. Help is available in the configuration.nix(5) man page -# and in the NixOS manual (accessible by running ‘nixos-help’). - -{ config, pkgs, ... }: - -{ - networking = { - networkmanager.enable = true; - - # The global useDHCP flag is deprecated, therefore explicitly set to false here. - # Per-interface useDHCP will be mandatory in the future, so this generated config - # replicates the default behaviour. - useDHCP = false; - }; - - # Select internationalisation properties. - i18n.defaultLocale = "en_US.UTF-8"; - - # Set your time zone. - time.timeZone = "Europe/Moscow"; - - fonts = { - enableDefaultFonts = true; - fonts = with pkgs; [ - ubuntu_font_family - fira-code - (nerdfonts.override { fonts = [ "FiraCode" ]; }) - ]; - fontconfig = { - defaultFonts = { - monospace = [ - "Fira Code" - "emoji" - "FiraCode Nerd Font Mono" - ]; - serif = [ "Ubuntu" "emoji" ]; - sansSerif = [ "Ubuntu" "emoji" ]; - emoji = [ "Noto Color Emoji" ]; - }; - }; - }; - - # Configure network proxy if necessary - # networking.proxy.default = "http://user:password@proxy:port/"; - # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; - - console.useXkbConfig = true; - - # Enable the X11 windowing system. - services = { - # Xmonad - dbus = { - enable = true; - packages = [ pkgs.dconf ]; - }; - - xserver = { - enable = true; - - xkbModel = "pc105"; - layout = "us,us"; - xkbVariant = "dvorak,"; - xkbOptions = "grp:win_space_toggle"; - - displayManager = { - defaultSession = "none+xmonad"; - }; - - windowManager.xmonad.enable = true; - }; - }; - - # Enable sound. - sound = { - enable = true; - mediaKeys.enable = true; - }; - - hardware.pulseaudio = { - enable = true; - package = pkgs.pulseaudioFull; - }; - - programs.zsh.enable = true; - - # Define a user account. Don't forget to set a password with ‘passwd’. - - # List packages installed in system profile. To search, run: - # $ nix search wget - environment.systemPackages = with pkgs; [ - gnumake - vim - wget - ]; - - # Enable the OpenSSH daemon. - services.openssh.enable = true; - - # Some programs need SUID wrappers, can be configured further or are - # started in user sessions. - # programs.mtr.enable = true; - programs.gnupg.agent = { - enable = true; - enableSSHSupport = true; - }; - - virtualisation = { - docker.enable = true; - }; - - nix = { - settings = { - auto-optimise-store = true; - - trusted-users = [ "root" ]; - - experimental-features = [ "nix-command" "flakes" ]; - - # To protect nix-shell against garbage collection - # Source: https://github.com/nix-community/nix-direnv#installation - keep-derivations = true; - keep-outputs = true; - }; - - registry = - let - gitple = "https://git.pleshevski.ru"; - mkRegistry = id: url: { - from = { type = "indirect"; inherit id; }; - to = { type = "git"; inherit url; }; - }; - in - { - templates = mkRegistry "tmpl" "${gitple}/mynix/templates"; - }; - }; - - users.mutableUsers = false; - - # Open ports in the firewall. - # networking.firewall.allowedTCPPorts = [ ... ]; - # networking.firewall.allowedUDPPorts = [ ... ]; - # Or disable the firewall altogether. - # networking.firewall.enable = false; - - # Copy the NixOS configuration file and link it from the resulting system - # (/run/current-system/configuration.nix). This is useful in case you - # accidentally delete configuration.nix. - # system.copySystemConfiguration = true; - - # This value determines the NixOS release from which the default - # settings for stateful data, like file locations and database versions - # on your system were taken. It‘s perfectly fine and recommended to leave - # this value at the release version of the first install of this system. - # Before changing this value read the documentation for this option - # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). - system.stateVersion = "22.11"; # Did you read the comment? - -} diff --git a/machines/default.nix b/machines/default.nix index 6714a1d..6930425 100644 --- a/machines/default.nix +++ b/machines/default.nix @@ -8,7 +8,6 @@ in system = "x86_64-linux"; extraModules = [ - ../modules/garbage-collector.nix ../users/jan ]; @@ -30,5 +29,4 @@ in local.alacritty.fontSize = 6.0; }; }; - } diff --git a/machines/home/default.nix b/machines/home/default.nix index 4b09afc..109eedd 100644 --- a/machines/home/default.nix +++ b/machines/home/default.nix @@ -7,35 +7,44 @@ in imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix - ../common.nix + ../modules/common.nix + ../modules/sound.nix + ../modules/window_manager.nix + ../modules/fonts.nix + ../modules/gnupg.nix + ../modules/nix.nix + ../modules/garbage-collector.nix ]; + # Configure kernel boot = { - # Use the GRUB 2 boot loader. - loader.grub = { - enable = true; - version = 2; - device = "/dev/sdb"; - }; - kernelPackages = pkgs.linuxPackages_latest; extraModulePackages = with config.boot.kernelPackages; [ rtl88x2bu ]; }; + # Use the GRUB 2 boot loader. + boot.loader.grub = { + enable = true; + version = 2; + device = "/dev/sdb"; + }; + networking = { hostName = "home"; # Define your hostname. inherit (secrets.networking) extraHosts; + useDHCP = false; interfaces = { enp3s0.useDHCP = true; wlp11s0f3u2.useDHCP = true; }; + + networkmanager.enable = true; }; nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "cnijfilter2" ]; - services = { avahi = { enable = true; @@ -67,4 +76,7 @@ in } ]; }; + + # Enable the Docker + virtualisation.docker.enable = true; } diff --git a/machines/modules/common.nix b/machines/modules/common.nix new file mode 100644 index 0000000..d0b7ce1 --- /dev/null +++ b/machines/modules/common.nix @@ -0,0 +1,42 @@ +{ config, pkgs, ... }: + +{ + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + # Set your time zone. + time.timeZone = "Europe/Moscow"; + + users.mutableUsers = false; + + programs.zsh.enable = true; + + environment.systemPackages = with pkgs; [ + gnumake + vim + wget + ]; + + # Enable the OpenSSH daemon. + services.openssh.enable = true; + + + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; + + # Copy the NixOS configuration file and link it from the resulting system + # (/run/current-system/configuration.nix). This is useful in case you + # accidentally delete configuration.nix. + # system.copySystemConfiguration = true; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "22.11"; # Did you read the comment? + +} diff --git a/machines/modules/fonts.nix b/machines/modules/fonts.nix new file mode 100644 index 0000000..7295c8c --- /dev/null +++ b/machines/modules/fonts.nix @@ -0,0 +1,24 @@ +{ pkgs, ... }: + +{ + fonts = { + enableDefaultFonts = true; + fonts = with pkgs; [ + ubuntu_font_family + fira-code + (nerdfonts.override { fonts = [ "FiraCode" ]; }) + ]; + fontconfig = { + defaultFonts = { + monospace = [ + "Fira Code" + "emoji" + "FiraCode Nerd Font Mono" + ]; + serif = [ "Ubuntu" "emoji" ]; + sansSerif = [ "Ubuntu" "emoji" ]; + emoji = [ "Noto Color Emoji" ]; + }; + }; + }; +} diff --git a/modules/garbage-collector.nix b/machines/modules/garbage-collector.nix similarity index 100% rename from modules/garbage-collector.nix rename to machines/modules/garbage-collector.nix diff --git a/machines/modules/gnupg.nix b/machines/modules/gnupg.nix new file mode 100644 index 0000000..e0f6a02 --- /dev/null +++ b/machines/modules/gnupg.nix @@ -0,0 +1,8 @@ +{ config, ... }: + +{ + programs.gnupg.agent = { + enable = true; + enableSSHSupport = config.services.openssh.enable; + }; +} diff --git a/machines/modules/nix.nix b/machines/modules/nix.nix new file mode 100644 index 0000000..bcb19fc --- /dev/null +++ b/machines/modules/nix.nix @@ -0,0 +1,40 @@ +{ lib, config, ... }: + +let cfg = config.local.nix; in +{ + options.local.nix = with lib; { + enableMyRegistry = mkOption { + type = types.bool; + default = false; + description = "Enable my custom nix registry"; + }; + }; + + config = { + nix = { + settings = { + auto-optimise-store = true; + + trusted-users = [ "root" ]; + + experimental-features = [ "nix-command" "flakes" ]; + + # To protect nix-shell against garbage collection + # Source: https://github.com/nix-community/nix-direnv#installation + keep-derivations = true; + keep-outputs = true; + }; + + registry = lib.mkIf cfg.enableMyRegistry ( + let + gitple = "https://git.pleshevski.ru"; + mkRegistry = id: url: { + from = { type = "indirect"; inherit id; }; + to = { type = "git"; inherit url; }; + }; + in + { templates = mkRegistry "tmpl" "${gitple}/mynix/templates"; } + ); + }; + }; +} diff --git a/machines/modules/sound.nix b/machines/modules/sound.nix new file mode 100644 index 0000000..91a58f2 --- /dev/null +++ b/machines/modules/sound.nix @@ -0,0 +1,14 @@ +{ pkgs, ... }: + +{ + # Enable sound. + sound = { + enable = true; + mediaKeys.enable = true; + }; + + hardware.pulseaudio = { + enable = true; + package = pkgs.pulseaudioFull; + }; +} diff --git a/machines/modules/window_manager.nix b/machines/modules/window_manager.nix new file mode 100644 index 0000000..d9c52d1 --- /dev/null +++ b/machines/modules/window_manager.nix @@ -0,0 +1,22 @@ +{ pkgs, ... }: + +{ + services.dbus = { + enable = true; + packages = [ pkgs.dconf ]; + }; + + services.xserver = { + enable = true; + + xkbModel = "pc105"; + layout = "us,us"; + xkbVariant = "dvorak,"; + xkbOptions = "grp:win_space_toggle"; + + displayManager.defaultSession = "none+xmonad"; + windowManager.xmonad.enable = true; + }; + + console.useXkbConfig = true; +}