Last active
November 12, 2024 02:37
-
-
Save linhxhust/743ed5836b149513b5756bb4ac5be2f5 to your computer and use it in GitHub Desktop.
Nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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, ... }: | |
{ | |
imports = | |
[ # Include the results of the hardware scan. | |
./hardware-configuration.nix | |
]; | |
# Bootloader. | |
boot.loader.systemd-boot.enable = true; | |
boot.supportedFilesystems = [ "ntfs" ]; | |
boot.loader.efi.canTouchEfiVariables = true; | |
# Networking | |
networking.hostName = "nixos"; # Define your hostname. | |
# Or disable the firewall altogether. | |
networking.firewall = { | |
enable = true; | |
trustedInterfaces = [ "tailscale0" ]; | |
# allow connection over tailscale UDP port | |
allowedUDPPorts = [ config.services.tailscale.port ]; | |
}; | |
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. | |
# Enable networking | |
networking.networkmanager.enable = true; | |
# Configure network proxy if necessary | |
# networking.proxy.default = "http://user:password@proxy:port/"; | |
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; | |
# Set your time zone. | |
time.timeZone = "Asia/Ho_Chi_Minh"; | |
# Select internationalisation properties. | |
i18n.inputMethod = { | |
enabled = "fcitx5"; | |
fcitx5.addons = with pkgs; [ | |
fcitx5-mozc | |
fcitx5-gtk | |
]; | |
}; | |
i18n.defaultLocale = "en_US.UTF-8"; | |
i18n.extraLocaleSettings = { | |
LC_ADDRESS = "vi_VN.UTF-8"; | |
LC_IDENTIFICATION = "vi_VN.UTF-8"; | |
LC_MEASUREMENT = "vi_VN.UTF-8"; | |
LC_MONETARY = "vi_VN.UTF-8"; | |
LC_NAME = "vi_VN.UTF-8"; | |
LC_NUMERIC = "vi_VN.UTF-8"; | |
LC_PAPER = "vi_VN.UTF-8"; | |
LC_TELEPHONE = "vi_VN.UTF-8"; | |
LC_TIME = "vi_VN.UTF-8"; | |
}; | |
# Enable the X11 windowing system. | |
services.xserver.enable = true; | |
# Enable ssh with key authentication only | |
services.openssh = { | |
enable = true; | |
# settings.PasswordAuthentication = false; | |
# settings.KbdInteractiveAuthentication = false; | |
}; | |
# Enable the GNOME Desktop Environment. | |
services.xserver.displayManager.gdm.enable = true; | |
services.xserver.desktopManager.gnome.enable = true; | |
# Configure keymap in X11 | |
services.xserver = { | |
layout = "us"; | |
xkbVariant = ""; | |
}; | |
# Enable CUPS to print documents. | |
services.printing.enable = true; | |
# Enable sound with pipewire. | |
sound.enable = true; | |
hardware.pulseaudio.enable = false; | |
security.rtkit.enable = true; | |
services.pipewire = { | |
enable = true; | |
alsa.enable = true; | |
alsa.support32Bit = true; | |
pulse.enable = true; | |
# If you want to use JACK applications, uncomment this | |
#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; | |
}; | |
# Enable touchpad support (enabled default in most desktopManager). | |
# services.xserver.libinput.enable = true; | |
# Define a user account. Don't forget to set a password with ‘passwd’. | |
users.users."liam" = { | |
isNormalUser = true; | |
description = "liam"; | |
extraGroups = [ "networkmanager" "wheel" ]; | |
packages = with pkgs; [ | |
# thunderbird | |
]; | |
openssh.authorizedKeys.keyFiles = [ | |
/home/liam/.ssh/authorized_keys | |
]; | |
}; | |
# Enable automatic login for the user. | |
services.xserver.displayManager.autoLogin.enable = true; | |
services.xserver.displayManager.autoLogin.user = "liam"; | |
services.tailscale.enable = true; | |
virtualisation.docker.rootless = { | |
enable = true; | |
setSocketVariable = true; | |
}; | |
# Workaround for GNOME autologin: https://github.com/NixOS/nixpkgs/issues/103746#issuecomment-945091229 | |
# systemd stuff | |
systemd.services."getty@tty1".enable = false; | |
systemd.services."autovt@tty1".enable = false; | |
# disable gnome auto suspension | |
systemd.targets = { | |
sleep.enable = false; | |
suspend.enable = false; | |
hibernate.enable = false; | |
hybrid-sleep.enable = false; | |
}; | |
# Install firefox. | |
programs.firefox.enable = true; | |
# Allow unfree packages | |
nixpkgs.config.allowUnfree = true; | |
# List packages installed in system profile. To search, run: | |
# $ nix search wget | |
environment.variables = { | |
EDITOR= "vim"; | |
}; | |
environment.interactiveShellInit = '' | |
alias rebuild='nixos-rebuild switch' | |
''; | |
# system packages, app | |
environment.systemPackages = with pkgs; [ | |
wget | |
jq | |
hdparm | |
deluge | |
pkgs.jellyfin | |
pkgs.jellyfin-web | |
pkgs.jellyfin-ffmpeg | |
parted | |
git | |
kitty | |
zsh | |
fish | |
# enable vim with a custom vimrc applied system wide | |
((vim_configurable.override { }).customize{ | |
name = "vim"; | |
vimrcConfig.customRC ='' | |
filetype plugin indent on | |
set number | |
set autoindent | |
set tabstop=2 | |
set shiftwidth=2 | |
set expandtab | |
command W write | |
''; | |
} | |
)]; | |
# 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; | |
# }; | |
# List services that you want to enable: | |
# deluge torrent setup | |
services.deluge = { | |
enable = true; | |
authFile = /etc/deluge/deluge-auth; | |
web = { | |
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 = "23.11"; # Did you read the comment? | |
systemd.services.tailscale-autoconnect = { | |
description = "Automatic connection to Tailscale"; | |
after = ["network-pre.target" "tailscale.service"]; | |
wants = ["network-pre.target" "tailscale.service"]; | |
wantedBy = ["multi-user.target"]; | |
serviceConfig.Type = "oneshot"; | |
script = with pkgs; '' | |
echo "wait for tailscale.service to settle for 5 seconds" | |
sleep 5 | |
echo "checking if tailscail is up" | |
status="${tailscale}/bin/tailscale status -json | ${jq}/bin/jq -r .BackendState" | |
if [ $status = "Running" ]; then | |
exit 0 | |
fi | |
echo "authenticate into tailscale network" | |
${tailscale}/bin/tailscale up --auth-key file:/etc/tailscale/tailscale.key | |
''; | |
}; | |
# jellyfin | |
services.jellyfin = { | |
enable = true; | |
user = "liam"; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment