From 48e18fb4da5e0c1699953630e64ffc165b3752a6 Mon Sep 17 00:00:00 2001 From: sam Date: Wed, 8 May 2024 00:45:54 +0100 Subject: [PATCH] inital commit --- flake.lock | 48 +++++++++ flake.nix | 29 ++++++ hosts/workmachine/configuration.nix | 97 +++++++++++++++++++ hosts/workmachine/hardware-configuration.nix | 33 +++++++ hosts/workmachine/home.nix | 83 ++++++++++++++++ .../workmachine/scripts/wallpaper_changer.nix | 26 +++++ hosts/workmachine/themes/sddm-sugar-candy.nix | 18 ++++ 7 files changed, 334 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 hosts/workmachine/configuration.nix create mode 100644 hosts/workmachine/hardware-configuration.nix create mode 100644 hosts/workmachine/home.nix create mode 100755 hosts/workmachine/scripts/wallpaper_changer.nix create mode 100644 hosts/workmachine/themes/sddm-sugar-candy.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..0aa61c4 --- /dev/null +++ b/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1714981474, + "narHash": "sha256-b3/U21CJjCjJKmA9WqUbZGZgCvospO3ArOUTgJugkOY=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "6ebe7be2e67be7b9b54d61ce5704f6fb466c536f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1714906307, + "narHash": "sha256-UlRZtrCnhPFSJlDQE7M0eyhgvuuHBTe1eJ9N9AQlJQ0=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "25865a40d14b3f9cf19f19b924e2ab4069b09588", + "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..fcf9fe1 --- /dev/null +++ b/flake.nix @@ -0,0 +1,29 @@ +{ + description = "Nixos config flake"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { self, nixpkgs, ... }@inputs: { + nixosConfigurations = { + default = nixpkgs.lib.nixosSystem { + specialArgs = {inherit inputs;}; + modules = [ + ./hosts/default/configuration.nix + ]; + }; + workmachine = nixpkgs.lib.nixosSystem { + specialArgs = {inherit inputs;}; + modules = [ + ./hosts/workmachine/configuration.nix + ]; + }; + }; + }; +} diff --git a/hosts/workmachine/configuration.nix b/hosts/workmachine/configuration.nix new file mode 100644 index 0000000..3d60944 --- /dev/null +++ b/hosts/workmachine/configuration.nix @@ -0,0 +1,97 @@ +{ inputs, config, lib, pkgs, ... }: + +{ + imports = + [ + ./hardware-configuration.nix + inputs.home-manager.nixosModules.home-manager + ]; + + home-manager = { + extraSpecialArgs = { inherit inputs; }; + users = { + sam = import ./home.nix; + }; + }; + + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + boot.loader.grub.enable = true; + boot.loader.grub.device = "/dev/vda"; + + networking.networkmanager.enable = true; + + time.timeZone = "Europe/London"; + + networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + i18n.defaultLocale = "en_GB.UTF-8"; + console = { + font = "Lat2-Terminus16"; + keyMap = "uk"; + useXkbConfig = false; + }; + + services.printing.enable = true; + + sound.enable = true; + hardware.pulseaudio.enable = true; + + services.libinput.enable = true; + + users.users.sam = { + isNormalUser = true; + extraGroups = [ "wheel" ]; + }; + + users.users.sam.shell = pkgs.zsh; + + environment.systemPackages = with pkgs; [ + curl + vim + home-manager + tmux + waybar + git + mako + libnotify + wl-clipboard + swww + rofi-wayland + networkmanagerapplet + htop + sddm + wdisplays + (callPackage ./themes/sddm-sugar-candy.nix{}).sddm-sugar-candy-theme + libsForQt5.qt5.qtgraphicaleffects #required for sugar candy + (import ./scripts/wallpaper_changer.nix { inherit pkgs; }) + ]; + + programs.gnupg.agent = { + enable = true; + enableSSHSupport = true; + }; + + programs.zsh.enable = true; + programs.hyprland = { + enable = true; + xwayland.enable = true; + }; + + hardware = { + opengl.enable = true; + nvidia.modesetting.enable = true; + }; + + services.openssh.enable = true; + services.displayManager.sddm = { + enable = true; + theme = "sugar-candy"; + }; + + services.displayManager.sddm.wayland.enable = true; + + system.stateVersion = "23.11"; + +} + diff --git a/hosts/workmachine/hardware-configuration.nix b/hosts/workmachine/hardware-configuration.nix new file mode 100644 index 0000000..1b1b9bd --- /dev/null +++ b/hosts/workmachine/hardware-configuration.nix @@ -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, ... }: + +{ + imports = + [ (modulesPath + "/profiles/qemu-guest.nix") + ]; + + boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "sr_mod" "virtio_blk" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/f9abe09a-de68-4913-b6c5-ad55b473a961"; + fsType = "ext4"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/fe24d2ba-2fbc-4ef5-8139-a26f4fc3f3e3"; } + ]; + + # 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.enp1s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; +} diff --git a/hosts/workmachine/home.nix b/hosts/workmachine/home.nix new file mode 100644 index 0000000..2f0587a --- /dev/null +++ b/hosts/workmachine/home.nix @@ -0,0 +1,83 @@ +{ config, pkgs, ... }: + +{ + home.username = "sam"; + home.homeDirectory = "/home/sam"; + home.stateVersion = "23.11"; + home.packages = [ + pkgs.firefox + pkgs.neovim + pkgs.kitty + pkgs.zathura + pkgs.xfce.thunar + ]; + + programs.zsh = { + enable = true; + enableCompletion = true; + autosuggestion.enable = true; + syntaxHighlighting.enable = true; + + shellAliases = { + ll = "ls -l"; + update = "sudo nixos-rebuild switch --flake $(readlink -f /etc/nixos)#workmachine"; + nix-home = "nvim $HOME/nixos/hosts/workmachine/home.nix"; + nix-conf = "nvim $HOME/nixos/hosts/workmachine/configuration.nix"; + }; + history.size = 10000; + history.path = "${config.xdg.dataHome}/zsh/history"; + + initExtra = '' + bindkey -v + bindkey "^H" backward-delete-char + bindkey "^?" backward-delete-char + set -o vi + export TERM=xterm + ''; + }; + + + home.file = { + ".icons/bibata".source = "${pkgs.bibata-cursors}/share/icons/Bibata-Modern-Classic"; + }; + + home.sessionPath = [ + "$HOME/.scripts/" + ]; + + gtk.enable = true; + + gtk.cursorTheme.package = pkgs.bibata-cursors; + gtk.cursorTheme.name = "Bibata-Modern-Ice"; + + gtk.theme.package = pkgs.gruvbox-gtk-theme; + gtk.theme.name = "Gruvbox-Dark-B"; + + gtk.iconTheme.package = pkgs.gruvbox-plus-icons; + gtk.iconTheme.name = "GruvboxPlus"; + + qt.enable = true; + qt.platformTheme.name = "gtk"; + qt.style.name = "adwaita-dark"; + qt.style.package = pkgs.adwaita-qt; + + programs.git = { + enable=true; + extraConfig= { + pull.rebase = false; + }; + userEmail="samual.shop@proton.me"; + userName="sam"; + }; + + home.sessionVariables = { + EDITOR="nvim"; + MUSIC="$HOME/mus/music_data/"; + TERMINAL="kitty"; + READER="zathura"; + IMAGE_VIEWER=""; + IMAGE_EDITOR=""; + }; + + programs.home-manager.enable = true; +} diff --git a/hosts/workmachine/scripts/wallpaper_changer.nix b/hosts/workmachine/scripts/wallpaper_changer.nix new file mode 100755 index 0000000..01f6828 --- /dev/null +++ b/hosts/workmachine/scripts/wallpaper_changer.nix @@ -0,0 +1,26 @@ +{ pkgs }: + +pkgs.writeShellScriptBin "wallpaper_changer" '' + +script_name=''${BASH_SOURCE[0]} +for pid in $(pidof -x "$script_name"); do + if [ "$pid" != $$ ]; then + kill -15 "$pid" + fi +done + +[ "$XDG_SESSION_TYPE" != "wayland" ] && echo "Not a Wayland session, exiting." && exit 1 +wallpaper_dir="$HOME/.local/share/bg/" + +kill -15 $(pidof -x "swww-daemon") +kill -15 $(pidof -x "swww") +${pkgs.swww}/bin/swww-daemon & + +while true; do + find "$wallpaper_dir" -type f -follow \( -iname \*.jpg -o -iname \*.png -o -iname \*.gif -o -iname \*.bmp \) | shuf | while read -r file; do + ${pkgs.swww}/bin/swww img "$file" --transition-step 10 --transition-fps 60 + sleep 600 + done +done + +'' diff --git a/hosts/workmachine/themes/sddm-sugar-candy.nix b/hosts/workmachine/themes/sddm-sugar-candy.nix new file mode 100644 index 0000000..eb235a9 --- /dev/null +++ b/hosts/workmachine/themes/sddm-sugar-candy.nix @@ -0,0 +1,18 @@ +{ stdenv, fetchFromGitHub }: +{ + sddm-sugar-candy-theme = stdenv.mkDerivation rec { + pname = "sddm-sugar-candy-theme"; + version = "1.6"; + dontBuild = true; + installPhase = '' + mkdir -p $out/share/sddm/themes + cp -aR $src $out/share/sddm/themes/sugar-candy + ''; + src = fetchFromGitHub { + owner = "Kangie"; + repo = "sddm-sugar-candy"; + rev = "v1.6"; + sha256 = "sha256-p2d7I0UBP63baW/q9MexYJQcqSmZ0L5rkwK3n66gmqM="; + }; + }; +}