From 63da041bf50d4b5c3e4caf159ffe27cb81794c44 Mon Sep 17 00:00:00 2001 From: itsscb Date: Sun, 12 May 2024 23:50:07 +0200 Subject: [PATCH] "20240512111706" --- flake.nix | 17 +- hosts/default/configuration.nix | 220 ++++++++++++++--------- hosts/default/hardware-configuration.nix | 46 ++--- hosts/default/home.nix | 184 +++++++++---------- nixos-rebuild.sh | 52 ++++++ nixos-switch.log | 2 + shells/rust/rust.nix | 38 ++-- 7 files changed, 335 insertions(+), 224 deletions(-) create mode 100755 nixos-rebuild.sh create mode 100644 nixos-switch.log diff --git a/flake.nix b/flake.nix index d818af1..18ae839 100644 --- a/flake.nix +++ b/flake.nix @@ -14,10 +14,6 @@ url = "github:Mic92/sops-nix"; inputs.nixpkgs.follows = "nixpkgs"; }; - # hyprlock = { - # url = "github:hyprwm/hyprlock"; - # inputs.hyprland.follows = "hyprland"; - # }; home-manager = { url = "github:nix-community/home-manager"; @@ -25,10 +21,21 @@ }; }; - outputs = { self, nixpkgs, ... }@inputs: { + outputs = { + self, + nixpkgs, + ... + } @ inputs: { + inherit self; nixosConfigurations.default = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; specialArgs = {inherit inputs;}; modules = [ + ({pkgs, ...}: { + # Let 'nixos-version --json' know about the Git revision + # of this flake. + system.configurationRevision = self.lastModifiedDate; + }) ./hosts/default/configuration.nix inputs.home-manager.nixosModules.default ]; diff --git a/hosts/default/configuration.nix b/hosts/default/configuration.nix index 2c7b8e6..30db2d4 100644 --- a/hosts/default/configuration.nix +++ b/hosts/default/configuration.nix @@ -1,16 +1,20 @@ # 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, inputs, ... }: - { - imports = - [ # Include the results of the hardware scan. - ./hardware-configuration.nix - inputs.home-manager.nixosModules.default - inputs.sops-nix.nixosModules.sops - ]; + config, + pkgs, + inputs, + ... +}: { + imports = [ + # Include the results of the hardware scan. + ./hardware-configuration.nix + inputs.home-manager.nixosModules.default + + # Secrets Manager + inputs.sops-nix.nixosModules.sops + ]; sops.validateSopsFiles = false; sops.defaultSopsFile = "/etc/nixos/secrets/secrets.yaml"; @@ -32,7 +36,7 @@ boot.initrd.luks.devices."luks-ddb552e7-c477-4d71-899b-9224d6782b9f".device = "/dev/disk/by-uuid/ddb552e7-c477-4d71-899b-9224d6782b9f"; networking.hostName = "scbnb"; # Define your hostname. # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. - nix.settings.experimental-features = [ "nix-command" "flakes"]; + nix.settings.experimental-features = ["nix-command" "flakes"]; # Enable networking networking.networkmanager.enable = true; @@ -63,7 +67,7 @@ services.xserver.desktopManager.gnome.enable = true; # Configure keymap in X11 - services.xserver.xkb= { + services.xserver.xkb = { layout = "us"; variant = ""; }; @@ -81,7 +85,6 @@ alsa.support32Bit = true; pulse.enable = true; jack.enable = true; - }; users.groups.fsc = { @@ -93,37 +96,35 @@ isNormalUser = true; uid = 1000; description = "itsscb"; - extraGroups = [ "networkmanager" "wheel" "fsc"]; + extraGroups = ["networkmanager" "wheel" "fsc"]; packages = with pkgs; [ - ]; + ]; }; - users.users."k.sc"= { + users.users."k.sc" = { isNormalUser = true; uid = 1001; description = "k.sc"; - extraGroups = [ "networkmanager" "fsc"]; + extraGroups = ["networkmanager" "fsc"]; packages = with pkgs; [ - ]; + ]; }; fonts.packages = with pkgs; [ nerdfonts ]; - programs = { - steam = { - enable = true; + enable = true; }; hyprland = { enable = true; xwayland.enable = true; }; - + chromium = { - enable=true; + enable = true; homepageLocation = "https://start.duckduckgo.com"; extraOpts = { syncDisabled = true; @@ -131,7 +132,7 @@ PasswordManagerEnabled = false; SpellcheckEnabled = false; }; - defaultSearchProviderEnabled= true; + defaultSearchProviderEnabled = true; defaultSearchProviderSearchURL = "https://start.duckduckgo.com/?q={searchTerms}"; }; }; @@ -141,12 +142,10 @@ WLR_NO_HARDWARE_CURSORS = "1"; NIXOS_OZONE_WL = "1"; }; - + variables = { EDITOR = "hx"; }; - - }; hardware = { @@ -154,85 +153,141 @@ nvidia.modesetting.enable = true; }; -home-manager = { - extraSpecialArgs = { inherit inputs; }; - backupFileExtension = "backup"; - users = { - "itsscb" = import ./home.nix; # ( config.sops.secrets."git"); - "root" = { - home.stateVersion = "23.11"; - home.file.".config/helix".source = ../../dotfiles/helix; + home-manager = { + extraSpecialArgs = {inherit inputs;}; + backupFileExtension = "backup"; + users = { + "itsscb" = import ./home.nix; # ( config.sops.secrets."git"); + "root" = { + home.stateVersion = "23.11"; + home.file.".config/helix".source = ../../dotfiles/helix; + programs.bash = { + enable = true; + shellAliases = { + ls = "eza -la --git"; + grep = "rg"; + cat = "bat"; + }; + }; + }; }; }; -}; nixpkgs.config.allowUnfree = true; xdg.portal.enable = true; environment.systemPackages = with pkgs; [ - age + # nix specific + ## Secrets Manager sops - curl + + ## nix formatter + alejandra + + # Encryption + age + + # Hyprland / Window Manager + xdg-desktop-portal-gtk + xdg-desktop-portal-hyprland + + ## App Starter + rofi-wayland + + ## Network Settings + networkmanagerapplet + + # Audio Settings + pavucontrol + + ## Bluetooth Settings + blueman + + ## Lockscreen + hyprlock + + ## Top Bar waybar - (waybar.overrideAttrs (oldAttrs: { + ( + waybar.overrideAttrs (oldAttrs: { mesonFlags = oldAttrs.mesonFlags ++ ["-Dexperimental=true"]; }) ) + + ## ??? dunst + + ## Notification Daemone (?) libnotify - - swww - - broot - jq - poppler - fzf + + ## File Manager dolphin breeze-icons - - # cifs-utils - - networkmanagerapplet - alacritty - xdg-desktop-portal-gtk - xdg-desktop-portal-hyprland - rofi-wayland - pavucontrol - blueman - hyprlock + ## ??? + swww + + # Clipboard Manager + xclip + + # Image Manipulation inkscape gimp - ffmpeg - xclip - eza - bat - ripgrep - gitFull - rustup - helix - # vim - thunderbird + # Video + ffmpeg vlc + + # Music spotify + + # Terminal + alacritty + + ## 'ls' replacement + eza + + ## 'cat' replacement + bat + + ## 'grep' replacement + ripgrep + + ## 'find' replacement + fd + + ## Default Tools + curl + gitFull # git + broot # file manager + jq # json tool + poppler # ??? + fzf # ??? + + # Editor + helix + + # Mail Client + thunderbird ]; - services.xserver.excludePackages = (with pkgs; [ - nano - xterm - ]) ++ ( with pkgs.gnome; [ - cheese - gnome-music - epiphany - geary - totem - tali - iagno - hitori - atomix - ]); + services.xserver.excludePackages = + (with pkgs; [ + nano + xterm + ]) + ++ (with pkgs.gnome; [ + cheese + gnome-music + epiphany + geary + totem + tali + iagno + hitori + atomix + ]); fileSystems = { "/mnt/home" = { @@ -256,7 +311,6 @@ home-manager = { fsType = "cifs"; options = let automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s,user"; - in ["${automount_opts},credentials=${config.sops.secrets."nas".path},uid=1000,gid=1010"]; }; "/mnt/shared" = { @@ -264,17 +318,15 @@ home-manager = { fsType = "cifs"; options = let automount_opts = "x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s,user"; - in ["${automount_opts},credentials=${config.sops.secrets."nas".path},uid=1000,gid=1010"]; }; }; programs.nix-ld.enable = true; programs.nix-ld.libraries = with pkgs; [ - # Add any missing dynamic libraries for unpackaged + # Add any missing dynamic libraries for unpackaged # programs here, NOT in environment.systemPackages ]; system.stateVersion = "23.11"; # Did you read the comment? - } diff --git a/hosts/default/hardware-configuration.nix b/hosts/default/hardware-configuration.nix index 3252b34..2fa7f19 100644 --- a/hosts/default/hardware-configuration.nix +++ b/hosts/default/hardware-configuration.nix @@ -1,34 +1,38 @@ # 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") - ]; + config, + lib, + pkgs, + modulesPath, + ... +}: { + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; - boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ]; - boot.initrd.kernelModules = [ ]; - boot.kernelModules = [ "kvm-intel" ]; - boot.extraModulePackages = [ ]; + boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "usb_storage" "sd_mod" "rtsx_pci_sdmmc"]; + boot.initrd.kernelModules = []; + boot.kernelModules = ["kvm-intel"]; + boot.extraModulePackages = []; - fileSystems."/" = - { device = "/dev/disk/by-uuid/b57531b3-bf78-466e-a2f7-7eab09ce9284"; - fsType = "ext4"; - }; + fileSystems."/" = { + device = "/dev/disk/by-uuid/b57531b3-bf78-466e-a2f7-7eab09ce9284"; + fsType = "ext4"; + }; boot.initrd.luks.devices."luks-1ed60977-b0ee-4751-99f3-05f0b224634b".device = "/dev/disk/by-uuid/1ed60977-b0ee-4751-99f3-05f0b224634b"; - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/59A3-0BC5"; - fsType = "vfat"; - options = [ "fmask=0022" "dmask=0022" ]; - }; + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/59A3-0BC5"; + fsType = "vfat"; + options = ["fmask=0022" "dmask=0022"]; + }; - swapDevices = - [ { device = "/dev/disk/by-uuid/968cd561-fb73-496a-a37a-0e662bf45597"; } - ]; + swapDevices = [ + {device = "/dev/disk/by-uuid/968cd561-fb73-496a-a37a-0e662bf45597";} + ]; # 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 diff --git a/hosts/default/home.nix b/hosts/default/home.nix index 1d03ba4..67ba549 100644 --- a/hosts/default/home.nix +++ b/hosts/default/home.nix @@ -1,93 +1,94 @@ -{ config, pkgs, inputs, ... }: - { - # imports = [ - # inputs.sops-nix.nixosModules.sops - # ]; + config, + pkgs, + inputs, + ... +}: { home.username = "itsscb"; home.homeDirectory = "/home/itsscb"; home.stateVersion = "23.11"; # Please read the comment before changing. programs = { - helix = { - enable = true; - defaultEditor = true; - settings = { - theme = "onedark"; - editor = { - line-number = "relative"; - bufferline = "multiple"; - auto-completion = true; - auto-save = true; - auto-format = true; - cursorline = true; - gutters = [ - "diff" - "diagnostics" - "line-numbers" - "spacer" - ]; - text-width = 80; - cursor-shape = { + helix = { + enable = true; + defaultEditor = true; + settings = { + theme = "onedark"; + editor = { + line-number = "relative"; + bufferline = "multiple"; + auto-completion = true; + auto-save = true; + auto-format = true; + cursorline = true; + gutters = [ + "diff" + "diagnostics" + "line-numbers" + "spacer" + ]; + text-width = 80; + cursor-shape = { insert = "bar"; normal = "block"; - select = "underline"; - }; + select = "underline"; + }; - statusline = { - left = [ - "mode" - "spinner" - "file-modification-indicator" - "read-only-indicator" - ]; + statusline = { + left = [ + "mode" + "spinner" + "file-modification-indicator" + "read-only-indicator" + ]; - center = ["file-name"]; + center = ["file-name"]; - right = [ - "diagnostics" - "register" - "selections" - "position" - "file-encoding" - "file-line-ending" - "file-type" - ]; + right = [ + "diagnostics" + "register" + "selections" + "position" + "file-encoding" + "file-line-ending" + "file-type" + ]; - separator = "|"; - }; + separator = "|"; + }; - lsp = { - enable = true; - auto-signature-help = true; - display-messages = true; - display-inlay-hints = true; - }; + lsp = { + enable = true; + auto-signature-help = true; + display-messages = true; + display-inlay-hints = true; + }; - indent-guides = { - render = true; - character = "┊"; - skip-levels = 1; - }; + indent-guides = { + render = true; + character = "┊"; + skip-levels = 1; + }; }; - keys.insert.j.k="normal_mode"; - keys.insert."C-c"="normal_mode"; + keys.insert.j.k = "normal_mode"; + keys.insert."C-c" = "normal_mode"; + + keys.normal.g.a = "code_action"; + keys.normal.backspace = { + r = ":run-shell-command cargo run"; + t = ":run-shell-command cargo test"; + b = ":run-shell-command cargo build"; + c = ":run-shell-command cargo check"; + }; + }; + }; - keys.normal.g.a = "code_action"; - keys.normal.backspace = { - r=":run-shell-command cargo run"; - t=":run-shell-command cargo test"; - b=":run-shell-command cargo build"; - c=":run-shell-command cargo check"; - }; - }; - }; - bash = { enable = true; shellAliases = { ls = "eza -la --git"; + grep = "rg"; cat = "bat"; }; }; @@ -99,16 +100,14 @@ extraConfig = { credential.helper = "store"; }; - # init = { - # defaultBranch = "main"; - # }; }; vim = { - enable=true; + enable = true; }; + chromium = { - enable=true; + enable = true; commandLineArgs = [ "--disable-default-apps" "--homepage https://start.duckduckgo.com" @@ -133,22 +132,20 @@ settings."org/gnome/desktop/background".secondary-color = "#000000"; settings."org/gnome/desktop/interface".show-battery-percentage = true; settings."org/gnome/settings-daemon/plugins/media-keys".home = ["e"]; - settings."org/gnome/settings-daemon/plugins/media-keys".control-center= ["i"]; - settings."org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0".binding= "t"; - settings."org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0".command= "gnome-terminal"; - settings."org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0".name= "gt1"; - - settings."org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1".binding= "t"; - settings."org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1".command= "gnome-terminal"; - settings."org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1".name= "gt2"; - settings."org/gnome/settings-daemon/plugins/media-keys".custom-keybindings= ["/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/" "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/"]; + settings."org/gnome/settings-daemon/plugins/media-keys".control-center = ["i"]; + settings."org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0".binding = "t"; + settings."org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0".command = "gnome-terminal"; + settings."org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0".name = "gt1"; + settings."org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1".binding = "t"; + settings."org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1".command = "gnome-terminal"; + settings."org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1".name = "gt2"; + settings."org/gnome/settings-daemon/plugins/media-keys".custom-keybindings = ["/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/" "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/"]; }; home.packages = [ ]; -wayland.windowManager.hyprland.enable = true; -wayland.windowManager.hyprland.settings = { - + wayland.windowManager.hyprland.enable = true; + wayland.windowManager.hyprland.settings = { exec-once = [ "swww-daemon" "swww img /etc/nixos/dotfiles/hypr/rust.png" @@ -157,11 +154,11 @@ wayland.windowManager.hyprland.settings = { "waybar" "dunst" ]; - + "$terminal" = "alacritty"; "$fileManager" = "dolphin"; "$menu" = "rofi -show drun"; - + "$mod" = "SUPER"; monitor = ",preferred,auto,1"; @@ -177,7 +174,6 @@ wayland.windowManager.hyprland.settings = { allow_tearing = false; }; - decoration = { rounding = 10; @@ -206,7 +202,6 @@ wayland.windowManager.hyprland.settings = { "fade, 1, 7, default" "workspaces, 1, 6, default" ]; - }; gestures = { @@ -218,14 +213,13 @@ wayland.windowManager.hyprland.settings = { }; windowrulev2 = "suppressevent maximize, class:.*"; - + input = { follow_mouse = 2; touchpad = { - natural_scroll = "yes"; + natural_scroll = "yes"; }; - }; master = { @@ -236,7 +230,7 @@ wayland.windowManager.hyprland.settings = { "$mod, mouse:272, movewindow" "$mod, mouse:273, resizewindow" ]; - + bind = [ "$mod, T, exec, $terminal" @@ -277,7 +271,7 @@ wayland.windowManager.hyprland.settings = { 10) ); }; - + home.file = { ".config/hypr/hyprlock.conf".source = ../../dotfiles/hypr/hyprlock.conf; ".config/waybar".source = ../../dotfiles/waybar; diff --git a/nixos-rebuild.sh b/nixos-rebuild.sh new file mode 100755 index 0000000..7af7683 --- /dev/null +++ b/nixos-rebuild.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +if [ -z "$1"] + then + file='configuration.nix' + else + file=$1 +fi + +# A rebuild script that commits on a successful build +set -e + +# cd to your config dir +cd /etc/nixos/ + +# Edit your config +sudo hx $(fd $file . --max-results=1 -E hardware-configuration.nix -e nix) + +# Early return if no changes were detected (thanks @singiamtel!) +if sudo git diff --quiet '*.nix'; then + echo "No changes detected, exiting." + cd - + exit 0 +fi + +sudo rm nixos-switch.log + +# Autoformat your nix files +sudo alejandra . &>/dev/null \ + || ( sudo alejandra . ; echo "formatting failed!" && exit 1) + +# Shows your changes +sudo git diff -U0 '*.nix' + +echo -n "NixOS - Testing new configuration..." + +# Rebuild, output simplified errors, log trackebacks +sudo nixos-rebuild dry-build --flake .#default &>nixos-switch.log || (cat nixos-switch.log | grep --color error && exit 1) + +echo -e 'KNixOS - Test passed. Adding files to git' +sudo git add * + +echo -e "NixOS - Rebuilding..." +sudo nixos-rebuild dry-build --flake .#default &>nixos-switch.log || (cat nixos-switch.log | grep --color error && sudo git restore --staged ./**/*.nix && cd - && exit 1) +# Get current generation metadata +current=$(sudo nixos-version --json | jq .configurationRevision) + +# Commit all changes witih the generation metadata +sudo git commit -am "$current" + +echo -e "NixOS - New Build commited as $current" +cd - diff --git a/nixos-switch.log b/nixos-switch.log new file mode 100644 index 0000000..88758b4 --- /dev/null +++ b/nixos-switch.log @@ -0,0 +1,2 @@ +building the system configuration... +warning: Git tree '/etc/nixos' is dirty diff --git a/shells/rust/rust.nix b/shells/rust/rust.nix index 381b29c..51b27fa 100644 --- a/shells/rust/rust.nix +++ b/shells/rust/rust.nix @@ -1,7 +1,7 @@ -{ pkgs ? import {} }: - let - overrides = (builtins.fromTOML (builtins.readFile ./rust-toolchain.toml)); - libPath = with pkgs; lib.makeLibraryPath [ +{pkgs ? import {}}: let + overrides = builtins.fromTOML (builtins.readFile ./rust-toolchain.toml); + libPath = with pkgs; + lib.makeLibraryPath [ # load external libraries that you need in your rust project here ]; in @@ -14,27 +14,27 @@ in ]; RUSTC_VERSION = overrides.toolchain.channel; # https://github.com/rust-lang/rust-bindgen#environment-variables - LIBCLANG_PATH = pkgs.lib.makeLibraryPath [ pkgs.llvmPackages_latest.libclang.lib ]; + LIBCLANG_PATH = pkgs.lib.makeLibraryPath [pkgs.llvmPackages_latest.libclang.lib]; shellHook = '' export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin export PATH=$PATH:''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-x86_64-unknown-linux-gnu/bin/ - ''; + ''; # Add precompiled library to rustc search path - RUSTFLAGS = (builtins.map (a: ''-L ${a}/lib'') [ + RUSTFLAGS = builtins.map (a: ''-L ${a}/lib'') [ # add libraries here (e.g. pkgs.libvmi) - ]); + ]; LD_LIBRARY_PATH = libPath; # Add glibc, clang, glib, and other headers to bindgen search path BINDGEN_EXTRA_CLANG_ARGS = - # Includes normal include path - (builtins.map (a: ''-I"${a}/include"'') [ - # add dev libraries here (e.g. pkgs.libvmi.dev) - pkgs.glibc.dev - ]) - # Includes with special directory paths - ++ [ - ''-I"${pkgs.llvmPackages_latest.libclang.lib}/lib/clang/${pkgs.llvmPackages_latest.libclang.version}/include"'' - ''-I"${pkgs.glib.dev}/include/glib-2.0"'' - ''-I${pkgs.glib.out}/lib/glib-2.0/include/'' - ]; + # Includes normal include path + (builtins.map (a: ''-I"${a}/include"'') [ + # add dev libraries here (e.g. pkgs.libvmi.dev) + pkgs.glibc.dev + ]) + # Includes with special directory paths + ++ [ + ''-I"${pkgs.llvmPackages_latest.libclang.lib}/lib/clang/${pkgs.llvmPackages_latest.libclang.version}/include"'' + ''-I"${pkgs.glib.dev}/include/glib-2.0"'' + ''-I${pkgs.glib.out}/lib/glib-2.0/include/'' + ]; }