From c1e4ef47f397c560dd131e30d580361dd7d5a8df Mon Sep 17 00:00:00 2001 From: biscuit Date: Mon, 19 May 2025 17:53:19 -0500 Subject: [PATCH] initialization --- README.md | 11 ++++ dotfiles/biscuit/home.nix | 25 +++++++++ flake.lock | 48 ++++++++++++++++++ flake.nix | 40 +++++++++++++++ modules/biscuit/editor.nix | 9 ++++ modules/biscuit/gui.nix | 5 ++ modules/system.nix | 18 +++++++ nixos/biscuit/configuration.nix | 20 ++++++++ nixos/biscuit/hardware-configuration.nix | 41 +++++++++++++++ pkgs/fastfetch/biscuit.nix | 3 ++ pkgs/git/biscuit.nix | 3 ++ pkgs/hyprland/biscuit.nix | 3 ++ pkgs/kitty/biscuit.nix | 8 +++ pkgs/neovim/biscuit.nix | 21 ++++++++ pkgs/zsh/biscuit.nix | 64 ++++++++++++++++++++++++ pkgs/zsh/custom/config.omp.json | 55 ++++++++++++++++++++ system/bootloader.nix | 4 ++ system/browser.nix | 3 ++ system/firewall.nix | 7 +++ system/locale.nix | 9 ++++ system/networking.nix | 6 +++ system/print.nix | 5 ++ system/proxy.nix | 5 ++ system/recovery.nix | 6 +++ system/sound.nix | 9 ++++ system/ssh.nix | 3 ++ system/term.nix | 3 ++ system/timezone.nix | 3 ++ system/touchpad.nix | 4 ++ system/users.nix | 10 ++++ 30 files changed, 451 insertions(+) create mode 100644 README.md create mode 100644 dotfiles/biscuit/home.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 modules/biscuit/editor.nix create mode 100644 modules/biscuit/gui.nix create mode 100644 modules/system.nix create mode 100644 nixos/biscuit/configuration.nix create mode 100644 nixos/biscuit/hardware-configuration.nix create mode 100644 pkgs/fastfetch/biscuit.nix create mode 100644 pkgs/git/biscuit.nix create mode 100644 pkgs/hyprland/biscuit.nix create mode 100644 pkgs/kitty/biscuit.nix create mode 100644 pkgs/neovim/biscuit.nix create mode 100644 pkgs/zsh/biscuit.nix create mode 100644 pkgs/zsh/custom/config.omp.json create mode 100644 system/bootloader.nix create mode 100644 system/browser.nix create mode 100644 system/firewall.nix create mode 100644 system/locale.nix create mode 100644 system/networking.nix create mode 100644 system/print.nix create mode 100644 system/proxy.nix create mode 100644 system/recovery.nix create mode 100644 system/sound.nix create mode 100644 system/ssh.nix create mode 100644 system/term.nix create mode 100644 system/timezone.nix create mode 100644 system/touchpad.nix create mode 100644 system/users.nix diff --git a/README.md b/README.md new file mode 100644 index 0000000..9f677be --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# NixOS configuration + +## Getting Started + +### System rebuild +1. (Optional) On ./system/users.nix, replace `biscuit` on `users.users.biscuit` with your own username. If you are creating a new user (by replacing `biscuit`), or ignoring the file, the default password is `very-insecure-password`. Make sure to replace it! +2. Replace `hardware-configuration.conf`(each located at `nixos` folder) with your own. You can generate a config via `nixos-generate-config --dir ./nixos/`. +3. While in this folder, rebuild your system using this command: `sudo nixos-rebuild switch --flake ./#${YOUR_CHOICE}`. For example, if you chose `biscuit` config, you type the following: `sudo nixos-rebuild switch --flake ./#biscuit`. + +### Home rebuild + diff --git a/dotfiles/biscuit/home.nix b/dotfiles/biscuit/home.nix new file mode 100644 index 0000000..a507ad2 --- /dev/null +++ b/dotfiles/biscuit/home.nix @@ -0,0 +1,25 @@ +{ + inputs, + outputs, + lib, + config, + pkgs, + ... +}: { + imports = [ + ../../modules/biscuit/editor.nix + ../../modules/biscuit/gui.nix + ]; + + programs.home-manager.enable = true; + + home = { + username = "biscuit"; + homeDirectory = "/home/biscuit"; + packages = []; + sessionVariables = {}; + }; + + systemd.user.startServices = "sd-switch"; + home.stateVersion = "23.05"; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..5dd08eb --- /dev/null +++ b/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1747688838, + "narHash": "sha256-FZq4/3OtGV/cti9Vccsy2tGSUrxTO4hkDF9oeGRTen4=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "45c2985644b60ab64de2a2d93a4d132ecb87cf66", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1747542820, + "narHash": "sha256-GaOZntlJ6gPPbbkTLjbd8BMWaDYafhuuYRNrxCGnPJw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "292fa7d4f6519c074f0a50394dbbe69859bb6043", + "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..911a9f8 --- /dev/null +++ b/flake.nix @@ -0,0 +1,40 @@ +{ + description = "A very basic flake"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + home-manager.url = "github:nix-community/home-manager"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; # `follows` ensure it follows nixpkgs version + }; + + outputs = { + self, + nixpkgs, + home-manager, + ... + } @ inputs: let + lib = nixpkgs.lib; + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + in { + nixosConfigurations = { + biscuit = lib.nixosSystem { + specialArgs = {inherit inputs system;}; + inherit system; + modules = [ + ./nixos/biscuit/configuration.nix + ]; + }; + }; + homeConfigurations = { + biscuit = home-manager.lib.homeManagerConfiguration { + pkgs = import nixpkgs { + inherit system; + overlays = []; + }; + extraSpecialArgs = {inherit inputs system;}; + modules = [./dotfiles/biscuit/home.nix]; + }; + }; + }; +} diff --git a/modules/biscuit/editor.nix b/modules/biscuit/editor.nix new file mode 100644 index 0000000..7cba168 --- /dev/null +++ b/modules/biscuit/editor.nix @@ -0,0 +1,9 @@ +{...}: { + imports = [ + ../../pkgs/fastfetch/biscuit.nix + ../../pkgs/git/biscuit.nix + ../../pkgs/kitty/biscuit.nix + ../../pkgs/neovim/biscuit.nix + ../../pkgs/zsh/biscuit.nix + ]; +} diff --git a/modules/biscuit/gui.nix b/modules/biscuit/gui.nix new file mode 100644 index 0000000..fdcae9a --- /dev/null +++ b/modules/biscuit/gui.nix @@ -0,0 +1,5 @@ +{...}: { + imports = [ + ../../pkgs/hyprland/biscuit.nix + ]; +} diff --git a/modules/system.nix b/modules/system.nix new file mode 100644 index 0000000..a4f7025 --- /dev/null +++ b/modules/system.nix @@ -0,0 +1,18 @@ +{ ... }: { + imports = [ + ../system/bootloader.nix + ../system/browser.nix + ../system/firewall.nix + ../system/locale.nix + ../system/networking.nix + ../system/print.nix + ../system/term.nix + # ../system/proxy.nix + # ../system/recovery.nix # only supports non-flake conf + ../system/sound.nix + ../system/ssh.nix + ../system/timezone.nix + # ../system/touchpad.nix + ../system/users.nix + ]; +} diff --git a/nixos/biscuit/configuration.nix b/nixos/biscuit/configuration.nix new file mode 100644 index 0000000..2088e1a --- /dev/null +++ b/nixos/biscuit/configuration.nix @@ -0,0 +1,20 @@ +{ + config, + lib, + pkgs, + ... +}: { + imports = [ + # Include the results of the hardware scan. + ./hardware-configuration.nix + ../../modules/system.nix + ]; + + environment.systemPackages = with pkgs; [ + vim + wget + ]; + + nix.settings.experimental-features = ["nix-command" "flakes"]; + system.stateVersion = "25.05"; +} diff --git a/nixos/biscuit/hardware-configuration.nix b/nixos/biscuit/hardware-configuration.nix new file mode 100644 index 0000000..c970b77 --- /dev/null +++ b/nixos/biscuit/hardware-configuration.nix @@ -0,0 +1,41 @@ +# 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" "usbhid" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/8552e23a-af9f-4af8-947f-9ea6ff1e7195"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/00BB-80E9"; + fsType = "vfat"; + options = [ "fmask=0077" "dmask=0077" ]; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/2a916b88-8039-481b-9c30-4edd0f329eb3"; } + ]; + + # 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.eno1.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp1s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/pkgs/fastfetch/biscuit.nix b/pkgs/fastfetch/biscuit.nix new file mode 100644 index 0000000..452e710 --- /dev/null +++ b/pkgs/fastfetch/biscuit.nix @@ -0,0 +1,3 @@ +{...}: { + programs.fastfetch.enable = true; +} diff --git a/pkgs/git/biscuit.nix b/pkgs/git/biscuit.nix new file mode 100644 index 0000000..b04f182 --- /dev/null +++ b/pkgs/git/biscuit.nix @@ -0,0 +1,3 @@ +{ ... }: { + programs.git.enable = true; +} diff --git a/pkgs/hyprland/biscuit.nix b/pkgs/hyprland/biscuit.nix new file mode 100644 index 0000000..680135e --- /dev/null +++ b/pkgs/hyprland/biscuit.nix @@ -0,0 +1,3 @@ +{...}: { + wayland.windowManager.hyprland.enable = true; +} diff --git a/pkgs/kitty/biscuit.nix b/pkgs/kitty/biscuit.nix new file mode 100644 index 0000000..8254e87 --- /dev/null +++ b/pkgs/kitty/biscuit.nix @@ -0,0 +1,8 @@ +{pkgs, ...}: { + programs.kitty.enable = true; + programs.kitty.settings = { + confirm_os_window_close = 0; + window_padding_width = 10; + font_size = 12.0; + }; +} diff --git a/pkgs/neovim/biscuit.nix b/pkgs/neovim/biscuit.nix new file mode 100644 index 0000000..bf8d034 --- /dev/null +++ b/pkgs/neovim/biscuit.nix @@ -0,0 +1,21 @@ +{pkgs, ...}: let + nvimSource = pkgs.fetchFromGitea { + domain = "git.sakamoto.dev"; + owner = "kenji"; + repo = "nvim"; + rev = "30449ae49cae92ec42356a49a3d2a3b4b7db0119"; + sha256 = "sha256-YbP814fKOFuCWBRwlccd4nx/h8sdMgiJQu54thRLsK8="; + }; +in { + programs.neovim.enable = true; + home.packages = with pkgs; [ + lazygit + ripgrep + ]; + home.file.".config/nvim" = { + # source = /home/biscuit/Nixos/packages/nvim/nvchad; + source = nvimSource; + recursive = true; + force = true; + }; +} diff --git a/pkgs/zsh/biscuit.nix b/pkgs/zsh/biscuit.nix new file mode 100644 index 0000000..b9311c5 --- /dev/null +++ b/pkgs/zsh/biscuit.nix @@ -0,0 +1,64 @@ +{pkgs, ...}: { + home.packages = with pkgs; [ + zoxide + oh-my-posh + ]; + + programs.zsh.enable = true; + programs.zoxide.enable = true; + programs.oh-my-posh.enable = true; + + home.file.".config/oh-my-posh/config.omp.json" = { + source = ./custom/config.omp.json; + force = true; + }; + + programs.zsh = { + plugins = [ + { + name = "vi-mode"; + src = pkgs.zsh-vi-mode; + file = "share/zsh-vi-mode/zsh-vi-mode.plugin.zsh"; + } + { + name = "autosuggestion"; + src = pkgs.zsh-autosuggestions; + file = "share/zsh-autosuggestions/zsh-autosuggestions.zsh"; + } + ]; + enableCompletion = true; + syntaxHighlighting.enable = true; + shellAliases = { + ll = "ls -l"; + upd = "sudo nixos-rebuild switch --flake ~/Nixos/#biscuit"; + hupd = "home-manager switch --flake ~/Nixos/#biscuit --impure"; + agu = "pkill gjs & ags run ~/Nixos/packages/ags/custom/app.ts &"; + }; + history.size = 10000; + oh-my-zsh = { + plugins = []; + enable = true; + theme = "robbyrussell"; + extraConfig = '' + zstyle ':completion:*' completer _expand _complete _ignored _approximate _expand_alias + zstyle ':autocomplete:*' default-context curcontext + zstyle ':autocomplete:*' min-input 0 + + setopt HIST_FIND_NO_DUPS + + autoload -Uz compinit + compinit + + # setopt autocd # cd without writing 'cd' + setopt globdots # show dotfiles in autocomplete list + ''; + }; + initContent = '' + # Oh-My-Posh initialization for Zsh + eval "$(oh-my-posh init zsh --config ~/.config/oh-my-posh/config.omp.json)" + + # zsh-autocomplete + bindkey -M menuselect '^M' .accept-line # run code when selected completion + ''; + }; +} diff --git a/pkgs/zsh/custom/config.omp.json b/pkgs/zsh/custom/config.omp.json new file mode 100644 index 0000000..a6e6a5d --- /dev/null +++ b/pkgs/zsh/custom/config.omp.json @@ -0,0 +1,55 @@ +{ + "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", + "blocks": [ + { + "alignment": "left", + "segments": [ + { + "foreground": "#ffdd86", + "style": "plain", + "template": "{{ .UserName }}@{{ .HostName }} ", + "type": "session" + }, + { + "foreground": "#42a9ff", + "style": "plain", + "properties": { + "style": "full" + }, + "template": "{{ .Path }} ", + "type": "path" + }, + { + "properties": { + "branch_icon": "", + "fetch_status": true + }, + "style": "plain", + "template": "git:{{ if or (.Working.Changed) (.Staging.Changed) (gt .StashCount 0) }}<#ffdd86>{{ .HEAD }}{{ else }}{{ .HEAD }}{{ end }}{{ if .Staging.Changed }} <#98c379>{{ .Staging.String }}{{ end }}{{ if .Working.Changed }} <#d16971>{{ .Working.String }}{{ end }}", + "type": "git" + } + ], + "type": "prompt" + }, + { + "alignment": "left", + "newline": true, + "segments": [ + { + "foreground": "#ffdd86", + "foreground_templates": [ + "{{ if gt .Code 0 }}#42a9ff{{ end }}" + ], + "properties": { + "always_enabled": true + }, + "style": "plain", + "template": "> ", + "type": "status" + } + ], + "type": "prompt" + } + ], + "version": 3 +} diff --git a/system/bootloader.nix b/system/bootloader.nix new file mode 100644 index 0000000..909c54c --- /dev/null +++ b/system/bootloader.nix @@ -0,0 +1,4 @@ +{ ... }: { + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; +} diff --git a/system/browser.nix b/system/browser.nix new file mode 100644 index 0000000..5b7fb76 --- /dev/null +++ b/system/browser.nix @@ -0,0 +1,3 @@ +{ ... }: { + programs.firefox.enable = true; +} diff --git a/system/firewall.nix b/system/firewall.nix new file mode 100644 index 0000000..e894e22 --- /dev/null +++ b/system/firewall.nix @@ -0,0 +1,7 @@ +{ ... }: { + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; +} diff --git a/system/locale.nix b/system/locale.nix new file mode 100644 index 0000000..47d4c0a --- /dev/null +++ b/system/locale.nix @@ -0,0 +1,9 @@ +{ ... }: { + i18n.defaultLocale = "en_US.UTF-8"; + console = { + font = "Lat2-Terminus16"; + # keyMap = "us"; + useXkbConfig = true; # use xkb.options in tty. + }; +} + diff --git a/system/networking.nix b/system/networking.nix new file mode 100644 index 0000000..b0fe754 --- /dev/null +++ b/system/networking.nix @@ -0,0 +1,6 @@ +{ ... }: { + networking.hostName = "nixos"; + # Pick only one of the below networking options. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. +} diff --git a/system/print.nix b/system/print.nix new file mode 100644 index 0000000..8af9be3 --- /dev/null +++ b/system/print.nix @@ -0,0 +1,5 @@ +{ ... }: { + services = { + printing.enable = true; + }; +} diff --git a/system/proxy.nix b/system/proxy.nix new file mode 100644 index 0000000..ad9f246 --- /dev/null +++ b/system/proxy.nix @@ -0,0 +1,5 @@ +{ ... }: { + # Configure network proxy if necessary + # networking.proxy.default = "http://user:password@proxy:port/"; + # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; +} diff --git a/system/recovery.nix b/system/recovery.nix new file mode 100644 index 0000000..54715e4 --- /dev/null +++ b/system/recovery.nix @@ -0,0 +1,6 @@ +{ ... }: { + # Copy the NixOS configuration file and link it from the resulting system + # (/run/current-system/configuration.nix). This is useful in case you + # accidentally delete configuration.nix. + system.copySystemConfiguration = true; +} diff --git a/system/sound.nix b/system/sound.nix new file mode 100644 index 0000000..9aa6052 --- /dev/null +++ b/system/sound.nix @@ -0,0 +1,9 @@ +{ ... }: { + # Enable sound. + # services.pulseaudio.enable = true; + # OR + services.pipewire = { + enable = true; + pulse.enable = true; + }; +} diff --git a/system/ssh.nix b/system/ssh.nix new file mode 100644 index 0000000..914b807 --- /dev/null +++ b/system/ssh.nix @@ -0,0 +1,3 @@ +{ ... }: { + services.openssh.enable = true; +} diff --git a/system/term.nix b/system/term.nix new file mode 100644 index 0000000..2c1f221 --- /dev/null +++ b/system/term.nix @@ -0,0 +1,3 @@ +{...}: { + programs.zsh.enable = true; +} diff --git a/system/timezone.nix b/system/timezone.nix new file mode 100644 index 0000000..a6d89ef --- /dev/null +++ b/system/timezone.nix @@ -0,0 +1,3 @@ +{ ... }: { + time.timeZone = "America/Chicago"; +} diff --git a/system/touchpad.nix b/system/touchpad.nix new file mode 100644 index 0000000..4353925 --- /dev/null +++ b/system/touchpad.nix @@ -0,0 +1,4 @@ +{ ... }: { + # Enable touchpad support (enabled default in most desktopManager). + services.libinput.enable = true; +} diff --git a/system/users.nix b/system/users.nix new file mode 100644 index 0000000..ed55a5b --- /dev/null +++ b/system/users.nix @@ -0,0 +1,10 @@ +{ pkgs, ... }: { + users.users.biscuit = { + isNormalUser = true; + extraGroups = [ "wheel" "networkmanager" ]; + initialHashedPassword = "$6$Qab6SSvEJM2YRtVA$7Oyl7E3pp/FKtCC.2Tb2tyzp3yp7BFHFAKngUYJssQJ.v1Q2mqsgW9m7njpaKNcka2vyCwrnmw1R.YPlFqR0p1"; + shell = pkgs.zsh; + packages = with pkgs; [ + ]; + }; +}