Initial flake implementation

For now, simply copied current configuration.nix and hardware-configuration.nix
to hostname specific directory.
Made minor modifications to remove input impurity from
hardware-configuration.nix (<nixpkgs> to 4{modulesPath}).
Created flake.nix to import the configuration.nix and just build it.

Referred to this guy : https://github.com/MatthewCroughan/nixcfg
This commit is contained in:
Payas Relekar 2020-11-03 15:41:12 +05:30
parent b97b2f171e
commit 8afac13daa
3 changed files with 392 additions and 0 deletions

18
flake.nix Normal file
View file

@ -0,0 +1,18 @@
{
description = "Payas' NixOS configuration (flake edition)";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs, ... }: {
nixosConfigurations = {
enterprise = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
(import ./hosts/enterprise/configuration.nix)
];
};
};
};
}

View file

@ -0,0 +1,341 @@
#
# NixOS configuration for Enterprise
# Author: Payas
# Machine: MSI GL63
#
{ config, pkgs, ... }:
let
nvidia-offload = pkgs.writeShellScriptBin "nvidia-offload" ''
export __NV_PRIME_RENDER_OFFLOAD=1
export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
export __GLX_VENDOR_LIBRARY_NAME=nvidia
export __VK_LAYER_NV_optimus=NVIDIA_only
exec -a "$0" "$@"
'';
in {
imports = [ # Include the results of the hardware scan.
./hardware-configuration.nix
];
boot.loader = {
efi = {
canTouchEfiVariables = true;
# assuming /boot is the mount point of the EFI partition in NixOS (as the installation section recommends).
# efiSysMountPoint = "/boot";
};
grub = {
devices = [ "nodev" ];
efiSupport = true;
enable = true;
version = 2;
# efiInstallAsRemovable = true;
gfxmodeEfi = "1920x1080";
useOSProber = true;
fsIdentifier = "label";
extraEntries = ''
menuentry "Reboot" {
reboot
}
menuentry "Poweroff" {
halt
}
'';
};
};
fileSystems."/mnt/Data" = {
device = "/dev/sda4";
fsType = "ntfs";
options = [ "rw" "uid=1000" ];
};
networking.hostName = "enterprise"; # Define your hostname.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. Disabled because networking is being handled via networkmanager
networking.networkmanager.enable = true;
hardware.bluetooth.enable = true;
hardware.enableRedistributableFirmware = true;
hardware.acpilight.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.
networking.useDHCP = false;
networking.interfaces.enp3s0.useDHCP = true;
networking.interfaces.wlo1.useDHCP = 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/Kolkata";
# Open ports for KDE Connect
networking.firewall.extraCommands = ''
iptables -I INPUT -i wlo1 -p udp --dport 1714:1764 -m state --state NEW,ESTABLISHED -j ACCEPT && iptables -I INPUT -i wlo1 -p tcp --dport 1714:1764 -m state --state NEW,ESTABLISHED -j ACCEPT && iptables -A OUTPUT -o wlo1 -p udp --sport 1714:1764 -m state --state NEW,ESTABLISHED -j ACCEPT && iptables -A OUTPUT -o wlo1 -p tcp --sport 1714:1764 -m state --state NEW,ESTABLISHED -j ACCEPT
'';
# Reduce stupid systemd shutdown timer so it possibly takes less time next time
systemd.extraConfig = ''
DefaultTimeoutStopSec=10s
'';
# Enable CUPS to print documents.
services.printing.enable = true;
# Enable sound.
sound.enable = true;
hardware.pulseaudio = {
enable = true;
extraModules = [ pkgs.pulseaudio-modules-bt ];
package = pkgs.pulseaudioFull;
};
boot.kernelPackages = pkgs.linuxPackages_latest;
boot.extraModulePackages = [
config.boot.kernelPackages.nvidia_x11_beta
#config.boot.kernelPackages.exfat-nofuse
];
services = {
xserver = {
enable = true;
videoDrivers = [
"nvidia" # "intel" "nvidia"
];
};
};
hardware.nvidia.prime = {
# Bus ID of the Intel GPU. You can find it using lspci, either under 3D or VGA
intelBusId = "PCI:0:2:0";
# Bus ID of the NVIDIA GPU. You can find it using lspci, either under 3D or VGA
nvidiaBusId = "PCI:1:0:0";
sync.enable = false;
offload.enable = true;
};
hardware.opengl.driSupport32Bit = true;
# Enable touchpad support.
services.xserver.libinput.enable = true;
# Enable the KDE Desktop Environment.
services.xserver.displayManager.sddm.enable = true;
services.xserver.desktopManager.plasma5.enable = true;
# Enable tlp for power/battery management
services.tlp.enable = true;
# Activate and set fish shell as default
programs.fish.enable = true;
users.extraUsers.payas = { shell = "/run/current-system/sw/bin/fish"; };
# Define a user account. Don't forget to set a password with passwd.
users.users.payas = {
isNormalUser = true;
extraGroups = [ "wheel" "networkmanager" "adbusers" "docker" "libvirtd" ];
home = "/home/payas";
description = "Payas";
};
# This value determines the NixOS release with which your system is to be
# compatible, in order to avoid breaking some software such as database
# servers. You should change this only after NixOS release notes say you
# should.
system.stateVersion = "19.09"; # Did you read the comment?
# Allow searching and installing proprietory packages
nixpkgs.config.allowUnfree = true;
# Accelerated playback, proprietory codecs etc
nixpkgs.config.packageOverrides = pkgs: {
vaapiIntel = pkgs.vaapiIntel.override { enableHybridCodec = true; };
};
hardware.opengl = {
enable = true;
extraPackages = with pkgs; [
vaapiIntel
vaapiVdpau
libvdpau-va-gl
intel-media-driver
];
};
nix = {
# Enable Flakes systemwide
package = pkgs.nixUnstable;
extraOptions = ''
experimental-features = nix-command flakes
'';
# Automated gabrage collection
gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 15d";
};
# Auto-optimize nix-store, create hard-links to save space on /nix/store
autoOptimiseStore = true;
};
# Fonts
fonts = {
enableDefaultFonts = true;
fonts = with pkgs; [ source-code-pro source-sans-pro source-serif-pro ];
fontconfig = {
defaultFonts = {
monospace = [ "Source Code Pro" ];
sansSerif = [ "Source Code Pro" ];
serif = [ "Source Serif Pro" ];
};
};
};
environment = {
shells = [ "${pkgs.fish}/bin/fish" "${pkgs.bash}/bin/bash" ];
variables = {
BROWSER = pkgs.lib.mkOverride 0 "firefox";
EDITOR = pkgs.lib.mkOverride 0 "kak";
};
systemPackages = with pkgs; [
nvidia-offload
# dev
git
bat
wget
ripgrep
jq
fd
file
htop
du-dust
broot
fzf
thefuck
shellcheck
kakoune-unwrapped
kak-lsp
sublime3
yakuake
kitty
starship # shell-prompt
# Emacs with vterm
((emacsPackagesNgGen emacs).emacsWithPackages (epkgs: [ epkgs.vterm ]))
python3
sqlite # apparently org-roam switched to sqlite
graphviz # added for org-roam
jetbrains.idea-community
#android-studio
openjdk11
# email
aerc
keepassxc
# apps
vlc
strawberry
picard # tag music tracks
firefox
soulseekqt
appimage-run
skype
signal-desktop
# utilities
restic
rsync
rclone
kdeconnect
youtube-dl
ffmpeg-full
qbittorrent
digikam
okular
kcalc
ark
syncthing
syncthingtray
spectacle
gwenview
opusTools
flac
peek # gif screen recorder
libreoffice
snapcast # Audio syncronisation across devices
# personal finance
hledger
hledger-ui
hledger-web
# System
parted
gparted
pciutils
gnome3.gnome-disk-utility
acpi
acpid
acpilight
lsof
# Ops
docker
docker-compose
# virt-manager
virtmanager
xorg.xf86videoqxl
# Nix things
direnv # For use with lorri
nixfmt
nixpkgs-fmt
rnix-lsp
patchelf
niv
texlive.combined.scheme-medium
# experiments
amfora
];
};
programs.adb.enable = true;
programs.java.enable = true;
environment.etc = with pkgs; {
"jdk".source = jdk;
"jdk8".source = jdk8;
"jdk11".source = jdk11;
};
# virtualBox
# virtualisation.virtualbox.host.enable = true;
# users.extraGroups.vboxusers.members = [ "payas" ];
# virtualisation.virtualbox.host.enableExtensionPack = true;
# virt-manager (QEMU/KVM)
virtualisation.libvirtd.enable = true;
boot.kernel.sysctl = { "net.ipv4.ip_forward" = 1; }; # IPv4 NAT networking
# Enable docker service
virtualisation.docker.enable = true;
# Enable lorri : https://github.com/target/lorri
services.lorri.enable = true;
}

View file

@ -0,0 +1,33 @@
# 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, ... }:
# added modulesPath here^ so we can purely access modules path instead of using <>
{
imports =
[ "${modulesPath}/installer/scan/not-detected.nix"
];
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "sd_mod" "rtsx_usb_sdmmc" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/79dd69ba-ea56-4479-a104-14f0ba6776b0";
fsType = "ext4";
};
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/15A2-FD75";
fsType = "vfat";
};
swapDevices =
[ { device = "/dev/disk/by-uuid/fc70026b-8b25-47b1-8190-d6c3d0f12975"; }
];
nix.maxJobs = lib.mkDefault 8;
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
}