about summary refs log tree commit diff
path: root/system/modules
diff options
context:
space:
mode:
Diffstat (limited to 'system/modules')
-rw-r--r--system/modules/common.nix106
-rw-r--r--system/modules/emacs.nix23
-rw-r--r--system/modules/reusable/README.org2
-rw-r--r--system/modules/reusable/battery.nix32
-rw-r--r--system/modules/sound.nix14
-rw-r--r--system/modules/xserver.nix19
6 files changed, 196 insertions, 0 deletions
diff --git a/system/modules/common.nix b/system/modules/common.nix
new file mode 100644
index 000000000000..27f4a73f09e9
--- /dev/null
+++ b/system/modules/common.nix
@@ -0,0 +1,106 @@
+{ config, lib, pkgs, ... }:
+
+{
+  imports =
+    [
+      ./xserver.nix
+      ./emacs.nix
+      ./sound.nix
+    ];
+
+  boot.loader.systemd-boot.enable = true;
+  boot.loader.efi.canTouchEfiVariables = true;
+
+  networking.hostName = "bumblebee";
+  networking.useDHCP = false;
+  networking.networkmanager.enable = true;
+
+  # Select internationalisation properties.
+  # i18n = {
+  #   consoleFont = "Lat2-Terminus16";
+  #   consoleKeyMap = "us";
+  #   defaultLocale = "en_US.UTF-8";
+  # };
+
+  # Set your time zone.
+  time.timeZone = "America/New_York";
+
+  environment.systemPackages = with pkgs; [
+    wget
+    vim
+    zsh
+    git
+    w3m
+    libnotify
+    file
+  ];
+
+  # 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;
+  #   pinentryFlavor = "gnome3";
+  # };
+
+  programs.nm-applet.enable = true;
+
+
+  services.openssh.enable = true;
+
+  # Open ports in the firewall.
+  # networking.firewall.allowedTCPPorts = [ ... ];
+  # networking.firewall.allowedUDPPorts = [ ... ];
+  # Or disable the firewall altogether.
+  networking.firewall.enable = false;
+
+  # Enable CUPS to print documents.
+  # services.printing.enable = true;
+
+  users.mutableUsers = true;
+  programs.zsh.enable = true;
+  environment.pathsToLink = [ "/share/zsh" ];
+  users.users.grfn = {
+    isNormalUser = true;
+    initialPassword = "password";
+    extraGroups = [
+      "wheel"  # Enable ‘sudo’ for the user.
+      "networkmanager"
+      "audio"
+    ];
+    shell = pkgs.zsh;
+  };
+
+  # 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 = "20.03"; # Did you read the comment?
+
+  nixpkgs.config.allowUnfree = true;
+
+  fonts.fonts = with pkgs; [
+    nerdfonts
+  ];
+
+  services.geoclue2.enable = true;
+
+  powerManagement = {
+    enable = true;
+    cpuFreqGovernor = "powersave";
+    powertop.enable = true;
+  };
+  # Hibernate on low battery
+  laptop.onLowBattery = {
+    enable = true;
+    action = "hibernate";
+    thresholdPercentage = 5;
+  };
+
+  nix = {
+    autoOptimiseStore = true;
+  };
+}
diff --git a/system/modules/emacs.nix b/system/modules/emacs.nix
new file mode 100644
index 000000000000..1cfa2b07452c
--- /dev/null
+++ b/system/modules/emacs.nix
@@ -0,0 +1,23 @@
+{ config, pkgs, lib, ... }:
+with lib;
+{
+  options.programs.emacs.useGit = mkOption {
+    description = "Use emacs from git";
+    type = types.bool;
+    default = false;
+  };
+
+  config = {
+    nixpkgs.overlays = if config.programs.emacs.useGit then [] else [
+      (import (builtins.fetchTarball https://github.com/nix-community/emacs-overlay/archive/master.tar.gz))
+    ];
+
+    environment.systemPackages = with pkgs; [
+      (if config.programs.emacs.useGit then emacsGit else emacs)
+      ripgrep
+      coreutils
+      fd
+      clang
+    ];
+  };
+}
diff --git a/system/modules/reusable/README.org b/system/modules/reusable/README.org
new file mode 100644
index 000000000000..34d9bfdcb729
--- /dev/null
+++ b/system/modules/reusable/README.org
@@ -0,0 +1,2 @@
+This directory contains things I'm eventually planning on contributing upstream
+to nixpkgs
diff --git a/system/modules/reusable/battery.nix b/system/modules/reusable/battery.nix
new file mode 100644
index 000000000000..d7043bf54979
--- /dev/null
+++ b/system/modules/reusable/battery.nix
@@ -0,0 +1,32 @@
+{ config, lib, pkgs, ... }:
+with lib;
+{
+  options = {
+    laptop.onLowBattery = {
+      enable = mkEnableOption "Perform action on low battery";
+
+      thresholdPercentage = mkOption {
+        description = "Threshold battery percentage on which to perform the action";
+        default = 5;
+        type = types.int;
+      };
+
+      action = mkOption {
+        description = "Action to perform on low battery";
+        default = "hibernate";
+        type = types.enum [ "hibernate" "suspend" "suspend-then-hibernate" ];
+      };
+    };
+  };
+
+  config =
+    let cfg = config.laptop.onLowBattery;
+    in mkIf cfg.enable {
+    services.udev.extraRules = concatStrings [
+      ''SUBSYSTEM=="power_supply", ''
+      ''ATTR{status}=="Discharging", ''
+      ''ATTR{capacity}=="[0-${toString cfg.thresholdPercentage}]", ''
+      ''RUN+="/${pkgs.systemd}/bin/systemctl ${cfg.action}"''
+    ];
+  };
+}
diff --git a/system/modules/sound.nix b/system/modules/sound.nix
new file mode 100644
index 000000000000..0d5ce3e318c3
--- /dev/null
+++ b/system/modules/sound.nix
@@ -0,0 +1,14 @@
+{ config, lib, pkgs, ... }:
+{
+  # Enable sound.
+  sound.enable = true;
+  hardware.pulseaudio.enable = true;
+  nixpkgs.config.pulseaudio = true;
+
+  environment.systemPackages = with pkgs; [
+    pulseaudio-ctl
+    paprefs
+    pasystray
+    pavucontrol
+  ];
+}
diff --git a/system/modules/xserver.nix b/system/modules/xserver.nix
new file mode 100644
index 000000000000..52f04e2e6a69
--- /dev/null
+++ b/system/modules/xserver.nix
@@ -0,0 +1,19 @@
+{ config, pkgs, ... }:
+{
+  # Enable the X11 windowing system.
+  services.xserver = {
+    enable = true;
+    layout = "us";
+    xkbOptions = "caps:swapescape";
+
+    libinput.enable = true;
+
+    windowManager.i3 = {
+      enable = true;
+      extraPackages = with pkgs; [
+        i3status
+        i3lock
+      ];
+    };
+  };
+}