Skip to content

Instantly share code, notes, and snippets.

@joedicastro
Last active July 20, 2024 22:53
Show Gist options
  • Save joedicastro/a19a9dfd21470783240c739657747f5d to your computer and use it in GitHub Desktop.
Save joedicastro/a19a9dfd21470783240c739657747f5d to your computer and use it in GitHub Desktop.
My NixOS configuration
# 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, ... }:
{
## DISK CONFIGURATION
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];
# Use the GRUB 2 boot loader.
boot.loader.grub.enable = true;
boot.loader.grub.version = 2;
# Define on which hard drive you want to install Grub.
boot.loader.grub.device = "/dev/sda";
# Define which partition is encrypted with LUKS
boot.initrd.luks.devices = [
{
name = "luksroot";
device = "/dev/sda2";
}
];
boot.cleanTmpDir = true;
boot.kernelModules = [ "kvm_intel" "tp_smapi" ];
boot.extraModulePackages = [ config.boot.kernelPackages.tp_smapi ];
## NETWORK
# Define your hostname.
networking.hostName = "ltp";
# Enables wireless support via wpa_supplicant.
networking.wireless.enable = true;
## LOCALIZATION
# Select internationalisation properties.
i18n = {
consoleFont = "Lat2-Terminus16";
consoleKeyMap = "us";
defaultLocale = "en_US.UTF-8";
};
# Set your time zone.
time.timeZone = "Europe/Madrid";
## PACKAGES & ENVIRONMENT
# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
environment = {
enableBashCompletion = true;
variables = {
EDITOR = pkgs.lib.mkOverride 0 "vim";
};
systemPackages = with pkgs; [
acpitool
autocutsel
btrfs-progs
compton
chromium
dmenu
dunst
emacs
f2fs-tools
file
firefox
firejail
git
gparted
htop
imv
libreoffice
libnotify
lm_sensors
luaPackages.vicious
mplayer
meld
mupdf
ncdu
ntfs3g
pciutils
python27Packages.udiskie
ranger
rxvt_unicode
sxiv
smplayer
tmux
tree
unclutter
vimHugeX
vlc
w3m
wget
which
xcape
xfsprogs
xterm
zathura
];
};
nixpkgs.config = {
allowUnfree = true;
};
## SERVICES
# List services that you want to enable:
# Enable the OpenSSH daemon.
# services.openssh.enable = true;
# Enable CUPS to print documents.
services.printing.enable = true;
# Enable locate
services.locate.enable = true;
services.thinkfan.enable = true;
services.acpid.enable = true;
services.redshift = {
enable = true;
latitude = "43.365";
longitude = "-8.41";
temperature.day = 6500;
temperature.night = 2700;
};
services.syncthing = {
enable = true;
user = "joedicastro";
dataDir = "/home/joedicastro/.config/syncthing";
};
## XSERVER
# Enable the X11 windowing system.
services.xserver = {
enable = true;
layout = "us";
xkbOptions = "ctrl:nocaps";
xkbVariant = "altgr-intl";
displayManager.kdm.enable = false;
displayManager.lightdm.enable = true;
displayManager.slim.enable = false;
displayManager.slim.defaultUser = "joedicastro";
displayManager.sessionCommands = ''
xrdb "${pkgs.writeText "xrdb.conf" ''
URxvt.font: xft:Dejavu Sans Mono for Powerline:size=11
XTerm*faceName: xft:Dejavu Sans Mono for Powerline:size=11
XTerm*utf8: 2
URxvt.iconFile: /usr/share/icons/elementary/apps/24/terminal.svg
URxvt.letterSpace: 0
URxvt.background: #121214
URxvt.foreground: #FFFFFF
XTerm*background: #121212
XTerm*foreground: #FFFFFF
! black
URxvt.color0 : #2E3436
URxvt.color8 : #555753
XTerm*color0 : #2E3436
XTerm*color8 : #555753
! red
URxvt.color1 : #CC0000
URxvt.color9 : #EF2929
XTerm*color1 : #CC0000
XTerm*color9 : #EF2929
! green
URxvt.color2 : #4E9A06
URxvt.color10 : #8AE234
XTerm*color2 : #4E9A06
XTerm*color10 : #8AE234
! yellow
URxvt.color3 : #C4A000
URxvt.color11 : #FCE94F
XTerm*color3 : #C4A000
XTerm*color11 : #FCE94F
! blue
URxvt.color4 : #3465A4
URxvt.color12 : #729FCF
XTerm*color4 : #3465A4
XTerm*color12 : #729FCF
! magenta
URxvt.color5 : #75507B
URxvt.color13 : #AD7FA8
XTerm*color5 : #75507B
XTerm*color13 : #AD7FA8
! cyan
URxvt.color6 : #06989A
URxvt.color14 : #34E2E2
XTerm*color6 : #06989A
XTerm*color14 : #34E2E2
! white
URxvt.color7 : #D3D7CF
URxvt.color15 : #EEEEEC
XTerm*color7 : #D3D7CF
XTerm*color15 : #EEEEEC
URxvt*saveLines: 32767
XTerm*saveLines: 32767
URxvt.colorUL: #AED210
URxvt.perl-ext: default,url-select
URxvt.keysym.M-u: perl:url-select:select_next
URxvt.url-select.launcher: /usr/bin/firefox -new-tab
URxvt.url-select.underline: true
Xft*dpi: 96
Xft*antialias: true
Xft*hinting: full
URxvt.scrollBar: false
URxvt*scrollTtyKeypress: true
URxvt*scrollTtyOutput: false
URxvt*scrollWithBuffer: false
URxvt*scrollstyle: plain
URxvt*secondaryScroll: true
Xft.autohint: 0
Xft.lcdfilter: lcddefault
Xft.hintstyle: hintfull
Xft.hinting: 1
Xft.antialias: 1
''}"
'';
windowManager.awesome = {
enable = true;
luaModules = [
pkgs.luaPackages.vicious
];
};
desktopManager.kde4.enable = false;
windowManager.i3.enable = false;
};
fonts = {
enableFontDir = true;
enableGhostscriptFonts = true;
fonts = with pkgs; [
anonymousPro
corefonts
dejavu_fonts
font-droid
freefont_ttf
google-fonts
inconsolata
liberation_ttf
powerline-fonts
source-code-pro
terminus_font
ttf_bitstream_vera
ubuntu_font_family
];
};
## USERS
# Define a user account. Don't forget to set a password with ‘passwd’.
users.extraUsers.joedicastro = {
isNormalUser = true;
uid = 1000;
extraGroups = ["wheel" "vboxusers" "docker"];
};
## SYSTEMD
systemd.user.services."urxvtd" = {
enable = true;
description = "rxvt unicode daemon";
wantedBy = [ "default.target" ];
path = [ pkgs.rxvt_unicode ];
serviceConfig.Restart = "always";
serviceConfig.RestartSec = 2;
serviceConfig.ExecStart = "${pkgs.rxvt_unicode}/bin/urxvtd -q -o";
};
systemd.user.services."xcape" = {
enable = true;
description = "xcape to use CTRL as ESC when pressed alone";
wantedBy = [ "default.target" ];
serviceConfig.Type = "forking";
serviceConfig.Restart = "always";
serviceConfig.RestartSec = 2;
serviceConfig.ExecStart = "${pkgs.xcape}/bin/xcape";
};
systemd.user.services."dunst" = {
enable = true;
description = "";
wantedBy = [ "default.target" ];
serviceConfig.Restart = "always";
serviceConfig.RestartSec = 2;
serviceConfig.ExecStart = "${pkgs.dunst}/bin/dunst";
};
systemd.user.services."unclutter" = {
enable = true;
description = "hide cursor after X seconds idle";
wantedBy = [ "default.target" ];
serviceConfig.Restart = "always";
serviceConfig.RestartSec = 2;
serviceConfig.ExecStart = "${pkgs.unclutter}/bin/unclutter";
};
systemd.user.services."compton" = {
enable = true;
description = "";
wantedBy = [ "default.target" ];
path = [ pkgs.compton ];
serviceConfig.Type = "forking";
serviceConfig.Restart = "always";
serviceConfig.RestartSec = 2;
serviceConfig.ExecStart = "${pkgs.compton}/bin/compton -b --config /home/joedicastro/.compton.conf";
};
systemd.user.services."autocutsel" = {
enable = true;
description = "AutoCutSel";
wantedBy = [ "default.target" ];
serviceConfig.Type = "forking";
serviceConfig.Restart = "always";
serviceConfig.RestartSec = 2;
serviceConfig.ExecStartPre = "${pkgs.autocutsel}/bin/autocutsel -fork";
serviceConfig.ExecStart = "${pkgs.autocutsel}/bin/autocutsel -selection PRIMARY -fork";
};
systemd.user.services."udiskie" = {
enable = true;
description = "udiskie to automount removable media";
wantedBy = [ "default.target" ];
path = with pkgs; [
gnome3.defaultIconTheme
gnome3.gnome_themes_standard
pythonPackages.udiskie
];
environment.XDG_DATA_DIRS="${pkgs.gnome3.defaultIconTheme}/share:${pkgs.gnome3.gnome_themes_standard}/share";
serviceConfig.Restart = "always";
serviceConfig.RestartSec = 2;
serviceConfig.ExecStart = "${pkgs.python27Packages.udiskie}/bin/udiskie -a -t -n -F ";
};
## VIRTUALIZATION
virtualisation.docker.enable = true;
virtualisation.docker.socketActivation = true;
virtualisation.virtualbox.host.enable = true;
## SECURITY
# enable grsecurity, this would take a long time to compile, for a fast
# installation comment this part
# security.grsecurity = {
# enable = true;
# config.hardwarevirtualisation = true;
# config.system = "desktop";
# };
security.setuidPrograms = [ "firejail" ];
## NIXOS
# The NixOS release to be compatible with for stateful data such as databases.
system.stateVersion = "16.03";
}
# 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, ... }:
{
imports =
[ <nixpkgs/nixos/modules/installer/scan/not-detected.nix>
];
boot.initrd.availableKernelModules = [ "uhci_hcd" "ehci_pci" "ahci" "usb_storage" "sd_mod" ];
# boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/7afb616f-d2a6-4801-b011-8098873876c2";
fsType = "ext4";
};
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/be3b9866-05d0-4496-a73c-94519d7fbfd3";
fsType = "ext4";
};
fileSystems."/home" =
{ device = "/dev/disk/by-uuid/2f21c497-7793-49ed-83af-e476792fe4cc";
fsType = "ext4";
};
swapDevices = [ ];
nix.maxJobs = 2;
}
@joedicastro
Copy link
Author

Aún faltan un montonazo de temas por configurar y "problemillas" por resolver:

  • Tengo que instalar aún muchisimos más paquetes "system wide", pero voy instalando y probando, a menos que necesite algo urgente.
  • Aun ni siquiera me he puesto a probar la configuración de Emacs, algo me dice que va a ser todo un reto. La de Vim si me funciona perfectamente.
  • Firefox y Chromium petan si uso el Kernel con grsecurity, lo desactive y lo dejo para otro momento con más tiempo.
  • Firejail me falla de entrada, como no es esencial lo dejo para mirar en otro momento.
  • Udiskie como unit de systemd funciona pero no muestra las notificaciones, ya lo resolvere cuando tenga un rato.
  • Compton como systemd unit se reinicia mucho, pero funciona, no es esencial, ya lo mirare.
  • Virtualbox no me activa los puertos USB > 1.0, se suele solucionar con una variable de entorno, es una chorrrada, pero no me he parado a mirarlo. ACTUALIZADO Hay que instalar el Extension Pack, que parece que tiene su miga... mirando la mejor manera de hacerlo...
  • etc...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment