commit e726aebd5b6ee3669d3ff704860d67d5dbabb31a Author: Tyler Mayoff Date: Mon Sep 30 18:06:03 2024 -0400 Initial Commit diff --git a/dot_config/home-manager/flake.lock b/dot_config/home-manager/flake.lock new file mode 100644 index 0000000..303ad0f --- /dev/null +++ b/dot_config/home-manager/flake.lock @@ -0,0 +1,115 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1726985855, + "narHash": "sha256-NJPGK030Y3qETpWBhj9oobDQRbXdXOPxtu+YgGvZ84o=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "04213d1ce4221f5d9b40bcee30706ce9a91d148d", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixgl": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1713543440, + "narHash": "sha256-lnzZQYG0+EXl/6NkGpyIz+FEOc/DSEG57AP1VsdeNrM=", + "owner": "nix-community", + "repo": "nixGL", + "rev": "310f8e49a149e4c9ea52f1adf70cdc768ec53f8a", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixGL", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1660551188, + "narHash": "sha256-a1LARMMYQ8DPx1BgoI/UN4bXe12hhZkCNqdxNi6uS0g=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "441dc5d512153039f19ef198e662e4f3dbb9fd65", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1726755586, + "narHash": "sha256-PmUr/2GQGvFTIJ6/Tvsins7Q43KTMvMFhvG6oaYK+Wk=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "c04d5652cfa9742b1d519688f65d1bbccea9eb7e", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1727397532, + "narHash": "sha256-pojbL/qteElw/nIXlN8kmHn/w6PQbEHr7Iz+WOXs0EM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "f65141456289e81ea0d5a05af8898333cab5c53d", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixgl": "nixgl", + "nixpkgs": "nixpkgs_2", + "nixpkgs-unstable": "nixpkgs-unstable" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/dot_config/home-manager/flake.nix b/dot_config/home-manager/flake.nix new file mode 100644 index 0000000..c8339d1 --- /dev/null +++ b/dot_config/home-manager/flake.nix @@ -0,0 +1,55 @@ +{ + description = "Home manager flake"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05"; + nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + nixgl.url = "github:nix-community/nixGL"; + }; + + outputs = { + self, + nixpkgs, + nixpkgs-unstable, + home-manager, + ... + } @ inputs: let + inherit (self) outputs; + + system = "x86_64-linux"; + in rec { + pkgs = import nixpkgs { + inherit system; + config.allowUnfree = true; + }; + + overlays = import ./overlays {inherit inputs;}; + + defaultPackage.${system} = home-manager.defaultPackage.${system}; + + nixosConfigurations = { + mal = nixpkgs.lib.nixosSystem { + specialArgs = {inherit inputs outputs;}; + modules = [./nixos/mal/configuration.nix]; + }; + }; + + homeConfigurations = { + "tyler@guidebolt" = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + extraSpecialArgs = {inherit inputs outputs;}; + modules = [./home/guidebolt/guidebolt.nix]; + }; + + "tyler@wash" = home-manager.lib.homeManagerConfiguration { + inherit pkgs; + extraSpecialArgs = {inherit inputs outputs;}; + modules = [./home/wash/wash.nix]; + }; + }; + }; +} diff --git a/dot_config/home-manager/home/common.nix b/dot_config/home-manager/home/common.nix new file mode 100644 index 0000000..4627fa3 --- /dev/null +++ b/dot_config/home-manager/home/common.nix @@ -0,0 +1,224 @@ +{ + inputs, + outputs, + # lib, + config, + pkgs, + ... +}: let + nixGLIntel = inputs.nixgl.packages."${pkgs.system}".nixGLIntel; +in rec { + nixpkgs.config.allowUnfree = true; + + home.username = "tyler"; + home.homeDirectory = "/home/tyler"; + + home.enableNixpkgsReleaseCheck = false; + + xdg.enable = true; + + imports = [ + ./fish.nix + ./nushell.nix + # ./nom.nix + # ./neovim.nix + (builtins.fetchurl { + url = "https://raw.githubusercontent.com/Smona/home-manager/nixgl-compat/modules/misc/nixgl.nix"; + sha256 = "01dkfr9wq3ib5hlyq9zq662mp0jl42fw3f6gd2qgdf8l8ia78j7i"; + }) + ]; + + nixGL.prefix = "${nixGLIntel}/bin/nixGLIntel"; + + nixpkgs = { + overlays = [ + outputs.overlays.additions + outputs.overlays.modifications + outputs.overlays.unstable-packages + ]; + }; + + fonts.fontconfig.enable = true; + + home.packages = with pkgs; [ + # Gnome + gnome.gnome-tweaks + adw-gtk3 + + nixGLIntel + + # Fonts + (nerdfonts.override {fonts = ["JetBrainsMono"];}) + + unstable.nix-output-monitor + + chezmoi + + # backup + restic + libnotify + + distrobox + discord + + wl-clipboard + usbutils + + yadm + + # Shell + bash + starship + ripgrep + fh + fd + glow + unstable.helix + gitoxide + lnav + + fzf + zoxide + + # Software Dev + tig + mold + + # Office + libreoffice + obsidian + + # language servers + efm-langserver + sumneko-lua-language-server + nil + alejandra + lemminx + pylyzer + ltex-ls # Spell checker + ]; + + programs.gnome-shell = { + enable = true; + extensions = [ + # {package = pkgs.gnomeExtensions.appindicator;} + {package = pkgs.gnomeExtensions.ddterm;} + {package = pkgs.gnomeExtensions.gsconnect;} + {package = pkgs.gnomeExtensions.paperwm;} + {package = pkgs.gnomeExtensions.night-theme-switcher;} + {package = pkgs.gnomeExtensions.blur-my-shell;} + ]; + }; + + programs.alacritty = { + enable = true; + package = config.lib.nixGL.wrap pkgs.alacritty; + }; + + programs.wezterm = { + enable = true; + package = config.lib.nixGL.wrap pkgs.wezterm; + extraConfig = '' + return { + font_size=9.25, + color_scheme="catppuccin-latte", + hide_tab_bar_if_only_one_tab = true, + window_frame = { + font_size = 10 + }, + } + ''; + }; + + programs.bat = { + enable = true; + config = { + theme = "GitHub"; + }; + }; + + programs.zellij = { + enable = true; + }; + + programs.broot = { + enable = true; + enableFishIntegration = true; + }; + + programs.starship = { + enable = true; + }; + + programs.eza = { + enable = true; + enableFishIntegration = true; + }; + + programs.direnv = { + enable = true; + }; + + programs.thefuck = { + enable = true; + enableFishIntegration = true; + enableInstantMode = true; + }; + + programs.yazi = { + enable = true; + package = pkgs.unstable.yazi; + enableFishIntegration = true; + shellWrapperName = "y"; + }; + + systemd.user.services = { + daily_backup = { + Unit = { + Description = "Run a backup script"; + }; + Install = { + WantedBy = ["default.target"]; + }; + + Service = { + Type = "oneshot"; + ExecStart = "${home.homeDirectory}/.local/bin/,daily_backup"; + }; + }; + }; + + services.darkman = { + enable = true; + package = pkgs.unstable.darkman; + settings = { + lat = 45.408; + lng = -74.159; + }; + + darkModeScripts = { + helix-editor = '' + sed -i 's/theme = ".*"/theme = "catppuccin_macchiato"/' $HOME/.config/helix/config.toml + ''; + + alacritty = '' + ln -fs ~/.config/alacritty/themes/catppuccin_macchiato.toml ~/.config/alacritty/themes/_active.toml + touch ~/.config/alacritty/alacritty.toml + ''; + }; + + lightModeScripts = { + helix-editor = '' + sed -i 's/theme = ".*"/theme = "catppuccin_latte"/' $HOME/.config/helix/config.toml + ''; + + alacritty = '' + ln -fs ~/.config/alacritty/themes/catppuccin_latte.toml ~/.config/alacritty/themes/_active.toml + touch ~/.config/alacritty/alacritty.toml + ''; + }; + }; + + home.stateVersion = "23.11"; + programs.home-manager.enable = true; +} diff --git a/dot_config/home-manager/home/fish.nix b/dot_config/home-manager/home/fish.nix new file mode 100644 index 0000000..c925251 --- /dev/null +++ b/dot_config/home-manager/home/fish.nix @@ -0,0 +1,74 @@ +{pkgs, ...}: { + programs.fish = { + enable = true; + interactiveShellInit = '' + set -gx EDITOR hx + set -gx GIT_EDITOR $EDITOR + set -gx DEBEMAIL "tyler@tylermayoff.com" + + fish_add_path $HOME/.local/bin + + source $HOME/.config/fish/variables-$(hostname).fish + bind \cz 'fg 2>/dev/null; commandline -f repaint' + + zoxide init fish | source + ''; + + shellInit = '' + set -gx EDITOR hx + set -gx GIT_EDITOR $EDITOR + set -gx DEBEMAIL "tyler@tylermayoff.com" + + set -xg XDG_DATA_DIRS "$HOME/.nix-profile/share:$XDG_DATA_DIRS" + + fish_add_path $HOME/.local/bin + source $HOME/.config/fish/variables-$(hostname).fish + ''; + + # functions = { + # yupdate = { + # body = '' + # echo "Hello world" + # ''; + # }; + # }; + + plugins = [ + { + name = "forgit"; + src = pkgs.fishPlugins.forgit.src; + } + ]; + + shellAliases = { + # ls + ls = "eza $eza_params"; + l = "eza --git-ignore $eza_params"; + ll = "eza --all --header --long $eza_params"; + llm = "eza --all --header --long --sort=modified $eza_params"; + la = "eza -lbhHigUmuSa"; + lx = "eza -lbhHigUmuSa@"; + lt = "eza --tree $eza_params"; + tree = "eza --tree $eza_params"; + + # Git + gc = "git commit"; + gcm = "git commit -m"; + gac = "git add . && git commit"; + gacp = "gac && git push"; + gs = "git status"; + + # yac = "yadm add . && yadm commit"; + # yacp = "yac && yadm push"; + yc = "pushd $HOME/.local/share/yadm/repo.git && git-forgit add && yadm commit && popd"; + yd = "pushd $HOME/.local/share/yadm/repo.git && git-forgit diff && popd"; + + # nix + flake = "nix flake"; + + # home-manager + hm-upgrade = "nix flake update --flake ~/.config/home-manager#"; + hm-update = "home-manager switch"; + }; + }; +} diff --git a/dot_config/home-manager/home/guidebolt/guidebolt.nix b/dot_config/home-manager/home/guidebolt/guidebolt.nix new file mode 100644 index 0000000..d68916d --- /dev/null +++ b/dot_config/home-manager/home/guidebolt/guidebolt.nix @@ -0,0 +1,16 @@ +{ + inputs, + outputs, + lib, + config, + pkgs, + ... +}: { + imports = [../common.nix]; + + home.packages = with pkgs; [ + # clang_17 + # clang-tools + just + ]; +} diff --git a/dot_config/home-manager/home/nom.nix b/dot_config/home-manager/home/nom.nix new file mode 100644 index 0000000..b2696c2 --- /dev/null +++ b/dot_config/home-manager/home/nom.nix @@ -0,0 +1,187 @@ +{ config, pkgs, lib, ... }: + +let + collectPathArgs = '' + paths=() + while [ "$#" -gt 0 ]; do + arg="$1" + [[ "$arg" =~ ^--?.+ ]] && break + paths+=("$arg"); shift + done + ''; + pathArgs = ''"''${paths[@]}"''; + collectFlakeFlags = '' + flakeFlags=() + while [ "$#" -gt 0 ]; do + arg="$1" + case "$arg" in + ${ + builtins.concatStringsSep "|" [ + "build" + "bundle" + "copy" + "daemon" + "derivation" + "develop" + "doctor" + "edit" + "eval" + "flake" + "fmt" + "hash" + "help" + "help-stores" + "key" + "log" + "nar" + "path-info" + "print-dev-env" + "profile" + "realisation" + "registry" + "repl" + "run" + "search" + "shell" + "show-config" + "store" + "upgrade-nix" + "why-depends" + ] + }) + break + ;; + *) + flakeFlags+=("$arg"); shift + ;; + esac + done + ''; + flakeFlags = ''"''${flakeFlags[@]}"''; + nixNomArgs = "--log-format internal-json --verbose"; + nixBuildCmdWithNomArgs = buildCmd: '' + ${collectPathArgs} + ${buildCmd} ${pathArgs} ${nixNomArgs} "$@" + ''; + nixShellCmdWithNomArgs = shellCmd: '' + ${shellCmd} ${nixNomArgs} "$@" + ''; + nixStoreCmdWithNomArgs = storeCmd: '' + operation="$1"; shift + case "$operation" in + --realise|-r) + ${collectPathArgs} + ${storeCmd} "$operation" ${pathArgs} ${nixNomArgs} "$@" + ;; + *) + ${storeCmd} "$operation" "$@" + ;; + esac + ''; + nixWithNomArgs = nix: + pkgs.symlinkJoin { + name = "nix-with-nom-args-${nix.version}"; + paths = (lib.attrsets.mapAttrsToList pkgs.writeShellScriptBin { + nix = '' + program="$(basename $0)" + case "$program" in + nix) + ${collectFlakeFlags} + command="$1"; shift + case "$command" in + build) + ${nixBuildCmdWithNomArgs "${nix}/bin/nix ${flakeFlags} build"} + ;; + shell) + ${nixShellCmdWithNomArgs "${nix}/bin/nix ${flakeFlags} shell"} + ;; + store) + ${nixStoreCmdWithNomArgs "${nix}/bin/nix ${flakeFlags} store"} + ;; + *) + ${nix}/bin/nix ${flakeFlags} "$command" "$@" + ;; + esac + ;; + *) + "${nix}/bin/$program" "$@" + ;; + esac + ''; + # nix-build = nixBuildCmdWithNomArgs "${nix}/bin/nix-build"; + nix-shell = nixShellCmdWithNomArgs "${nix}/bin/nix-shell"; + nix-store = nixStoreCmdWithNomArgs "${nix}/bin/nix-store"; + }) ++ [ nix ]; + }; + nixNomPkgs = { nix ? null, nixos-rebuild ? null, home-manager ? null }: + lib.attrsets.mapAttrs pkgs.writeShellScriptBin ((if nix != null then { + nix = '' + program="$(basename $0)" + case "$program" in + nix) + ${collectFlakeFlags} + command="$1"; shift + case "$command" in + build|shell|develop) + ${pkgs.nix-output-monitor}/bin/nom ${flakeFlags} "$command" "$@" + ;; + *) + ${nix}/bin/nix ${flakeFlags} "$command" "$@" + ;; + esac + ;; + *) + "${nix}/bin/$program" "$@" + ;; + esac + ''; + # nix-build = '' + # ${pkgs.nix-output-monitor}/bin/nom-build "$@" + # ''; + nix-shell = '' + ${pkgs.nix-output-monitor}/bin/nom-shell "$@" + ''; + nix-store = '' + ${nixWithNomArgs nix}/bin/nix-store "$@" \ + |& ${pkgs.nix-output-monitor}/bin/nom --json + ''; + } else + { }) // (if nixos-rebuild != null then { + nixos-rebuild = '' + ${pkgs.expect}/bin/unbuffer \ + ${ + nixos-rebuild.override (old: { nix = nixWithNomArgs old.nix; }) + }/bin/nixos-rebuild "$@" \ + |& ${pkgs.nix-output-monitor}/bin/nom --json + ''; + } else + { }) // (if home-manager != null then { + home-manager = '' + PATH="${nixWithNomArgs pkgs.nix}/bin:$PATH" \ + ${pkgs.expect}/bin/unbuffer \ + ${home-manager}/bin/home-manager "$@" \ + |& ${pkgs.nix-output-monitor}/bin/nom --json + ''; + } else + { })); + nomAliases = pkgs: + lib.attrsets.mapAttrs (name: pkg: "${pkg}/bin/${name}") (nixNomPkgs pkgs); + wrapWithNom = let inherit (pkgs) symlinkJoin; + in (pkgs: + symlinkJoin { + name = "wrapped-with-nom"; + paths = (builtins.attrValues (nixNomPkgs pkgs)) + ++ (builtins.attrValues pkgs); + }); + +in { + # home.shellAliases = + # nomAliases { inherit (pkgs) nix nixos-rebuild home-manager; }; + + # or + + # home.packages = [ + # (lib.hiPrio + # (wrapWithNom { inherit (pkgs) nix nixos-rebuild home-manager; })) + # ]; +} diff --git a/dot_config/home-manager/home/nushell.nix b/dot_config/home-manager/home/nushell.nix new file mode 100644 index 0000000..23af502 --- /dev/null +++ b/dot_config/home-manager/home/nushell.nix @@ -0,0 +1,44 @@ +{pkgs, ...}: { + programs.nushell = { + enable = true; + + envFile = { + text = '' + $env.EDITOR = hx + $env.GIT_EDITOR = $env.EDITOR + $env.DEBMAIL = "tyler@tylermayoff.com" + $env.XDG_CONFIG_HOME = "$HOME/.config" + $env.XDG_CACHE_HOME = "$HOME/.cache" + $env.XDG_DATA_HOME = "$HOME/.local/share" + $env.XDG_STATE_HOME = "$HOME/.local/state" + + zoxide init nushell | save -f ~/.config/nushell/zoxide.nu + ''; + }; + + shellAliases = { + # Git + gc = "git commit"; + gcm = "git commit -m"; + gac = "git add . and git commit"; + gacp = "gac and git push"; + gs = "git status"; + + yac = "yadm add --interactive and yadm commit"; + yacp = "yac and yadm push"; + + # nix + flake = "nix flake"; + + # home-manager + hm-upgrade = "nix flake update --flake ~/.config/home-manager/"; + hm-update = "home-manager switch --impure"; + }; + + configFile = { + text = '' + source ~/.config/nushell/zoxide.nu + ''; + }; + }; +} diff --git a/dot_config/home-manager/home/wash/wash.nix b/dot_config/home-manager/home/wash/wash.nix new file mode 100644 index 0000000..006e46c --- /dev/null +++ b/dot_config/home-manager/home/wash/wash.nix @@ -0,0 +1,7 @@ +{pkgs, ...}: { + imports = [../common.nix]; + + home.packages = with pkgs; [ + ventoy + ]; +} diff --git a/dot_config/home-manager/neovim.nix b/dot_config/home-manager/neovim.nix new file mode 100644 index 0000000..5f83912 --- /dev/null +++ b/dot_config/home-manager/neovim.nix @@ -0,0 +1,52 @@ +{pkgs, ...}: { + programs.neovim = { + # package = pkgs.neovim-nightly; + enable = false; + defaultEditor = false; + viAlias = true; + vimAlias = true; + vimdiffAlias = true; + + plugins = with pkgs.vimPlugins; [ + # Color schemes + rose-pine + gruvbox-nvim + + cmp-buffer + cmp-path + cmp_luasnip + cmp-nvim-lua + cmp-nvim-lsp + + friendly-snippets + glow-nvim + + nvim-tree-lua + + luasnip + lsp-zero-nvim + nvim-dap + nvim-dap-ui + + copilot-vim + + todo-comments-nvim + nvim-treesitter-context + nvim-treesitter.withAllGrammars + nvim-lspconfig + nvim-cmp + harpoon + undotree + #mini-nvim + formatter-nvim + telescope-nvim + vim-fugitive + + vim-just + ]; + + #extraConfig = '' + # builtins.readFile /home/jayne/.config/nvim/extra_init.vim + #''; + }; +} diff --git a/dot_config/home-manager/nixos/mal/configuration.nix b/dot_config/home-manager/nixos/mal/configuration.nix new file mode 100644 index 0000000..a655f2e --- /dev/null +++ b/dot_config/home-manager/nixos/mal/configuration.nix @@ -0,0 +1,179 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page, on +# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). +{ + inputs, + outputs, + config, + lib, + pkgs, + ... +}: { + imports = [ + # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + nixpkgs = { + overlays = [ + outputs.overlays.additions + outputs.overlays.modifications + outputs.overlays.unstable-packages + ]; + + config = { + allowUnfree = true; + }; + }; + + nix = let + flakeInputs = lib.filterAttrs (_: lib.isType "flake") inputs; + in { + settings = { + experimental-features = ["nix-command" "flakes"]; + }; + + channel.enable = false; + + registry = lib.mapAttrs (_: flake: {inherit flake;}) flakeInputs; + nixPath = lib.mapAttrsToList (n: _: "${n}=flake:${n}") flakeInputs; + }; + + # Use the systemd-boot EFI boot loader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + networking.hostName = "mal"; # Define your hostname. + # 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. + + # Set your time zone. + # time.timeZone = "Europe/Amsterdam"; + + # Configure network proxy if necessary + # networking.proxy.default = "http://user:password@proxy:port/"; + # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + # Select internationalisation properties. + # i18n.defaultLocale = "en_US.UTF-8"; + # console = { + # font = "Lat2-Terminus16"; + # keyMap = "us"; + # useXkbConfig = true; # use xkb.options in tty. + # }; + + # Enable the X11 windowing system. + # services.xserver.enable = true; + + # Configure keymap in X11 + services.xserver.xkb.layout = "us"; + # services.xserver.xkb.options = "eurosign:e,caps:escape"; + + # Enable CUPS to print documents. + # services.printing.enable = true; + + # Enable sound. + # hardware.pulseaudio.enable = true; + # OR + # services.pipewire = { + # enable = true; + # pulse.enable = true; + # }; + + # Enable touchpad support (enabled default in most desktopManager). + # services.libinput.enable = true; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.tyler = { + isNormalUser = true; + extraGroups = ["wheel"]; # Enable ‘sudo’ for the user. + shell = pkgs.fish; + }; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + helix # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. + wget + yadm + restic + ]; + + # Some programs need SUID wrappers, can be configured further or are + # started in user sessions. + # programs.mtr.enable = true; + # programs.gnupg.agent = { + # enable = true; + # enableSSHSupport = true; + # }; + + systemd.timers."backup-serenity"= { + timerConfig = { + OnCalendar = "monthly"; + Persistent = true; + Unit = "backup-serenity.service"; + }; + }; + + systemd.services."backup-serenity"= { + script = '' + # Remove keys + ${./secrets.sh} + printf "\nBacking up nextcloud \n" + ${pkgs.restic} -r "$RESTIC_REPOSITORY/NextCloud" backup --verbose --no-scan /mnt/user/NextCloud + ${pkgs.restic} -r "$RESTIC_REPOSITORY/NextCloud" check --verbose + + printf "\nBacking up Backups \n" + ${pkgs.restic} -r "$RESTIC_REPOSITORY/Backups" backup --verbose --no-scan /mnt/user/Backups + ${pkgs.restic} -r "$RESTIC_REPOSITORY/Backups" check --verbose + + printf "\nBacking up appdata \n" + ${pkgs.restic} -r "$RESTIC_REPOSITORY/Appdata" backup --verbose --no-scan /mnt/user/appdata + ${pkgs.restic} -r "$RESTIC_REPOSITORY/Appdata" check --verbose + ''; + serviceConfig = { + Type = "oneshot"; + User = "root"; + }; + }; + + + + programs.fish.enable = true; + + # List services that you want to enable: + + # Enable the OpenSSH daemon. + services.openssh.enable = true; + + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; + + # 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; + + # This option defines the first version of NixOS you have installed on this particular machine, + # and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions. + # + # Most users should NEVER change this value after the initial install, for any reason, + # even if you've upgraded your system to a new NixOS release. + # + # This value does NOT affect the Nixpkgs version your packages and OS are pulled from, + # so changing it will NOT upgrade your system - see https://nixos.org/manual/nixos/stable/#sec-upgrading for how + # to actually do that. + # + # This value being lower than the current NixOS release does NOT mean your system is + # out of date, out of support, or vulnerable. + # + # Do NOT change this value unless you have manually inspected all the changes it would make to your configuration, + # and migrated your data accordingly. + # + # For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion . + system.stateVersion = "24.05"; # Did you read the comment? +} diff --git a/dot_config/home-manager/nixos/mal/hardware-configuration.nix b/dot_config/home-manager/nixos/mal/hardware-configuration.nix new file mode 100644 index 0000000..823f79b --- /dev/null +++ b/dot_config/home-manager/nixos/mal/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 + "/profiles/qemu-guest.nix") + ]; + + boot.initrd.availableKernelModules = ["uhci_hcd" "ehci_pci" "ahci" "virtio_pci" "sr_mod" "virtio_blk"]; + boot.initrd.kernelModules = []; + boot.kernelModules = ["kvm-amd"]; + boot.extraModulePackages = []; + + fileSystems."/" = { + device = "/dev/disk/by-uuid/b44df0dd-174f-47b0-af88-fd66c6e7deb5"; + fsType = "ext4"; + }; + + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/5564-A778"; + fsType = "vfat"; + options = ["fmask=0022" "dmask=0022"]; + }; + + 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.enp1s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; +} diff --git a/dot_config/home-manager/nixos/mal/private_secrets.sh b/dot_config/home-manager/nixos/mal/private_secrets.sh new file mode 100644 index 0000000..a32eb58 --- /dev/null +++ b/dot_config/home-manager/nixos/mal/private_secrets.sh @@ -0,0 +1,6 @@ +***REMOVED*** +***REMOVED*** +***REMOVED*** +***REMOVED*** +***REMOVED*** + diff --git a/dot_config/home-manager/nushell.nix b/dot_config/home-manager/nushell.nix new file mode 100644 index 0000000..6cfa022 --- /dev/null +++ b/dot_config/home-manager/nushell.nix @@ -0,0 +1,15 @@ +{pkgs, ...}: { + programs.nushell = { + enable = true; + + envFile = '' + $env.EDITOR = hx + $env.GIT_EDITOR = $env.EDITOR + $env.DEBMAIL = "tyler@tylermayoff.com" + $env.XDG_CONFIG_HOME = "$HOME/.config" + $env.XDG_CACHE_HOME = "$HOME/.cache" + $env.XDG_DATA_HOME = "$HOME/.local/share" + $env.XDG_STATE_HOME = "$HOME/.local/state" + ''; + }; +} diff --git a/dot_config/home-manager/overlays/default.nix b/dot_config/home-manager/overlays/default.nix new file mode 100644 index 0000000..320ed60 --- /dev/null +++ b/dot_config/home-manager/overlays/default.nix @@ -0,0 +1,12 @@ +{inputs, ...}: { + additions = final: _prev: import ../pkgs final.pkgs; + + modifications = final: prev: {}; + + unstable-packages = final: _prev: { + unstable = import inputs.nixpkgs-unstable { + system = final.system; + config.allowUnfree = true; + }; + }; +} diff --git a/dot_config/home-manager/package.nix b/dot_config/home-manager/package.nix new file mode 100644 index 0000000..45a4a07 --- /dev/null +++ b/dot_config/home-manager/package.nix @@ -0,0 +1,2 @@ +final: prev: { +} diff --git a/dot_config/home-manager/pkgs/default.nix b/dot_config/home-manager/pkgs/default.nix new file mode 100644 index 0000000..5d56bdc --- /dev/null +++ b/dot_config/home-manager/pkgs/default.nix @@ -0,0 +1,2 @@ +pkgs: { +} diff --git a/dot_config/home-manager/symlink_result b/dot_config/home-manager/symlink_result new file mode 100644 index 0000000..a891007 --- /dev/null +++ b/dot_config/home-manager/symlink_result @@ -0,0 +1 @@ +/nix/store/x4vzxk2s9vr08kb9iybhhjy4nvsy4zgj-home-manager diff --git a/private_dot_local/bin/executable_,daily_backup b/private_dot_local/bin/executable_,daily_backup new file mode 100644 index 0000000..17faeb0 --- /dev/null +++ b/private_dot_local/bin/executable_,daily_backup @@ -0,0 +1,41 @@ +#!/bin/env fish + +set current_date $(date +%Y-%m-%d) + +set log_dir "$XDG_STATE_HOME/logs/backups" +set log_file "$log_dir/backup_$current_date.log" + +set last $(restic snapshots | tail -3 | head -1 | awk '{print $2}') +if test $status != 0 + echo "can't find last snapshot" | tee -a $log_file + notify-send -a "backup" "Failed to get last snapshot for backups" -u critical + exit $status +end + +function exit_handler + # Restore std... + # exec 2>&4 1>&3 +end + +# Setup logging +mkdir -p $log_dir || true + +trap exit_handler 0 1 2 3 + +printf "Current date: %s. Last snapshot: %s\n" $current_date $last | tee -a $log_file + +if test "$last" != "$current_date" + set not_id $(notify-send -a "backup" "Daily backup $current_date started." -p) + restic backup -v "$HOME" --exclude-file "$XDG_CONFIG_HOME/restic/ignore" | tee -a $log_file + if test $status != 0 + echo "Backup failed." | tee -a $log_file + notify-send -a "backup" "Backup $current_date failed!" -u critical -r $not_id + exit $status + end + + printf "Backup success\n." | tee -a $log_file + + notify-send -a "backup" "Daily backup $current_date succeeded." -r $not_id +else + printf "No backup needed" | tee -a $log_file +end diff --git a/private_dot_local/bin/executable_,git-prune b/private_dot_local/bin/executable_,git-prune new file mode 100644 index 0000000..79930d2 --- /dev/null +++ b/private_dot_local/bin/executable_,git-prune @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +echo "Cleaning remote branches" +git remote prune origin +echo "Cleaning local branches" +git for-each-ref --format '%(refname:short)' refs/heads | grep -v master | xargs git branch -D diff --git a/private_dot_local/bin/executable_,restic-backup.sh b/private_dot_local/bin/executable_,restic-backup.sh new file mode 100644 index 0000000..d42429f --- /dev/null +++ b/private_dot_local/bin/executable_,restic-backup.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +restic backup "$HOME" --exclude-file "$XDG_CONFIG_HOME"/restic/ignore --exclude-caches +restic unlock +restic forget --keep-daily 7 --keep-weekly 4 --prune diff --git a/private_dot_local/bin/executable_,restic-lastbackup.sh b/private_dot_local/bin/executable_,restic-lastbackup.sh new file mode 100644 index 0000000..5a8c8d2 --- /dev/null +++ b/private_dot_local/bin/executable_,restic-lastbackup.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +restic snapshots | tail -3 | head -1 | awk '{print "Last backup: " $2 " " $3}' +restic check diff --git a/private_dot_local/bin/executable_,yupdate.fish b/private_dot_local/bin/executable_,yupdate.fish new file mode 100644 index 0000000..650f23f --- /dev/null +++ b/private_dot_local/bin/executable_,yupdate.fish @@ -0,0 +1,10 @@ +#!/usr/bin/env fish + +yadm pull + +pushd $HOME/.local/share/yadm/repo.git +git-forgit add +yadm commit +popd + +yadm push