From 099ef49629eca7169187f6b40dd319e6b0ab5173 Mon Sep 17 00:00:00 2001 From: tootbrute Date: Sun, 10 Nov 2024 15:47:39 +0800 Subject: [PATCH] initial try that failed --- base.nix | 164 ++++++++++++++++++++++++++++ bluenix/configuration.nix | 47 ++++++++ bluenix/hardware-configuration.nix | 40 +++++++ flake.lock | 48 ++++++++ flake.nix | 51 +++++++++ fonts.nix | 21 ++++ gnome.nix | 49 +++++++++ greynix/configuration.nix | 53 +++++++++ greynix/hardware-configuration.nix | 42 +++++++ home.nix | 170 +++++++++++++++++++++++++++++ systemd.nix | 26 +++++ 11 files changed, 711 insertions(+) create mode 100644 base.nix create mode 100644 bluenix/configuration.nix create mode 100644 bluenix/hardware-configuration.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 fonts.nix create mode 100644 gnome.nix create mode 100644 greynix/configuration.nix create mode 100644 greynix/hardware-configuration.nix create mode 100644 home.nix create mode 100644 systemd.nix diff --git a/base.nix b/base.nix new file mode 100644 index 0000000..dc3cbed --- /dev/null +++ b/base.nix @@ -0,0 +1,164 @@ +{ config, pkgs, ... }: + +{ + imports = + [ # I do imports in flakes + ./gnome.nix + ./systemd.nix + ./fonts.nix + ]; + + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + boot.loader.grub.configurationLimit = 10; + + # Clear /tmp during boot + boot.tmp.cleanOnBoot = true; + + # Housekeeping: Garbage collection + nix.optimise.automatic = true; + + nix.gc = { + automatic = true; + dates = "daily"; + options = "--delete-older-than 7d"; + }; + + # Enable networking + networking.networkmanager.enable = true; + + # Disable sudo password for the wheel group + security.sudo.wheelNeedsPassword = false; + + # Set your time zone. + time.timeZone = "Asia/Taipei"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + i18n.supportedLocales = [ "en_US.UTF-8/UTF-8" "zh_CN.UTF-8/UTF-8" "zh_TW.UTF-8/UTF-8" ]; + + i18n.extraLocaleSettings = { + LC_ADDRESS = "en_US.UTF-8"; + LC_IDENTIFICATION = "en_US.UTF-8"; + LC_MEASUREMENT = "en_US.UTF-8"; + LC_MONETARY = "en_US.UTF-8"; + LC_NAME = "en_US.UTF-8"; + LC_NUMERIC = "en_US.UTF-8"; + LC_PAPER = "en_US.UTF-8"; + LC_TELEPHONE = "en_US.UTF-8"; + LC_TIME = "en_US.UTF-8"; + }; + + i18n.inputMethod = { + type = "fcitx5"; + fcitx5.addons = with pkgs; [ fcitx5-chewing fcitx5-chinese-addons ]; + }; + + # Enable the X11 windowing system. + services.xserver.enable = true; + + # Enable the GNOME Desktop Environment. + services.xserver.displayManager.gdm.enable = true; + services.xserver.desktopManager.gnome.enable = true; + # remove xterm + services.xserver.excludePackages = [ pkgs.xterm ]; + services.xserver.desktopManager.xterm.enable = false; + + # Configure keymap in X11 + services.xserver.xkb = { + layout = "us"; + variant = ""; + }; + + # Enable CUPS to print documents. + services.printing.enable = false; + + # Enable sound with pipewire. + 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 > + # no need to redefine it in your config for now) + #media-session.enable = true; + }; + + # Enable automatic login for the user. + services.displayManager.autoLogin.enable = true; + services.displayManager.autoLogin.user = "elias"; + + # Workaround for GNOME autologin: https://github.com/NixOS/nixpk> + systemd.services."getty@tty1".enable = false; + systemd.services."autovt@tty1".enable = false; + + # PROGRAMS + # ================ + # Install Firefox. + programs.firefox.enable = true; + + # Install KDE Connect + programs.kdeconnect.enable = true; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + # List packages installed in system profile. To search, run: + # $ nix search wget + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + environment.systemPackages = with pkgs; [ + # vim # Do not forget to add an editor to edit configuration.ni> + wget + curl + nvtopPackages.full + iotas + fastfetch + curl + keepassxc + git + nextcloud-client + libreoffice-fresh + hunspell #dictionaries for libreoffice + hunspellDicts.en_CA + hunspellDicts.en_US + btop + restic + kdePackages.kdenlive + mediainfo #something for kdenlive + audacity + ]; + + # Accelerated Video Playback + nixpkgs.config.packageOverrides = pkgs: { + intel-vaapi-driver = pkgs.intel-vaapi-driver.override { enableHybridCodec = true; }; + }; + + hardware.graphics = { + enable = true; + extraPackages = with pkgs; [ + intel-media-driver # LIBVA_DRIVER_NAME=iHD + intel-vaapi-driver # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium) + libvdpau-va-gl + ]; + }; + environment.sessionVariables = { LIBVA_DRIVER_NAME = "iHD"; }; # Force intel-media-driver + + # Services + # ========================= + + # Enable OpenSSH + services.openssh.enable = true; + + # Enable Flatpak + services.flatpak.enable = true; + + # Enable Tailscale + services.tailscale.enable = true; + +} diff --git a/bluenix/configuration.nix b/bluenix/configuration.nix new file mode 100644 index 0000000..be6010e --- /dev/null +++ b/bluenix/configuration.nix @@ -0,0 +1,47 @@ +# 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’). + +# BLUENIX CONFIG FILE + +{ config, pkgs, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + zramSwap.enable = true; + + networking.hostName = "bluenix"; # Define your hostname. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # 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.elias = { + isNormalUser = true; + description = "Elias Gasparis"; + extraGroups = [ "networkmanager" "wheel"]; + packages = with pkgs; [ + # thunderbird + ]; + }; + + # Open ports in the firewall. + networking.firewall.allowedTCPPorts = [ 22 ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; + + # 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 = "24.05"; # Did you read the comment? + +} diff --git a/bluenix/hardware-configuration.nix b/bluenix/hardware-configuration.nix new file mode 100644 index 0000000..49f9707 --- /dev/null +++ b/bluenix/hardware-configuration.nix @@ -0,0 +1,40 @@ +# 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" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/9bd500b5-1d06-4ccf-b7c2-5338e8555a5a"; + fsType = "ext4"; + }; + + boot.initrd.luks.devices."luks-6cfc6952-9e66-4e10-b181-97278f99bf2f".device = "/dev/disk/by-uuid/6cfc6952-9e66-4e10-b181-97278f99bf2f"; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/4F9E-9FFF"; + fsType = "vfat"; + options = [ "fmask=0077" "dmask=0077" ]; + }; + + swapDevices = [ ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp2s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c9c4de9 --- /dev/null +++ b/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1730837930, + "narHash": "sha256-0kZL4m+bKBJUBQse0HanewWO0g8hDdCvBhudzxgehqc=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "2f607e07f3ac7e53541120536708e824acccfaa8", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1730785428, + "narHash": "sha256-Zwl8YgTVJTEum+L+0zVAWvXAGbWAuXHax3KzuejaDyo=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "4aa36568d413aca0ea84a1684d2d46f55dbabad7", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..95143ca --- /dev/null +++ b/flake.nix @@ -0,0 +1,51 @@ +{ + description = "NixOS configuration"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager.url = "github:nix-community/home-manager"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = inputs@{ nixpkgs, home-manager, ... }: { + nixosConfigurations = { + # greynix - Gray Asus machine + greynix = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + /home/elias/nixos-config/base.nix + /home/elias/nixos-config/greynix/configuration.nix + + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.elias = import /home/elias/nixos-config/home.nix; + + # Optionally, use home-manager.extraSpecialArgs to pass + # arguments to home.nix + } + ]; + # bluenix - Blue Acer machine + bluenix = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + /home/elias/nixos-config/base.nix + /home/elias/nixos-config/bluenix/configuration.nix + + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.elias = import /home/elias/nixos-config/home.nix; + + # Optionally, use home-manager.extraSpecialArgs to pass + # arguments to home.nix + } + ]; + }; + }; + }; +}; + +} diff --git a/fonts.nix b/fonts.nix new file mode 100644 index 0000000..ea4dcd8 --- /dev/null +++ b/fonts.nix @@ -0,0 +1,21 @@ +{ config, pkgs, ... }: + +{ + # Fonts + fonts.packages = with pkgs; [ + corefonts + vistafonts + noto-fonts + noto-fonts-cjk-sans + noto-fonts-cjk-serif + noto-fonts-emoji + liberation_ttf + fira-code + fira-code-symbols + mplus-outline-fonts.githubRelease + dina-font + proggyfonts + ]; + + fonts.fontDir.enable = true; +} diff --git a/gnome.nix b/gnome.nix new file mode 100644 index 0000000..16b0ae0 --- /dev/null +++ b/gnome.nix @@ -0,0 +1,49 @@ +{ config, pkgs, lib, ... }: + +{ + + # Auto unlock gnome keyring + services.gnome.gnome-keyring.enable = true; + security.pam.services.sddm.enableGnomeKeyring = true; + + # Remove default packages from GNOME + environment.gnome.excludePackages = with pkgs; [ + baobab # disk usage analyzer + cheese # photo booth + eog # image viewer + epiphany # web browser + #gedit # text editor + simple-scan # document scanner + totem # video player + yelp # help viewer + evince # document viewer + file-roller # archive manager + geary # email client + seahorse # password manager + gnome-contacts + gnome-weather + gnome-maps + gnome-music + gnome-software + gnome-extension-manager + gnome-shell-extensions + gnome-photos + gnome-connections + snapshot + gnome-logs + gnome-system-monitor + gnome-calculator + gnome-tour + ]; + + environment.systemPackages = with pkgs; [ + #Gnome tweak tools + gnome-tweaks + gnomeExtensions.appindicator + gnomeExtensions.caffeine + gnomeExtensions.gsconnect + gnomeExtensions.hot-edge + gnomeExtensions.alphabetical-app-grid + ]; + +} diff --git a/greynix/configuration.nix b/greynix/configuration.nix new file mode 100644 index 0000000..4e6243a --- /dev/null +++ b/greynix/configuration.nix @@ -0,0 +1,53 @@ +# 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’). + +# configuration.nix + +{ config, pkgs, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + boot.initrd.luks.devices."luks-880424d4-ac69-44cf-aa3b-99a224128551".device = "/dev/disk/by-uuid/880424d4-ac69-44cf-aa3b-99a224128551"; + networking.hostName = "greynix"; # Define your hostname. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # 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.elias = { + isNormalUser = true; + description = "Elias Gasparis"; + extraGroups = [ "networkmanager" "wheel" "libvirtd" ]; + packages = with pkgs; [ + # thunderbird + ]; + }; + + # Services: + # ===================================== + + # Virtualization for VMs + virtualisation.libvirtd.enable = true; + programs.virt-manager.enable = true; + + # Open ports in the firewall. + networking.firewall.allowedTCPPorts = [ 22 ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; + + # 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 = "24.05"; # Did you read the comment? + +} diff --git a/greynix/hardware-configuration.nix b/greynix/hardware-configuration.nix new file mode 100644 index 0000000..49e6558 --- /dev/null +++ b/greynix/hardware-configuration.nix @@ -0,0 +1,42 @@ +# 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 = [ "vmd" "xhci_pci" "ahci" "nvme" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/7f9595fb-2076-4f33-8834-ce8485bfc56f"; + fsType = "ext4"; + }; + + boot.initrd.luks.devices."luks-1ead6344-6826-436d-9ff8-daa75571966a".device = "/dev/disk/by-uuid/1ead6344-6826-436d-9ff8-daa75571966a"; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/7361-5788"; + fsType = "vfat"; + options = [ "fmask=0077" "dmask=0077" ]; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/f529a3f7-ceb2-453c-99b3-583e84cf4172"; } + ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.wlo1.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/home.nix b/home.nix new file mode 100644 index 0000000..bc60d4a --- /dev/null +++ b/home.nix @@ -0,0 +1,170 @@ +{ config, pkgs, ... }: + +{ + home.username = "elias"; + home.homeDirectory = "/home/elias"; + + # link the configuration file in current directory to the specified location in home directory + # home.file.".config/i3/wallpaper.jpg".source = ./wallpaper.jpg; + + # link all files in `./scripts` to `~/.config/i3/scripts` + # home.file.".config/i3/scripts" = { + # source = ./scripts; + # recursive = true; # link recursively + # executable = true; # make all files executable + # }; + + # encode the file content in nix configuration file directly + # home.file.".xxx".text = '' + # xxx + # ''; + + # Packages that should be installed to the user profile. + home.packages = with pkgs; [ + # here is some command line tools I use frequently + # feel free to add your own or remove some of them + + fastfetch + nnn # terminal file manager + + # archives + zip + xz + unzip + p7zip + + # utils + ripgrep # recursively searches directories for a regex pattern + #jq # A lightweight and flexible command-line JSON processor + #yq-go # yaml processor https://github.com/mikefarah/yq + eza # A modern replacement for ‘ls’ + #fzf # A command-line fuzzy finder + + # networking tools + mtr # A network diagnostic tool + iperf3 + dnsutils # `dig` + `nslookup` + #ldns # replacement of `dig`, it provide the command `drill` + #aria2 # A lightweight multi-protocol & multi-source command-line download utility + #socat # replacement of openbsd-netcat + #nmap # A utility for network discovery and security auditing + #ipcalc # it is a calculator for the IPv4/v6 addresses + + # misc + #cowsay + #file + #which + #tree + #gnused + #gnutar + #gawk + #zstd + #gnupg + + # nix related + # + # it provides the command `nom` works just like `nix` + # with more details log output + nix-output-monitor + + # productivity + hugo # static site generator + glow # markdown previewer in terminal + + btop # replacement of htop/nmon + iotop # io monitoring + iftop # network monitoring + + # system call monitoring + strace # system call monitoring + ltrace # library call monitoring + lsof # list open files + + # system tools + sysstat + lm_sensors # for `sensors` command + ethtool + pciutils # lspci + usbutils # lsusb + ]; + + # basic configuration of git, please change to your own + programs.git = { + enable = true; + userName = "Tootbrute"; + userEmail = "tootbrute@tutamail.com"; + }; + + # starship - an customizable prompt for any shell + programs.starship = { + enable = true; + # custom settings + settings = { + add_newline = false; + aws.disabled = true; + gcloud.disabled = true; + line_break.disabled = true; + }; + }; + + # alacritty - a cross-platform, GPU-accelerated terminal emulator + programs.alacritty = { + enable = true; + # custom settings + settings = { + env.TERM = "xterm-256color"; + font = { + size = 12; + # this causes error + #draw_bold_text_with_bright_colors = true; + }; + scrolling.multiplier = 5; + selection.save_to_clipboard = true; + }; + }; + + #GNOME desktop settings + dconf.settings = { + "org/gnome/desktop/interface" = { + color-scheme = "prefer-dark"; + }; + }; + + gtk = { + enable = true; + + gtk3.extraConfig = { + Settings = '' + gtk-application-prefer-dark-theme=1 + ''; + }; + + gtk4.extraConfig = { + Settings = '' + gtk-application-prefer-dark-theme=1 + ''; + }; + }; + + programs.bash = { + enable = true; + enableCompletion = true; + bashrcExtra = '' + export PATH="$PATH:$HOME/bin:$HOME/.local/bin:$HOME/go/bin" + ''; + + }; + + # This value determines the home Manager release that your + # configuration is compatible with. This helps avoid breakage + # when a new home Manager release introduces backwards + # incompatible changes. + # + # You can update home Manager without changing this value. See + # the home Manager release notes for a list of state version + # changes in each release. + home.stateVersion = "24.05"; + + # Let home Manager install and manage itself. + programs.home-manager.enable = true; +} diff --git a/systemd.nix b/systemd.nix new file mode 100644 index 0000000..8031dd4 --- /dev/null +++ b/systemd.nix @@ -0,0 +1,26 @@ +{ config, pkgs, lib, ... }: + +{ + + systemd.timers."update-flatpak" = { + wantedBy = [ "timers.target" ]; + timerConfig = { + OnBootSec = "1m"; + OnCalendar = "daily"; + Unit = "update-flatpak.service"; + }; + }; + + systemd.services."update-flatpak" = { + script = '' + set -eu + ${pkgs.flatpak}/bin/flatpak update --noninteractive --assumeyes + ''; + serviceConfig = { + Type = "oneshot"; + User = "root"; + }; + wantedBy = [ "multi-user.target" ]; # Ensure the service starts after rebuild + }; + +}