about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2021-06-10 15:34:49 +0700
committerNguyễn Gia Phong <mcsinyx@disroot.org>2021-06-10 15:34:49 +0700
commit7744ecfaacc668d75ac0d4d458d95e7d549a826f (patch)
treed833a128037f5a1807c417d86d92d6bc95987a62
parent9ec5278c3faffaf8b861cb89b89ec344a88471d9 (diff)
downloaddotfiles-7744ecfaacc668d75ac0d4d458d95e7d549a826f.tar.gz
Set up NixOS
-rw-r--r--.gitignore8
-rw-r--r--nix/etc/nixos/awesome.nix39
-rw-r--r--nix/etc/nixos/configuration.nix85
-rw-r--r--nix/etc/nixos/devel.nix23
-rw-r--r--nix/etc/nixos/games.nix19
-rw-r--r--nix/etc/nixos/hardware-configuration.nix43
-rw-r--r--nixos/.Xdefaults32
-rw-r--r--nixos/.bashrc67
l---------nixos/.config/systemd/user/default.target.wants/mbsync-legacy.timer1
l---------nixos/.config/systemd/user/default.target.wants/mbsync-primary.timer1
-rw-r--r--nixos/.config/systemd/user/default.target.wants/redshift.service0
-rw-r--r--nixos/.config/systemd/user/mbsync-legacy.service12
-rw-r--r--nixos/.config/systemd/user/mbsync-legacy.timer11
-rw-r--r--nixos/.config/systemd/user/mbsync-primary.service12
-rw-r--r--nixos/.config/systemd/user/mbsync-primary.timer11
-rw-r--r--nixos/.profile23
-rw-r--r--nixos/.xinitrc11
17 files changed, 394 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index 73f7d24..424f9c7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,7 @@
+.uuid
+__pycache__
+audio/.config/pulse/cookie
+nix/etc/nixos/redshift.nix
 vim/.cache/vim
 vim/.vim/.netrwhist
 vim/.vim/plugged
-nix/.config/gtk-3.0/settings.ini
-nix/.gtkrc-2.0
-__pycache__
-.uuid
diff --git a/nix/etc/nixos/awesome.nix b/nix/etc/nixos/awesome.nix
new file mode 100644
index 0000000..25e639e
--- /dev/null
+++ b/nix/etc/nixos/awesome.nix
@@ -0,0 +1,39 @@
+{ pkgs, ... }:
+
+{
+  imports = [ ./redshift.nix ];
+
+  fonts.fonts = with pkgs; [ lmodern ];
+
+  services = {
+    autorandr.enable = true;
+    xserver = {
+      enable = true;
+      displayManager.startx.enable = true;
+      windowManager.awesome.enable = true;
+
+      layout = "us";
+      xkbOptions = "caps:ctrl_modifier,compose:menu";
+      libinput.enable = true; # Enable touchpad support.
+    };
+  };
+
+  i18n = {
+    defaultLocale = "en_US.UTF-8";
+    inputMethod = {
+      enabled = "ibus";
+      ibus.engines = with pkgs.ibus-engines; [ table table-others ];
+    };
+  };
+
+  environment.systemPackages = with pkgs; [
+    gnome.adwaita-icon-theme qt5ct
+    gnome.networkmanagerapplet mate.mate-power-manager playerctl pulsemixer
+    rxvt_unicode-with-plugins urxvt_autocomplete_all_the_things urxvt_font_size
+    aerc amfora autocutsel firefox keynav newsboat ranger
+    arandr audacious gimp scrot vim_configurable
+  ];
+
+  programs.nm-applet.enable = true;
+  programs.slock.enable = true;
+}
diff --git a/nix/etc/nixos/configuration.nix b/nix/etc/nixos/configuration.nix
new file mode 100644
index 0000000..7e6e108
--- /dev/null
+++ b/nix/etc/nixos/configuration.nix
@@ -0,0 +1,85 @@
+# Help is available in the configuration.nix(5) man page
+# and in the NixOS manual (accessible by running 'nixos-help').
+
+{ config, pkgs, ... }:
+
+{
+  imports = [
+    ./hardware-configuration.nix
+    ./awesome.nix
+    ./devel.nix
+    ./games.nix
+  ];
+
+  # Use the systemd-boot EFI boot loader.
+  boot.loader = {
+    systemd-boot.enable = true;
+    efi.canTouchEfiVariables = true;
+    grub.useOSProber = true;
+  };
+
+  networking = {
+    hostName = "nix";
+    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;
+    interfaces.enp1s0.useDHCP = true;
+    interfaces.wlp2s0.useDHCP = true;
+
+    # Configure network proxy if necessary
+    # proxy.default = "http://user:password@proxy:port/";
+    # proxy.noProxy = "127.0.0.1,localhost,internal.domain";
+
+    # Open ports in the firewall.
+    # firewall.allowedTCPPorts = [ ... ];
+    # firewall.allowedUDPPorts = [ ... ];
+    # Or disable the firewall altogether.
+    # firewall.enable = false;
+  };
+
+  # Set your time zone.
+  time.timeZone = "Asia/Ho_Chi_Minh";
+
+  # Select internationalisation properties.
+  # console = {
+  #   font = "Lat2-Terminus16";
+  #   keyMap = "us";
+  # };
+
+  users.users.sea = {
+    isNormalUser = true;
+    extraGroups = [ "networkmanager" "wheel" ];
+  };
+
+  environment.systemPackages = with pkgs; [
+    htop isync killall oathToolkit rsync stow w3m wget
+    ffmpeg mpv pavucontrol pqiv
+  ];
+
+  # List services that you want to enable:
+  services.printing.enable = true;
+
+  security.rtkit.enable = true;
+  services.pipewire = {
+    enable = true;
+    alsa.enable = true;
+    alsa.support32Bit = true;
+    pulse.enable = true;
+    jack.enable = true;
+
+    # Use the example session manager (no others are packaged yet so this is
+    # enabled by default, no need to redefine it in your config for now)
+    # media-session.enable = 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 = "21.05"; # Did you read the comment?
+}
diff --git a/nix/etc/nixos/devel.nix b/nix/etc/nixos/devel.nix
new file mode 100644
index 0000000..86c842c
--- /dev/null
+++ b/nix/etc/nixos/devel.nix
@@ -0,0 +1,23 @@
+{ pkgs, ... }:
+
+{
+  environment.systemPackages = with pkgs; [
+    exa fd git ripgrep
+    clojure guile leiningen python3 rakudo zig
+    texlive.combined.scheme-tetex
+  ];
+
+  programs.mtr.enable = true;
+  programs.gnupg.agent = {
+    enable = true;
+    enableSSHSupport = true;
+  };
+
+  services = {
+    # openssh.enable = true;
+    ipfs = {
+      enable = true;
+      dataDir = "/data/IPFS";
+    };
+  };
+}
diff --git a/nix/etc/nixos/games.nix b/nix/etc/nixos/games.nix
new file mode 100644
index 0000000..3a48dc4
--- /dev/null
+++ b/nix/etc/nixos/games.nix
@@ -0,0 +1,19 @@
+{ config, pkgs, ... }:
+
+{
+  nixpkgs.config.allowUnfree = true;
+
+  environment.systemPackages = with pkgs; [
+    _20kly hedgewars globulation2 scorched3d teeworlds # strategy
+    astromenace chromium-bsu # scrolling
+    azimuth cdogs-sdl taisei # shmup
+    bastet moon-buggy n2048 # text
+    blackshades redeclipse warsow xonotic-glx # fps
+    blobwars openclonk sienna superTux # platformer
+    bonzomatic # edu
+    extremetuxracer gl117 gltron superTuxKart # vehicle
+    flare freedroidrpg hyperrogue # slash
+    frozen-bubble gnujump gtetrinet pinball xbill # coffeebreak
+    neverball orthorobot trackballs # puzzle
+  ];
+}
diff --git a/nix/etc/nixos/hardware-configuration.nix b/nix/etc/nixos/hardware-configuration.nix
new file mode 100644
index 0000000..9ac7c6c
--- /dev/null
+++ b/nix/etc/nixos/hardware-configuration.nix
@@ -0,0 +1,43 @@
+# Do not modify this file!  It was generated by ‘nixos-generate-config’
+# and may be overwritten by future invocations.  Please make changes
+# to /etc/nixos/configuration.nix instead.
+{ config, lib, pkgs, modulesPath, ... }:
+
+{
+  imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
+
+  boot.initrd.availableKernelModules = [
+    "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" "rtsx_pci_sdmmc"
+  ];
+  boot.initrd.kernelModules = [ ];
+  boot.kernelModules = [ "kvm-intel" ];
+  boot.extraModulePackages = [ ];
+
+  fileSystems = {
+    "/" = {
+      device = "/dev/disk/by-uuid/34058769-4280-4374-ad92-259554380a9e";
+      fsType = "ext4";
+    };
+
+    "/boot" = {
+      device = "/dev/disk/by-uuid/8EB8-6EDD";
+      fsType = "vfat";
+    };
+
+    "/home" = {
+      device = "/dev/disk/by-uuid/69991f9d-8fec-4b32-8e3e-83d6a2c64257";
+      fsType = "ext4";
+    };
+
+    "/data" = {
+      device = "/dev/disk/by-uuid/02594f2b-d681-49fc-8f4a-0616d44c8987";
+      fsType = "ext4";
+    };
+  };
+
+  swapDevices = [
+    { device = "/dev/disk/by-uuid/6f45a147-3b44-4eb9-8ac3-2201e80cff5e"; }
+  ];
+
+  powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
+}
diff --git a/nixos/.Xdefaults b/nixos/.Xdefaults
new file mode 100644
index 0000000..1a3cfc1
--- /dev/null
+++ b/nixos/.Xdefaults
@@ -0,0 +1,32 @@
+*.cursorColor:  #fce8c3
+*.pointerColor: #fce8c3
+*.foreground:   #fce8c3
+*.background:   #1c1b19
+*.color0:       #1c1b19
+*.color1:       #ef2f27
+*.color2:       #519f50
+*.color3:       #fbb829
+*.color4:       #2c78bf
+*.color5:       #e02c6d
+*.color6:       #0aaeb3
+*.color7:       #d0bfa1
+*.color8:       #918175
+*.color9:       #f75341
+*.color10:      #98bc37
+*.color11:      #fed06e
+*.color12:      #68A8E4
+*.color13:      #ff5c8f
+*.color14:      #53fde9
+*.color15:      #fce8c3
+
+URxvt.loginShell:   true
+URxvt.scrollBar:    false
+URxvt.saveLines:    65535
+URxvt.cursorBlink:  false
+URxvt.visualBell:   true
+URxvt.jumpScroll:   true
+
+URxvt.font: xft:Latin Modern Mono:size=15:autohint=true
+URxvt.termName: rxvt-unicode-256color
+URxvt.perl-ext-common: default,font-size
+URxvt.font-size.step: 1
diff --git a/nixos/.bashrc b/nixos/.bashrc
new file mode 100644
index 0000000..c05cab9
--- /dev/null
+++ b/nixos/.bashrc
@@ -0,0 +1,67 @@
+# ~/.bashrc: executed by bash(1) for non-login shells.
+# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
+# for examples
+
+# If not running interactively, don't do anything
+[[ $- != *i* ]] && return
+
+# don't put duplicate lines or lines starting with space in the history.
+# See bash(1) for more options
+HISTCONTROL=ignoreboth
+
+# append to the history file, don't overwrite it
+shopt -s histappend
+
+# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
+HISTSIZE=32767
+HISTFILESIZE=65536
+
+# check the window size after each command and, if necessary,
+# update the values of LINES and COLUMNS.
+shopt -s checkwinsize
+
+# If set, the pattern "**" used in a pathname expansion context will
+# match all files and zero or more directories and subdirectories.
+shopt -s globstar
+
+# make less more friendly for non-text input files, see lesspipe(1)
+[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
+
+# some more ls aliases
+alias ll='exa -l'
+alias la='exa -a'
+
+# Alias definitions.
+# You may want to put all your additions into a separate file like
+# ~/.bash_aliases, instead of adding them here directly.
+# See /usr/share/doc/bash-doc/examples in the bash-doc package.
+alias l='$(fc -ln -1) | less -r'
+alias r=ranger
+alias gcc='gcc -Wall -Wextra -pedantic -O2 -lm'
+alias g++='g++ -Wall -Wextra -pedantic -O2 -lm'
+alias x='cd $HOME && startx && cd -'
+alias backup='rsync -avh --delete /home/ /data/Home/'
+
+function ipfs-cors {
+  ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://127.0.0.1:8000", "http://127.0.0.1:5001", "https://webui.ipfs.io"]'
+  ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST"]'
+  systemctl restart --user ipfs
+}
+
+# enable programmable completion features (you don't need to enable
+# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
+# sources /etc/bash.bashrc).
+if ! shopt -oq posix; then
+  if [ -f /usr/share/bash-completion/bash_completion ]; then
+    . /usr/share/bash-completion/bash_completion
+  elif [ -f /etc/bash_completion ]; then
+    . /etc/bash_completion
+  fi
+fi
+
+stty -ixon
+# emacs input
+set -o emacs
+
+export EDITOR=vim
+export PAGER='less -r'
diff --git a/nixos/.config/systemd/user/default.target.wants/mbsync-legacy.timer b/nixos/.config/systemd/user/default.target.wants/mbsync-legacy.timer
new file mode 120000
index 0000000..d6a74a0
--- /dev/null
+++ b/nixos/.config/systemd/user/default.target.wants/mbsync-legacy.timer
@@ -0,0 +1 @@
+/home/sea/.config/systemd/user/mbsync-legacy.timer
\ No newline at end of file
diff --git a/nixos/.config/systemd/user/default.target.wants/mbsync-primary.timer b/nixos/.config/systemd/user/default.target.wants/mbsync-primary.timer
new file mode 120000
index 0000000..fdf6883
--- /dev/null
+++ b/nixos/.config/systemd/user/default.target.wants/mbsync-primary.timer
@@ -0,0 +1 @@
+/home/sea/.config/systemd/user/mbsync-primary.timer
\ No newline at end of file
diff --git a/nixos/.config/systemd/user/default.target.wants/redshift.service b/nixos/.config/systemd/user/default.target.wants/redshift.service
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/nixos/.config/systemd/user/default.target.wants/redshift.service
diff --git a/nixos/.config/systemd/user/mbsync-legacy.service b/nixos/.config/systemd/user/mbsync-legacy.service
new file mode 100644
index 0000000..e0954de
--- /dev/null
+++ b/nixos/.config/systemd/user/mbsync-legacy.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Synchronize IMAP and MailDir for legacy account
+Documentation=man:mbsync(1)
+ConditionPathExists=%h/.mbsyncrc
+After=network.target
+
+[Service]
+ExecStart=/usr/bin/mbsync legacy
+Type=oneshot
+
+[Install]
+WantedBy=default.target
diff --git a/nixos/.config/systemd/user/mbsync-legacy.timer b/nixos/.config/systemd/user/mbsync-legacy.timer
new file mode 100644
index 0000000..3ea535a
--- /dev/null
+++ b/nixos/.config/systemd/user/mbsync-legacy.timer
@@ -0,0 +1,11 @@
+[Unit]
+Description=Timer for legacy accound mbsync
+ConditionPathExists=%h/.mbsyncrc
+After=network.target
+
+[Timer]
+OnBootSec=1m
+OnUnitInactiveSec=1m
+
+[Install]
+WantedBy=default.target
diff --git a/nixos/.config/systemd/user/mbsync-primary.service b/nixos/.config/systemd/user/mbsync-primary.service
new file mode 100644
index 0000000..8ce0e6f
--- /dev/null
+++ b/nixos/.config/systemd/user/mbsync-primary.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Synchronize IMAP and MailDir for primary account
+Documentation=man:mbsync(1)
+ConditionPathExists=%h/.mbsyncrc
+After=network.target
+
+[Service]
+ExecStart=/usr/bin/mbsync primary
+Type=oneshot
+
+[Install]
+WantedBy=default.target
diff --git a/nixos/.config/systemd/user/mbsync-primary.timer b/nixos/.config/systemd/user/mbsync-primary.timer
new file mode 100644
index 0000000..a0f4151
--- /dev/null
+++ b/nixos/.config/systemd/user/mbsync-primary.timer
@@ -0,0 +1,11 @@
+[Unit]
+Description=Timer for primary accound mbsync
+ConditionPathExists=%h/.mbsyncrc
+After=network.target
+
+[Timer]
+OnBootSec=1m
+OnUnitInactiveSec=1m
+
+[Install]
+WantedBy=default.target
diff --git a/nixos/.profile b/nixos/.profile
new file mode 100644
index 0000000..9de9eb7
--- /dev/null
+++ b/nixos/.profile
@@ -0,0 +1,23 @@
+# ~/.profile: executed by the command interpreter for login shells.
+# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
+# exists.
+# see /usr/share/doc/bash/examples/startup-files for examples.
+# the files are located in the bash-doc package.
+
+# the default umask is set in /etc/profile; for setting the umask
+# for ssh logins, install and configure the libpam-umask package.
+#umask 022
+
+export PATH="$HOME/.local/bin:$PATH"
+export MANPATH="$HOME/.local/share/man:$MANPATH"
+export XMODIFIERS=@im=ibus
+export QT_IM_MODULE=ibus
+export QT_QPA_PLATFORMTHEME=qt5ct
+
+# if running bash
+if [ -n "$BASH_VERSION" ]; then
+    # include .bashrc if it exists
+    if [ -f "$HOME/.bashrc" ]; then
+        . "$HOME/.bashrc"
+    fi
+fi
diff --git a/nixos/.xinitrc b/nixos/.xinitrc
new file mode 100644
index 0000000..bb3847e
--- /dev/null
+++ b/nixos/.xinitrc
@@ -0,0 +1,11 @@
+#!/bin/sh
+mate-power-manager &
+ibus-daemon -drx
+nm-applet &
+keynav &
+audacious &
+autocutsel -fork
+autocutsel -selection PRIMARY -fork
+#diodon &
+autorandr --change
+exec awesome