From 36f866ea9c367f1772c0eabb66377952afac5c21 Mon Sep 17 00:00:00 2001 From: Truxnell <19149206+truxnell@users.noreply.github.com> Date: Sat, 30 Mar 2024 23:58:31 +1100 Subject: [PATCH] chore: re-do home-manager (#42) * docs: add better comments * add deploy-rs * wip * hackz * chore: make gc daily * chore: add --fast for haxing * fix: re-did home-manager --------- Co-authored-by: Truxnell <9149206+truxnell@users.noreply.github.com> --- .taskfiles/nix/Taskfile.yaml | 2 +- flake.nix | 108 +++++++++++-------- nixos/home-manager/.gitkeep | 59 ----------- nixos/home/modules/default.nix | 25 +++++ nixos/home/modules/shell/default.nix | 5 + nixos/home/modules/shell/fish/default.nix | 123 ++++++++++++++++++++++ nixos/home/profiles/global.nix | 30 ++++++ nixos/home/profiles/server.nix | 3 + nixos/home/profiles/workstation.nix | 25 +++++ nixos/modules/nixos/system/nix.nix | 1 + nixos/profiles/role-server.nix | 7 +- nixos/profiles/role-worstation.nix | 10 +- 12 files changed, 294 insertions(+), 104 deletions(-) delete mode 100644 nixos/home-manager/.gitkeep create mode 100644 nixos/home/modules/default.nix create mode 100644 nixos/home/modules/shell/default.nix create mode 100644 nixos/home/modules/shell/fish/default.nix create mode 100644 nixos/home/profiles/global.nix create mode 100644 nixos/home/profiles/server.nix create mode 100644 nixos/home/profiles/workstation.nix diff --git a/.taskfiles/nix/Taskfile.yaml b/.taskfiles/nix/Taskfile.yaml index c3f637c..7f382c8 100644 --- a/.taskfiles/nix/Taskfile.yaml +++ b/.taskfiles/nix/Taskfile.yaml @@ -63,7 +63,7 @@ tasks: - host cmds: - git add . - - nixos-rebuild build --flake "{{.ROOT_DIR}}/#{{.host}}" --impure + - nixos-rebuild build --flake "{{.ROOT_DIR}}/#{{.host}}" --impure --fast - nvd diff /run/current-system result preconditions: - sh: which nix diff --git a/flake.nix b/flake.nix index a39a7a4..e208b4a 100644 --- a/flake.nix +++ b/flake.nix @@ -1,29 +1,37 @@ { - description = "My machines"; + description = "My nixos homelab"; inputs = { # Nixpkgs and unstable nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11"; nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; + + # nix-community hardware quirks + # https://github.com/nix-community nixos-hardware.url = "github:NixOS/nixos-hardware/master"; - # home-manager + # home-manager - home user+dotfile manager + # https://github.com/nix-community/home-manager home-manager = { url = "github:nix-community/home-manager/release-23.11"; inputs.nixpkgs.follows = "nixpkgs"; }; - # sops-nix + # sops-nix - secrets with mozilla sops + # https://github.com/Mic92/sops-nix sops-nix = { url = "github:Mic92/sops-nix"; inputs.nixpkgs.follows = "nixpkgs"; }; - # deploy-rs + # deploy-rs - Remote deployment + # https://github.com/serokell/deploy-rs deploy-rs = { url = "github:serokell/deploy-rs"; inputs.nixpkgs.follows = "nixpkgs"; }; + # VSCode community extensions + # https://github.com/nix-community/nix-vscode-extensions nix-vscode-extensions = { url = "github:nix-community/nix-vscode-extensions"; inputs.nixpkgs.follows = "nixpkgs"; @@ -33,6 +41,7 @@ { self , nixpkgs , sops-nix + , home-manager , ... } @ inputs: @@ -43,27 +52,18 @@ "x86_64-linux" ]; - # import overlays, ready for wrapping in nixossystem - in rec { # Use nixpkgs-fmt for 'nix fmt' formatter = forAllSystems (system: nixpkgs.legacyPackages."${system}".nixpkgs-fmt); - nixosModules = import ./nixos/modules/nixos; - - nixosConfigurations = - with self.lib; + # with self.lib; let - defaultModules = - (builtins.attrValues nixosModules) ++ - [ - sops-nix.nixosModules.sops - ]; specialArgs = { inherit inputs outputs; }; + # Import overlays for building nixosconfig with them. overlays = import ./nixos/overlays { inherit inputs; }; # generate a base nixos configuration with the @@ -73,11 +73,14 @@ , system ? "x86_64-linux" , nixpkgs ? inputs.nixpkgs , hardwareModules ? [ ] + # basemodules is the base of the entire machine building + # here we import all the modules and setup home-manager , baseModules ? [ sops-nix.nixosModules.sops - ./nixos/profiles/global.nix - ./nixos/modules/nixos - ./nixos/hosts/${hostname} + home-manager.nixosModules.home-manager + ./nixos/profiles/global.nix # all machines get a global profile + ./nixos/modules/nixos # all machines get nixos modules + ./nixos/hosts/${hostname} # load this host's config folder for machine-specific config ] , profileModules ? [ ] }: @@ -156,26 +159,49 @@ ]; }; - # # nix build .#images.rpi4 - # rpi4 = nixpkgs.lib.nixosSystem { - # inherit specialArgs; - - # modules = defaultModules ++ [ - # "${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix" - # ./nixos/hosts/images/sd-image - # ]; - # }; - # # nix build .#images.iso - # iso = nixpkgs.lib.nixosSystem { - # inherit specialArgs; - - # modules = defaultModules ++ [ - # "${nixpkgs}/nixos/modules/installer/cd-dvd/channel.nix" - # "${nixpkgs}/nixos/modules/installer/cd-dvd/iso-image.nix" - # ./nixos/hosts/images/cd-dvd - # ]; - # }; }; + + + homeConfigurations = { + + # For servers (no gui) + server = { pkgs, lib, username, ... }: { + imports = [ + ./nixos/home/profiles/global.nix + ./nixos/home/profiles/server.nix + ./nixos/home/modules + ]; + }; + + # For workstations (X11 + awesome) + desktop = { pkgs, lib, username, ... }: { + imports = [ + ./nixos/home/profiles/global.nix + ./nixos/home/profiles/workstation.nix + ./nixos/home/modules + ]; + }; + + # # nix build .#images.rpi4 + # rpi4 = nixpkgs.lib.nixosSystem { + # inherit specialArgs; + + # modules = defaultModules ++ [ + # "${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix" + # ./nixos/hosts/images/sd-image + # ]; + # }; + # # nix build .#images.iso + # iso = nixpkgs.lib.nixosSystem { + # inherit specialArgs; + + # modules = defaultModules ++ [ + # "${nixpkgs}/nixos/modules/installer/cd-dvd/channel.nix" + # "${nixpkgs}/nixos/modules/installer/cd-dvd/iso-image.nix" + # ./nixos/hosts/images/cd-dvd + # ]; + # }; + }; # simple shortcut to allow for easier referencing of correct # key for building images # > nix build .#images.rpi4 @@ -220,11 +246,11 @@ nixtop = nixpkgs.lib.genAttrs (builtins.attrNames inputs.self.nixosConfigurations) (attr: inputs.self.nixosConfigurations.${attr}.config.system.build.toplevel); - # hometop = genAttrs - # (builtins.attrNames inputs.self.homeManagerConfigurations) - # (attr: inputs.self.homeManagerConfigurations.${attr}.activationPackage); + hometop = nixpkgs.lib.genAttrs + (builtins.attrNames inputs.self.homeConfigurations) + (attr: inputs.self.homeManagerConfigurations.${attr}.activationPackage); in - nixtop; # // hometop + nixtop // hometop; }; } diff --git a/nixos/home-manager/.gitkeep b/nixos/home-manager/.gitkeep deleted file mode 100644 index 931d5d3..0000000 --- a/nixos/home-manager/.gitkeep +++ /dev/null @@ -1,59 +0,0 @@ -My home infrastructure, - -![](https://imgur.com/ISNnzgN.png) - -## Structure - -- [flake.nix](flake.nix) (Entrypoint for rebuilding via nixos-rebuild or home-manager) -- [flake.lock](flake.lock) (lockfile for current nix flake state, updated daily via [github action](.github/workflows/main.yml)) - - [home-manager](home-manager) (User level configuration per machine via home-manager) - - [hosts](hosts/README.md) - (Definition of physical/virutal hosts) - - [common](hosts/common) (Role definitions [Desktop, Laptop, Server]) - - [darwin](hosts/common/darwin) (global host configuration used across all darwin hosts) - - [nixos](hosts/common/nixos) (global host configuration used across all NixOS hosts) - - [optional](hosts/common/optional) (optional host configuration used as-needed per host) - - [nas](hosts/nas/README.md) (NixOS NAS server) - - [home](hosts/home/README.md) (NixOS VM running in NAS) - - [cloud](hosts/cloud/README.md) (NixOS VM running in Oracle Cloud) - - [k3s-f](hosts/k3s-f/README.md) (NixOS running on an N100 tiny PC as a k3s node) - - [k3s-g](hosts/k3s-g/README.md) (NixOS running on an N100 tiny PC as a k3s node) - - [k3s-h](hosts/k3s-h/README.md) (NixOS running on an N100 tiny PC as a k3s node) - - [jeffs_laptop](hosts/jeffs_laptop/README.md) (nix-darwin running on a MacBook Pro) - - [jens_laptop](hosts/jens_laptop/README.md) (nix-darwin running on a MacBook Air) - - [work_laptop](hosts/work_laptop/README.md) (nix-darwin running on a MacBook Pro) - - [modules](modules) (Custom NixOS and home-manager modules) - - [overlays](overlays) (Custom overlays, primarily used for packages currently) - - [pkgs](pkgs) (Custom Packages, mainly items not yet in official nixpkgs) -- [shell.nix](shell.nix) (Shell for bootstrapping flake-enabled nix and home-manager) -- [nixpkgs.nix](nixpkgs.nix) (Used by shell.nix - useful to avoid using channels when using legacy nix commands) - -## Background - -Everyone keeps gushing about how amazing Nix is and I want to get in on the hype cycle - -## Goals - -- [x] Learn nix -- [x] Mostly reproduce features from my existing [dotfiles](https://github.com/billimek/dotfiles) -- [x] Replace existing ubunut-based 'home VM' -- [x] Expand usage to other shell environments such as WSL, Macbook, etc -- [x] handle secrets - ideally using 1Password and not SOPS - using git-crypt for now -- [x] try agenix for secrets handling -- [ ] introduce the concept of [impermanence](https://github.com/nix-community/impermanence) where appropriate - -## References - -- [Misterio77/nix-starter-config](https://github.com/Misterio77/nix-starter-configs) -- [How to learn Nix](https://ianthehenry.com/posts/how-to-learn-nix/) -- [home-manager](https://github.com/nix-community/home-manager) -- [Zero to Nix: Everything I Know About Nix & NixOS](https://chetanbhasin.com/articles/zero-to-nix-everything-i-know-about-nix-nixos) -- [Walkthrough of Nix Install and Setup on MacOS (YouTube)](https://www.youtube.com/watch?v=LE5JR4JcvMg) -- [NixOS as a server, part 1: Impermanence](https://guekka.github.io/nixos-server-1/) -- [budimanjojo/dotfiles](https://github.com/budimanjojo/dotfiles/tree/master/nixos) -- [wrmilling/nixos-configuration](https://github.com/wrmilling/nixos-configuration) -- [gshpychka/dotfiles-nix](https://github.com/gshpychka/dotfiles-nix) -- [wimpysworld/nix-config](https://github.com/wimpysworld/nix-config) - -## Old Dotfiles - -Old dotfiles are still accessible in [archive branch](https://github.com/billimek/dotfiles/tree/archive) diff --git a/nixos/home/modules/default.nix b/nixos/home/modules/default.nix new file mode 100644 index 0000000..e31bb52 --- /dev/null +++ b/nixos/home/modules/default.nix @@ -0,0 +1,25 @@ +{ inputs +, config +, ... +}: { + imports = [ + ./shell + ]; + + # Home-manager defaults + config = { + home.stateVersion = "23.11"; + + programs = { + home-manager.enable = true; + git.enable = true; + }; + + xdg.enable = true; + + nixpkgs.config = { + allowUnfree = true; + }; + }; + +} diff --git a/nixos/home/modules/shell/default.nix b/nixos/home/modules/shell/default.nix new file mode 100644 index 0000000..a395ba2 --- /dev/null +++ b/nixos/home/modules/shell/default.nix @@ -0,0 +1,5 @@ +{ ... }: { + imports = [ + ./fish + ]; +} diff --git a/nixos/home/modules/shell/fish/default.nix b/nixos/home/modules/shell/fish/default.nix new file mode 100644 index 0000000..827325b --- /dev/null +++ b/nixos/home/modules/shell/fish/default.nix @@ -0,0 +1,123 @@ +{ config +, pkgs +, lib +, ... +}: +with lib; let + inherit (config.home) username homeDirectory; + cfg = config.myHome.shell.fish; +in +{ + options.myHome.shell.fish = { + enable = mkEnableOption "fish"; + }; + + config = mkMerge [ + (mkIf cfg.enable { + programs.fish = { + enable = true; + + shellAliases = { + m = "less"; + ls = "${pkgs.eza}/bin/eza --group"; + ll = "${pkgs.eza}/bin/eza --long --all --group --header"; + tm = "tmux attach -t (basename $PWD) || tmux new -s (basename $PWD)"; + x = "exit"; + }; + + shellAbbrs = { + dup = "git add . ; darwin-rebuild --flake . switch"; + dupb = "git add . ; darwin-rebuild --flake . build --show-trace ; nvd diff /run/current-system result"; + nup = "git add . ; sudo nixos-rebuild --flake . switch"; + nhup = "nh os switch . --dry"; + nvdiff = "nvd diff /run/current-system result"; + ap = "ansible-playbook"; + apb = "ansible-playbook --ask-become"; + gfp = "git fetch -p && git pull"; + gitp = "git push"; + gitpf = "git push -f"; + tf = "terraform"; + }; + + # functions = { + # brewup = { + # description = "Update homebrew applications"; + # body = builtins.readFile ./functions/brewup.fish; + # }; + # fish_prompt = { + # description = "Set the fish prompt"; + # body = builtins.readFile ./functions/fish_prompt.fish; + # }; + # fish_right_prompt = { + # description = "Set the right prompt"; + # body = builtins.readFile ./functions/fish_right_prompt.fish; + # }; + # fish_title = { + # description = "Set the title"; + # body = builtins.readFile ./functions/fish_title.fish; + # }; + # fwatch = { + # description = "Watch with fish alias support"; + # body = builtins.readFile ./functions/fwatch.fish; + # }; + # git_current_branch = { + # description = "Display the current branch"; + # body = builtins.readFile ./functions/git_current_branch.fish; + # }; + # }; + + interactiveShellInit = '' + # Erase fish_mode_prompt function + functions -e fish_mode_prompt + + function remove_path + if set -l index (contains -i $argv[1] $PATH) + set --erase --universal fish_user_paths[$index] + end + end + + function update_path + if test -d $argv[1] + fish_add_path -m $argv[1] + else + remove_path $argv[1] + end + end + + # Paths are in reverse priority order + update_path /opt/homebrew/opt/postgresql@16/bin + update_path /opt/homebrew/bin + update_path ${homeDirectory}/.krew/bin + update_path /nix/var/nix/profiles/default/bin + update_path /run/current-system/sw/bin + update_path /etc/profiles/per-user/${username}/bin + update_path /run/wrappers/bin + update_path ${homeDirectory}/.nix-profile/bin + update_path ${homeDirectory}/go/bin + update_path ${homeDirectory}/.cargo/bin + update_path ${homeDirectory}/.local/bin + + set -gx EDITOR "nvim" + + set -gx EZA_COLORS "da=1;34:gm=1;34" + set -gx EZA_COLORS 'da=1;34:gm=1;34;di=01;34:ln=01;36:pi=33:so=01;35:bd=01;33:cd=33:or=31:ex=01;32:*.7z=01;31:*.bz2=01;31:*.gz=01;31:*.lz=01;31:*.lzma=01;31:*.lzo=01;31:*.rar=01;31:*.tar=01;31:*.tbz=01;31:*.tgz=01;31:*.xz=01;31:*.zip=01;31:*.zst=01;31:*.zstd=01;31:*.bmp=01;35:*.tiff=01;35:*.tif=01;35:*.TIFF=01;35:*.gif=01;35:*.jpeg=01;35:*.jpg=01;35:*.png=01;35:*.webp=01;35:*.pot=01;35:*.pcb=01;35:*.gbr=01;35:*.scm=01;35:*.xcf=01;35:*.spl=01;35:*.stl=01;35:*.dwg=01;35:*.ply=01;35:*.apk=01;31:*.deb=01;31:*.rpm=01;31:*.jad=01;31:*.jar=01;31:*.crx=01;31:*.xpi=01;31:*.avi=01;35:*.divx=01;35:*.m2v=01;35:*.m4v=01;35:*.mkv=01;35:*.MOV=01;35:*.mov=01;35:*.mp4=01;35:*.mpeg=01;35:*.mpg=01;35:*.sample=01;35:*.wmv=01;35:*.3g2=01;35:*.3gp=01;35:*.gp3=01;35:*.webm=01;35:*.flv=01;35:*.ogv=01;35:*.f4v=01;35:*.3ga=01;35:*.aac=01;35:*.m4a=01;35:*.mp3=01;35:*.mp4a=01;35:*.oga=01;35:*.ogg=01;35:*.opus=01;35:*.s3m=01;35:*.sid=01;35:*.wma=01;35:*.flac=01;35:*.alac=01;35:*.mid=01;35:*.midi=01;35:*.pcm=01;35:*.wav=01;35:*.ass=01;33:*.srt=01;33:*.ssa=01;33:*.sub=01;33:*.git=01;33:*.ass=01;33:*README=33:*README.rst=33:*README.md=33:*LICENSE=33:*COPYING=33:*INSTALL=33:*COPYRIGHT=33:*AUTHORS=33:*HISTORY=33:*CONTRIBUTOS=33:*PATENTS=33:*VERSION=33:*NOTICE=33:*CHANGES=33:*CHANGELOG=33:*log=33:*.txt=33:*.md=33:*.markdown=33:*.nfo=33:*.org=33:*.pod=33:*.rst=33:*.tex=33:*.texttile=33:*.bib=35:*.json=35:*.jsonl=35:*.jsonnet=35:*.libsonnet=35:*.rss=35:*.xml=35:*.fxml=35:*.toml=35:*.yaml=35:*.yml=35:*.dtd=35:*.cbr=35:*.cbz=35:*.chm=35:*.pdf=35:*.PDF=35:*.epub=35:*.awk=35:*.bash=35:*.bat=35:*.BAT=35:*.sed=35:*.sh=35:*.zsh=35:*.vim=35:*.py=35:*.ipynb=35:*.rb=35:*.gemspec=35:*.pl=35:*.PL=35:*.t=35:*.msql=35:*.mysql=35:*.pgsql=35:*.sql=35:*.r=35:*.R=35:*.cljw=35:*.scala=35:*.sc=35:*.dart=35:*.asm=35:*.cl=35:*.lisp=35:*.rkt=35:*.el=35:*.elc=35:*.eln=35:*.lua=35:*.c=35:*.C=35:*.h=35:*.H=35:*.tcc=35:*.c++=35:*.h++=35:*.hpp=35:*.hxx=35:*ii.=35:*.m=35:*.M=35:*.cc=35:*.cs=35:*.cp=35:*.cpp=35:*.cxx=35:*.go=35:*.f=35:*.F=35:*.nim=35:*.nimble=35:*.s=35:*.S=35:*.rs=35:*.scpt=35:*.swift=35:*.vala=35:*.vapi=35:*.hs=35:*.lhs=35:*.zig=35:*.v=35:*.pyc=35:*.tf=35:*.tfstate=35:*.tfvars=35:*.css=35:*.less=35:*.sass=35:*.scss=35:*.htm=35:*.html=35:*.jhtm=35:*.mht=35:*.eml=35:*.coffee=35:*.java=35:*.js=35:*.mjs=35:*.jsm=35:*.jsp=35:*.rasi=35:*.php=35:*.twig=35:*.vb=35:*.vba=35:*.vbs=35:*.Dockerfile=35:*.dockerignore=35:*.Makefile=35:*.MANIFEST=35:*.am=35:*.in=35:*.hin=35:*.scan=35:*.m4=35:*.old=35:*.out=35:*.SKIP=35:*.diff=35:*.patch=35:*.tmpl=35:*.j2=35:*PKGBUILD=35:*config=35:*.conf=35:*.service=31:*.@.service=31:*.socket=31:*.swap=31:*.device=31:*.mount=31:*.automount=31:*.target=31:*.path=31:*.timer=31:*.snapshot=31:*.allow=31:*.swp=31:*.swo=31:*.tmp=31:*.pid=31:*.state=31:*.lock=31:*.lockfile=31:*.pacnew=31:*.un=31:*.orig=31:' + set -gx LSCOLORS "Gxfxcxdxbxegedabagacad" + set -gx LS_COLORS 'di=01;34:ln=01;36:pi=33:so=01;35:bd=01;33:cd=33:or=31:ex=01;32:*.7z=01;31:*.bz2=01;31:*.gz=01;31:*.lz=01;31:*.lzma=01;31:*.lzo=01;31:*.rar=01;31:*.tar=01;31:*.tbz=01;31:*.tgz=01;31:*.xz=01;31:*.zip=01;31:*.zst=01;31:*.zstd=01;31:*.bmp=01;35:*.tiff=01;35:*.tif=01;35:*.TIFF=01;35:*.gif=01;35:*.jpeg=01;35:*.jpg=01;35:*.png=01;35:*.webp=01;35:*.pot=01;35:*.pcb=01;35:*.gbr=01;35:*.scm=01;35:*.xcf=01;35:*.spl=01;35:*.stl=01;35:*.dwg=01;35:*.ply=01;35:*.apk=01;31:*.deb=01;31:*.rpm=01;31:*.jad=01;31:*.jar=01;31:*.crx=01;31:*.xpi=01;31:*.avi=01;35:*.divx=01;35:*.m2v=01;35:*.m4v=01;35:*.mkv=01;35:*.MOV=01;35:*.mov=01;35:*.mp4=01;35:*.mpeg=01;35:*.mpg=01;35:*.sample=01;35:*.wmv=01;35:*.3g2=01;35:*.3gp=01;35:*.gp3=01;35:*.webm=01;35:*.flv=01;35:*.ogv=01;35:*.f4v=01;35:*.3ga=01;35:*.aac=01;35:*.m4a=01;35:*.mp3=01;35:*.mp4a=01;35:*.oga=01;35:*.ogg=01;35:*.opus=01;35:*.s3m=01;35:*.sid=01;35:*.wma=01;35:*.flac=01;35:*.alac=01;35:*.mid=01;35:*.midi=01;35:*.pcm=01;35:*.wav=01;35:*.ass=01;33:*.srt=01;33:*.ssa=01;33:*.sub=01;33:*.git=01;33:*.ass=01;33:*README=33:*README.rst=33:*README.md=33:*LICENSE=33:*COPYING=33:*INSTALL=33:*COPYRIGHT=33:*AUTHORS=33:*HISTORY=33:*CONTRIBUTOS=33:*PATENTS=33:*VERSION=33:*NOTICE=33:*CHANGES=33:*CHANGELOG=33:*log=33:*.txt=33:*.md=33:*.markdown=33:*.nfo=33:*.org=33:*.pod=33:*.rst=33:*.tex=33:*.texttile=33:*.bib=35:*.json=35:*.jsonl=35:*.jsonnet=35:*.libsonnet=35:*.rss=35:*.xml=35:*.fxml=35:*.toml=35:*.yaml=35:*.yml=35:*.dtd=35:*.cbr=35:*.cbz=35:*.chm=35:*.pdf=35:*.PDF=35:*.epub=35:*.awk=35:*.bash=35:*.bat=35:*.BAT=35:*.sed=35:*.sh=35:*.zsh=35:*.vim=35:*.py=35:*.ipynb=35:*.rb=35:*.gemspec=35:*.pl=35:*.PL=35:*.t=35:*.msql=35:*.mysql=35:*.pgsql=35:*.sql=35:*.r=35:*.R=35:*.cljw=35:*.scala=35:*.sc=35:*.dart=35:*.asm=35:*.cl=35:*.lisp=35:*.rkt=35:*.el=35:*.elc=35:*.eln=35:*.lua=35:*.c=35:*.C=35:*.h=35:*.H=35:*.tcc=35:*.c++=35:*.h++=35:*.hpp=35:*.hxx=35:*ii.=35:*.m=35:*.M=35:*.cc=35:*.cs=35:*.cp=35:*.cpp=35:*.cxx=35:*.go=35:*.f=35:*.F=35:*.nim=35:*.nimble=35:*.s=35:*.S=35:*.rs=35:*.scpt=35:*.swift=35:*.vala=35:*.vapi=35:*.hs=35:*.lhs=35:*.zig=35:*.v=35:*.pyc=35:*.tf=35:*.tfstate=35:*.tfvars=35:*.css=35:*.less=35:*.sass=35:*.scss=35:*.htm=35:*.html=35:*.jhtm=35:*.mht=35:*.eml=35:*.coffee=35:*.java=35:*.js=35:*.mjs=35:*.jsm=35:*.jsp=35:*.rasi=35:*.php=35:*.twig=35:*.vb=35:*.vba=35:*.vbs=35:*.Dockerfile=35:*.dockerignore=35:*.Makefile=35:*.MANIFEST=35:*.am=35:*.in=35:*.hin=35:*.scan=35:*.m4=35:*.old=35:*.out=35:*.SKIP=35:*.diff=35:*.patch=35:*.tmpl=35:*.j2=35:*PKGBUILD=35:*config=35:*.conf=35:*.service=31:*.@.service=31:*.socket=31:*.swap=31:*.device=31:*.mount=31:*.automount=31:*.target=31:*.path=31:*.timer=31:*.snapshot=31:*.allow=31:*.swp=31:*.swo=31:*.tmp=31:*.pid=31:*.state=31:*.lock=31:*.lockfile=31:*.pacnew=31:*.un=31:*.orig=31:' + ''; + }; + + home.sessionVariables.fish_greeting = ""; + + programs.nix-index.enable = true; + + programs.fish = { + functions = { + agent = { + description = "Start SSH agent"; + body = builtins.readFile ./functions/agent.fish; + }; + }; + }; + }) + ]; +} diff --git a/nixos/home/profiles/global.nix b/nixos/home/profiles/global.nix new file mode 100644 index 0000000..f83ca9f --- /dev/null +++ b/nixos/home/profiles/global.nix @@ -0,0 +1,30 @@ +{ lib, pkgs, self, config, ... }: +with config; +{ + # services.gpg-agent.pinentryPackage = pkgs.pinentry-qt; + systemd.user.sessionVariables = { + EDITOR = "nvim"; + VISUAL = "nvim"; + ZDOTDIR = "/home/pinpox/.config/zsh"; + }; + + home = { + # Install these packages for my user + packages = with pkgs; [ + eza + htop + unzip + ]; + + sessionVariables = { + # Workaround for alacritty (breaks wezterm and other apps!) + # LIBGL_ALWAYS_SOFTWARE = "1"; + EDITOR = "nvim"; + VISUAL = "nvim"; + ZDOTDIR = "/home/pinpox/.config/zsh"; + }; + + + + }; +} diff --git a/nixos/home/profiles/server.nix b/nixos/home/profiles/server.nix new file mode 100644 index 0000000..88c6f85 --- /dev/null +++ b/nixos/home/profiles/server.nix @@ -0,0 +1,3 @@ +{ lib, pkgs, self, config, ... }: +with config; +{ } diff --git a/nixos/home/profiles/workstation.nix b/nixos/home/profiles/workstation.nix new file mode 100644 index 0000000..f3e526a --- /dev/null +++ b/nixos/home/profiles/workstation.nix @@ -0,0 +1,25 @@ +{ lib, pkgs, self, config, ... }: +with config; +{ + + home = { + # Install these packages for my user + packages = with pkgs; [ + discord + steam + spotify + brightnessctl + + bat + dbus + direnv + git + nix-index + python3 + fzf + ripgrep + + ]; + + }; +} diff --git a/nixos/modules/nixos/system/nix.nix b/nixos/modules/nixos/system/nix.nix index 2f38015..2905ae4 100644 --- a/nixos/modules/nixos/system/nix.nix +++ b/nixos/modules/nixos/system/nix.nix @@ -38,6 +38,7 @@ in gc = mkIf cfg.gc.enable { # garbage collection automatic = cfg.gc.enable; + dates = "daily"; options = "--delete-older-than 7d"; inherit (cfg.gc) persistent; }; diff --git a/nixos/profiles/role-server.nix b/nixos/profiles/role-server.nix index e2ed44f..5b3cb7d 100644 --- a/nixos/profiles/role-server.nix +++ b/nixos/profiles/role-server.nix @@ -1,12 +1,17 @@ -{ config, lib, pkgs, imports, boot, ... }: +{ config, lib, pkgs, imports, boot, self, ... }: # Role for headless servers # covers raspi's, sbc, NUC etc, anything # that is headless and minimal for running services with lib; { + + config = { + # Link in desktop home mamanger profile + home-manager.users.truxnell = self.homeConfigurations.server; + # Enable monitoring for remote scraiping mySystem.services.promMonitoring.enable = true; mySystem.services.rebootRequiredCheck.enable = true; diff --git a/nixos/profiles/role-worstation.nix b/nixos/profiles/role-worstation.nix index 263101b..a97c1f3 100644 --- a/nixos/profiles/role-worstation.nix +++ b/nixos/profiles/role-worstation.nix @@ -1,10 +1,14 @@ -{ config, lib, pkgs, imports, boot, ... }: +{ config, lib, pkgs, imports, boot, self, ... }: # Role for workstations # Covers desktops/laptops, expected to have a GUI and do worloads # Will have home-manager installs with config; { + + # Link in desktop home mamanger profile + home-manager.users.truxnell = self.homeConfigurations.desktop; + mySystem = { de.gnome.enable = true; @@ -34,11 +38,13 @@ with config; services.xserver.enable = true; + environment.systemPackages = with pkgs; [ jq yq btop - unstable.vim + vim + unstable.deploy-rs git dnsutils nix