From 1fb4bf12c8be5bf2a04e498da38fbbff6e1a1457 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Mon, 11 Sep 2023 23:03:07 -0400 Subject: [PATCH 01/22] ignore result symlink --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 68af054..fc8a062 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /.vagrant/ /.vscode/ +/result/ /vendor/ .dccache From 6430f175b20cc1a351fe7ab951ce206a7020ae69 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Fri, 8 Sep 2023 16:49:45 -0400 Subject: [PATCH 02/22] First pass at a Nix flake for my laptop Heavily inspired by these: - https://github.com/zmre/mac-nix-simple-example - https://github.com/dustinlyons/nixos-config --- flake.lock | 187 ++++++++++++++++++++ flake.nix | 57 ++++++ link/nix/vimrc | 1 + modules/darwin/default.nix | 61 +++++++ modules/home-manager/default.nix | 104 +++++++++++ modules/home-manager/files/beanbag.omp.json | 174 ++++++++++++++++++ 6 files changed, 584 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 modules/darwin/default.nix create mode 100644 modules/home-manager/default.nix create mode 100755 modules/home-manager/files/beanbag.omp.json diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..ae02214 --- /dev/null +++ b/flake.lock @@ -0,0 +1,187 @@ +{ + "nodes": { + "brew-src": { + "flake": false, + "locked": { + "lastModified": 1690184446, + "narHash": "sha256-fGjvNY6ON/cdExCfwhfqmHzoxs3AZ0sev7vyBHfPGJo=", + "owner": "Homebrew", + "repo": "brew", + "rev": "3b3300546b5a4e40b74f4ee33cf225cca280defe", + "type": "github" + }, + "original": { + "owner": "Homebrew", + "ref": "4.1.1", + "repo": "brew", + "type": "github" + } + }, + "darwin": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1692248770, + "narHash": "sha256-tZeFpETKQGbgnaSIO1AGWD27IyTcBm4D+A9d7ulQ4NM=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "511177ffe8226c78c9cf6a92a7b5f2df3684956b", + "type": "github" + }, + "original": { + "owner": "lnl7", + "repo": "nix-darwin", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1687709756, + "narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1694375657, + "narHash": "sha256-32X8dcty4vPXx+D4yJPQZBo5hJ1NQikALhevGv6elO4=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "f7848d3e5f15ed02e3f286029697e41ee31662d7", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nix-darwin": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1688307440, + "narHash": "sha256-7PTjbN+/+b799YN7Tk2SS5Vh8A0L3gBo8hmB7Y0VXug=", + "owner": "LnL7", + "repo": "nix-darwin", + "rev": "b06bab83bdf285ea0ae3c8e145a081eb95959047", + "type": "github" + }, + "original": { + "owner": "LnL7", + "repo": "nix-darwin", + "type": "github" + } + }, + "nix-homebrew": { + "inputs": { + "brew-src": "brew-src", + "flake-utils": "flake-utils", + "nix-darwin": "nix-darwin", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1690495710, + "narHash": "sha256-7yF5A16Ayorrpcal74mRB1EqwUAHfXnoCIgDvj+ylgo=", + "owner": "zhaofengli-wip", + "repo": "nix-homebrew", + "rev": "d2738b78fd0f304f5a7ed4764b736ed2c7169b94", + "type": "github" + }, + "original": { + "owner": "zhaofengli-wip", + "repo": "nix-homebrew", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1687274257, + "narHash": "sha256-TutzPriQcZ8FghDhEolnHcYU2oHIG5XWF+/SUBNnAOE=", + "path": "/nix/store/22qgs3skscd9bmrxv9xv4q5d4wwm5ppx-source", + "rev": "2c9ecd1f0400076a4d6b2193ad468ff0a7e7fdc5", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1688049487, + "narHash": "sha256-100g4iaKC9MalDjUW9iN6Jl/OocTDtXdeAj7pEGIRh4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4bc72cae107788bf3f24f30db2e2f685c9298dc9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1694459622, + "narHash": "sha256-PcbBuRJKFxgb+CUQ3sliI5oRaKHHAV+OSTv6GPAccEA=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "bb446a19f77e8d1d0c5ada7069d21a001442fc73", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "darwin": "darwin", + "home-manager": "home-manager", + "nix-homebrew": "nix-homebrew", + "nixpkgs": "nixpkgs_3" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..db1a727 --- /dev/null +++ b/flake.nix @@ -0,0 +1,57 @@ +{ + description = "A flake for all my stuff"; + inputs = { + # Where we get most of our software. Giant mono repo with recipes + # called derivations that say how to build software. + nixpkgs.url = "github:nixos/nixpkgs"; + + # Controls system level software and settings including fonts + darwin = { + url = "github:lnl7/nix-darwin"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + # Manages things in home directory + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + # Manage Homebrew itself + nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew"; + + }; # end inputs + outputs = { self, nixpkgs, darwin, home-manager, nix-homebrew, ... }: { + # This is only set to work with x86 macOS right now... that will need to be updated + darwinConfigurations.Blue-Rock = darwin.lib.darwinSystem { + system = "x86_64-darwin"; + pkgs = import nixpkgs { system = "x86_64-darwin"; }; + modules = [ + nix-homebrew.darwinModules.nix-homebrew + { + nix-homebrew = { + # Install Homebrew under the default prefix + enable = true; + + # User owning the Homebrew prefix + user = "gene.liverman"; + + # Automatically migrate existing Homebrew installations + autoMigrate = true; + }; + } + + ./modules/darwin + + home-manager.darwinModules.home-manager + { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + users."gene.liverman".imports = [ ./modules/home-manager ]; + }; + } + ]; # end modules + }; # end of darwinConfigurations.Blue-Rock + }; +} diff --git a/link/nix/vimrc b/link/nix/vimrc index 4738d06..d9f216d 100644 --- a/link/nix/vimrc +++ b/link/nix/vimrc @@ -13,6 +13,7 @@ Plugin 'elzr/vim-json' " provides syntax highlighting for JSO Plugin 'garbas/vim-snipmate' " provides code snippets Plugin 'godlygeek/tabular' " provides a method for lining things up Plugin 'honza/vim-snippets' " provides snippets for use with vim-snipmate +Plugin 'LnL7/vim-nix' " support for writing Nix expressions in vim Plugin 'MarcWeber/vim-addon-mw-utils' " a utility used by vim-snipmate Plugin 'mrk21/yaml-vim' " provides indentation and syntax highlighting for yaml Plugin 'rbong/vim-flog' " git branch viewer built on fugitive diff --git a/modules/darwin/default.nix b/modules/darwin/default.nix new file mode 100644 index 0000000..a02e0f3 --- /dev/null +++ b/modules/darwin/default.nix @@ -0,0 +1,61 @@ +{ pkgs, ... }: { + nix.extraOptions = '' + # Generated by https://github.com/DeterminateSystems/nix-installer, version 0.11.0. + extra-nix-path = nixpkgs=flake:nixpkgs + experimental-features = nix-command flakes auto-allocate-uids + build-users-group = nixbld + bash-prompt-prefix = (nix:$name)\040 + ''; + + fonts.fontDir.enable = false; # True will uninstall other fonts, false installs, but doesn't uninstall + fonts.fonts = [ (pkgs.nerdfonts.override { fonts = [ + "Hack" + "SourceCodePro" + ]; }) ]; + + programs.zsh.enable = true; + + services.nix-daemon.enable = true; + system.stateVersion = 4; + users.users."gene.liverman".home = "/Users/gene.liverman"; + environment = { + shells = with pkgs; [ bash zsh ]; + loginShell = pkgs.zsh; + pathsToLink = [ + "/Applications" + "/share/zsh" + ]; + systemPackages = with pkgs; [ + coreutils + #adr-tools + chart-testing + colordiff + dog + dos2unix + # dust + + subversion + # git-svn + + gotop + # helm + hub + hugo + + kopia + # kubernetes-cli + kubectx + mas + mtr + nmap + # node + openjdk + rename + tree + watch + wget + yq + ]; + }; +} + diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix new file mode 100644 index 0000000..5277374 --- /dev/null +++ b/modules/home-manager/default.nix @@ -0,0 +1,104 @@ +{ pkgs, ... }: { + home.stateVersion = "23.11"; + # home.packages = with pkgs; [ + # + # ]; + home.sessionVariables = { + CLICLOLOR = 1; + EDITOR = "vim"; + PAGER = "less"; + }; + programs = { + bat.enable = true; + eza.enable = true; + gh.enable = true; + git = { + enable = true; + lfs.enable = true; + }; + go = { + enable = true; + goPath = "go"; + }; + jq.enable = true; + k9s.enable = true; + neovim.enable = true; + oh-my-posh = { + enable = true; + enableZshIntegration = true; + settings = builtins.fromJSON (builtins.unsafeDiscardStringContext (builtins.readFile ./files/beanbag.omp.json)); + }; + vim.enable = true; + zsh = { + enable = true; + enableCompletion = true; + enableAutosuggestions = true; + history.save = 1000000; + history.size = 1000000; + initExtra = '' + [ -f ~/.private-env ] && source ~/.private-env || echo '~/.private-env is missing' + + # Start GPG agent + # Some tips from https://hedberg.io/yubikey-for-ssh/ helped simplify this: + if [[ $(uname) == 'Darwin' ]]; then + # Add GPG Suite binaries to the path: + export PATH=/usr/local/MacGPG2/bin:$PATH + fi + + export GPG_TTY=$(tty) + + if [[ `uname` == 'Linux' ]]; then + alias uwgconnect='nmcli dev wifi connect SecureWest password' + alias uwgforget='nmcli connection delete SecureWest' + alias ykey='sudo systemctl restart pcscd && sudo pkill -9 gpg-agent && source ~/.zshrc; ssh-add -L' + else + alias currentwifi='networksetup -getairportnetwork en0 |cut -d ":" -f2- | cut -d " " -f2-' + alias uwgconnect='networksetup -setairportnetwork en0 SecureWest' + alias uwgforget='networksetup -removepreferredwirelessnetwork en0 SecureWest' + alias ykey='pkill -9 gpg-agent && source ~/.zshrc; ssh-add -L' + fi + if [[ `uname` != 'Linux' ]]; then + function otpon() { + osascript -e 'tell application "yubiswitch" to KeyOn' + } + function otpoff() { + osascript -e 'tell application "yubiswitch" to KeyOff' + } + fi + ''; + oh-my-zsh = { + enable = true; + plugins = [ + "bundler" + "gem" + "git" + "github" + "history" + "kubectl" + "macos" + "pip" + "terraform" + "vagrant" + "vscode" + ]; + }; + shellAliases = { + beo = "bundle exec onceover run spec --trace --force"; + biv = "bundle install --path=vendor/bundle"; + ce = "code-exploration"; + gbc = '' + git branch --merged | command grep -vE "^(\*|\s*(main|master|develop|production)\s*$)" | command xargs -n 1 git branch -d + ''; + gitextract = "git log --pretty=email --patch-with-stat --reverse --full-index --binary --"; + gpge = "gpg2 --encrypt --sign --armor -r "; + hubpr = "hub pull-request --push --browse"; + pssh = "ssh -o 'UserKnownHostsFile /dev/null' -o 'StrictHostKeyChecking no' -o PubkeyAcceptedKeyTypes=+ssh-rsa -o HostKeyAlgorithms=+ssh-rsa -o KexAlgorithms=+diffie-hellman-group1-sha1 -i ~/.ssh/id_rsa-acceptance"; + sal = "ssh-add -L"; + st = "open -a SourceTree"; + sz = "source ~/.zshrc"; + usegpg = "killall ssh-agent; export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) && gpgconf --launch gpg-agent"; + usessh = "gpgconf --kill gpg-agent"; + }; + }; # end zsh + }; +} diff --git a/modules/home-manager/files/beanbag.omp.json b/modules/home-manager/files/beanbag.omp.json new file mode 100755 index 0000000..b0297c6 --- /dev/null +++ b/modules/home-manager/files/beanbag.omp.json @@ -0,0 +1,174 @@ +{ + "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", + "version": 2, + "final_space": true, + "palette": { + "line-connector": "#00ff00", + "hostname": "#62c0ff", + "pwd": "#ffff00", + "git-fg-clean": "#62c0ff", + "git-fg-changed": "#6287ff", + "git-fg-ahead-and-behind": "#7f62ff", + "git-fg-ahead": "#9962ff", + "git-fg-behind": "#c062ff", + "svn-fg-clean": "#62c0ff", + "svn-fg-changed": "#6287ff", + "kubectl-fg": "#62c0ff", + "kubectl-bg": "transparent", + "status-fg-okay": "#00ff00", + "status-fg-error": "#D81E5B", + "secondary-fg": "#00ff00", + + + + "blue": "#4B95E9", + "orange": "#F07623", + "white": "#E0DEF4", + "yellow": "#F3AE35" + }, + "blocks": [ + { + "type": "prompt", + "alignment": "left", + "segments": [ + { + "type": "text", + "style": "plain", + "foreground": "p:line-connector", + "template": "\u2554" + }, + { + "type": "text", + "style": "plain", + "template": " \u2615 " + }, + { + "type": "session", + "style": "plain", + "foreground": "p:hostname", + "template": " {{ (split \".\" .HostName)._0 }}(" + }, + { + "type": "os", + "style": "plain", + "template": "{{ if .WSL }}WSL {{ end }}{{.Icon}}" + }, + { + "type": "session", + "style": "plain", + "foreground": "p:hostname", + "template": "):" + }, + { + "type": "path", + "style": "plain", + "foreground": "p:pwd", + "template": " \uea83 {{ path .Path .Location }}", + "properties": { + "folder_separator_icon": "/", + "style": "full" + } + }, + { + "type": "kubectl", + "style": "powerline", + "powerline_symbol": "\uE0B0", + "foreground": "p:kubectl-fg", + "background": "p:kubectl-bg", + "template": " <#ff8800>(\uFD31 {{.Context}}{{if .Namespace}} :: {{.Namespace}}{{end}}<#ff8800>)" + }, + { + "type": "git", + "style": "plain", + "foreground": "p:git-fg-clean", + "foreground_templates": [ + "{{ if or (.Working.Changed) (.Staging.Changed) }}p:git-fg-changed{{ end }}", + "{{ if and (gt .Ahead 0) (gt .Behind 0) }}p:git-fg-ahead-and-behind{{ end }}", + "{{ if gt .Ahead 0 }}p:git-fg-ahead{{ end }}", + "{{ if gt .Behind 0 }}p:git-fg-behind{{ end }}" + ], + "template": " <#ff8800>on {{ if .UpstreamURL }}{{ url .UpstreamIcon .UpstreamURL }} {{ end }}{{ url .HEAD .Kraken }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }}", + "properties": { + "branch_max_length": 25, + "fetch_stash_count": true, + "fetch_status": true, + "fetch_upstream_icon": true + } + }, + { + "type": "svn", + "style": "plain", + "foreground": "p:svn-fg-clean", + "foreground_templates": [ + "{{ if (.Working.Changed) }}p:svn-fg-changed{{ end }}" + ], + "template": " <#ff8800>on svn \ue0a0{{.Branch}} r{{.BaseRev}}{{ if .Working.Changed }} \uf044 {{.Working.String}}{{ end }}", + "properties": { + "fetch_status": true + } + }, + { + "type": "status", + "style": "diamond", + "foreground": "p:status-fg-okay", + "foreground_templates": [ + "{{ if gt .Code 0 }}p:status-fg-error{{ end }}" + ], + "template": " (exit code {{ .Code }})", + "properties": { + "always_enabled": false + } + } + ] + }, + { + "type": "prompt", + "alignment": "left", + "newline": true, + "segments": [ + { + "foreground": "p:line-connector", + "style": "plain", + "template": "\u255A\u1405", + "type": "text" + } + ] + } + ], + "tooltips": [ + { + "type": "aws", + "tips": [ + "aws" + ], + "style": "diamond", + "foreground": "p:white", + "background": "p:orange", + "leading_diamond": "\ue0b0", + "trailing_diamond": "\ue0b4", + "template": " \ue7ad {{ .Profile }}{{ if .Region }}@{{ .Region }}{{ end }} ", + "properties": { + "display_default": true + } + }, + { + "type": "az", + "tips": [ + "az" + ], + "style": "diamond", + "foreground": "p:white", + "background": "p:blue", + "leading_diamond": "\ue0b0", + "trailing_diamond": "\ue0b4", + "template": " \uebd8 {{ .Name }} ", + "properties": { + "display_default": true + } + } + ], + "secondary_prompt": { + "foreground": "p:secondary-fg", + "template": " " + } +} From ebd0e35dff9b240b204293d0a58314cd39822e1e Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Mon, 11 Sep 2023 19:38:20 -0400 Subject: [PATCH 03/22] Add in NixOS support --- flake.nix | 18 +++ modules/nixos/configuration.nix | 178 +++++++++++++++++++++++ modules/nixos/dconf.nix | 24 +++ modules/nixos/hardware-configuration.nix | 40 +++++ 4 files changed, 260 insertions(+) create mode 100644 modules/nixos/configuration.nix create mode 100644 modules/nixos/dconf.nix create mode 100644 modules/nixos/hardware-configuration.nix diff --git a/flake.nix b/flake.nix index db1a727..575a9d0 100644 --- a/flake.nix +++ b/flake.nix @@ -22,6 +22,24 @@ }; # end inputs outputs = { self, nixpkgs, darwin, home-manager, nix-homebrew, ... }: { + nixosConfigurations.rainbow-planet = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./modules/nixos/configuration.nix + home-manager.nixosModules.home-manager + { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + users."gene".imports = [ + ./modules/home-manager + ./modules/nixos/dconf.nix + ]; + }; + } + ]; + }; # end nixosConfigurations + # This is only set to work with x86 macOS right now... that will need to be updated darwinConfigurations.Blue-Rock = darwin.lib.darwinSystem { system = "x86_64-darwin"; diff --git a/modules/nixos/configuration.nix b/modules/nixos/configuration.nix new file mode 100644 index 0000000..6a62a3c --- /dev/null +++ b/modules/nixos/configuration.nix @@ -0,0 +1,178 @@ +# 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, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + networking.hostName = "rainbow-planet"; # Define your hostname. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # Configure network proxy if necessary + # networking.proxy.default = "http://user:password@proxy:port/"; + # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + # Enable networking + networking.networkmanager.enable = true; + + # Set your time zone. + time.timeZone = "America/New_York"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + + i18n.extraLocaleSettings = { + LC_ADDRESS = "en_US.UTF-8"; + LC_IDENTIFICATION = "en_US.UTF-8"; + LC_MEASUREMENT = "en_US.UTF-8"; + LC_MONETARY = "en_US.UTF-8"; + LC_NAME = "en_US.UTF-8"; + LC_NUMERIC = "en_US.UTF-8"; + LC_PAPER = "en_US.UTF-8"; + LC_TELEPHONE = "en_US.UTF-8"; + LC_TIME = "en_US.UTF-8"; + }; + + # Enable the X11 windowing system. + services.xserver.enable = true; + + # Enable the GNOME Desktop Environment. + services.xserver.displayManager.gdm.enable = true; + services.xserver.desktopManager.gnome.enable = true; + + services.udev.packages = with pkgs; [ + gnome.gnome-settings-daemon + ]; + + # Configure keymap in X11 + services.xserver = { + layout = "us"; + xkbVariant = ""; + }; + + # Enable CUPS to print documents. + services.printing.enable = true; + + # Enable sound with pipewire. + sound.enable = true; + hardware.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + # If you want to use JACK applications, uncomment this + #jack.enable = true; + + # use the example session manager (no others are packaged yet so this is enabled by default, + # no need to redefine it in your config for now) + #media-session.enable = true; + }; + + # Enable touchpad support (enabled default in most desktopManager). + # services.xserver.libinput.enable = true; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.gene = { + isNormalUser = true; + description = "Gene Liverman"; + extraGroups = [ "networkmanager" "wheel" "dialout" ]; + packages = with pkgs; [ + firefox + slack + # thunderbird + ]; + }; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + _1password + _1password-gui + bat + colordiff + dconf2nix + dog + dos2unix + gnomeExtensions.appindicator + gnomeExtensions.caffeine + gnomeExtensions.dash-to-panel + gnomeExtensions.user-themes + gotop + htop + hub + mtr + neofetch + nix-zsh-completions + tilix + tree + vivaldi + watch + wget + jq + ]; + + # 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; + # }; + programs._1password.enable = true; + programs._1password-gui = { + enable = true; + # Certain features, including CLI integration and system authentication support, + # require enabling PolKit integration on some desktop environments (e.g. Plasma). + polkitPolicyOwners = [ "gene" ]; + }; + # 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; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "23.05"; # Did you read the comment? + + nix.settings.allowed-users = [ "gene" ]; + nix.settings.experimental-features = [ + "flakes" + "nix-command" + ]; + + programs.zsh.enable = true; + fonts.fontDir.enable = false; + fonts.packages = [ (pkgs.nerdfonts.override { fonts = [ + "Hack" + "SourceCodePro" + ]; }) ]; + + environment.shells = with pkgs; [ bash zsh ]; + users.defaultUserShell = pkgs.zsh; + + +} diff --git a/modules/nixos/dconf.nix b/modules/nixos/dconf.nix new file mode 100644 index 0000000..4ee7c33 --- /dev/null +++ b/modules/nixos/dconf.nix @@ -0,0 +1,24 @@ +# Generated via dconf2nix: https://github.com/gvolpe/dconf2nix +{ lib, ... }: + +with lib.hm.gvariant; + +{ + dconf.settings = { + "com/gexperts/Tilix/profiles/2b7c4080-0ddd-46c5-8f23-563fd3ba789d" = { + background-color = "#272822"; + background-transparency-percent = 10; + badge-color-set = false; + bold-color-set = false; + cursor-colors-set = false; + font = "Hack Nerd Font Mono 12"; + foreground-color = "#F8F8F2"; + highlight-colors-set = false; + palette = [ "#272822" "#F92672" "#A6E22E" "#F4BF75" "#66D9EF" "#AE81FF" "#A1EFE4" "#F8F8F2" "#75715E" "#F92672" "#A6E22E" "#F4BF75" "#66D9EF" "#AE81FF" "#A1EFE4" "#F9F8F5" ]; + use-system-font = false; + use-theme-colors = false; + visible-name = "Default"; + }; + + }; +} diff --git a/modules/nixos/hardware-configuration.nix b/modules/nixos/hardware-configuration.nix new file mode 100644 index 0000000..4e6b1a3 --- /dev/null +++ b/modules/nixos/hardware-configuration.nix @@ -0,0 +1,40 @@ +# 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" "nvme" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/eb9a2c7e-ae61-4d06-9464-49b98d576f7c"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/924D-E7A4"; + fsType = "vfat"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/166d24ca-401c-492e-845d-bb1d0d6d7d86"; } + ]; + + # 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.wlp58s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} From 3ab9ca59882507f273f8d8fb3686b24720596270 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Mon, 11 Sep 2023 23:15:38 -0400 Subject: [PATCH 04/22] NixOS: Don't require sudo password for wheel group --- modules/nixos/configuration.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/nixos/configuration.nix b/modules/nixos/configuration.nix index 6a62a3c..aca022c 100644 --- a/modules/nixos/configuration.nix +++ b/modules/nixos/configuration.nix @@ -94,6 +94,8 @@ ]; }; + security.sudo.wheelNeedsPassword = false; + # Allow unfree packages nixpkgs.config.allowUnfree = true; From c7ce4cccd9b182edc882a16a6ca0736b02e3a2d5 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Tue, 12 Sep 2023 00:00:22 -0400 Subject: [PATCH 05/22] Setup Vim This mirrors what is in link/nix/vimrc --- modules/home-manager/default.nix | 68 +++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index 5277374..07d4292 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -5,7 +5,6 @@ # ]; home.sessionVariables = { CLICLOLOR = 1; - EDITOR = "vim"; PAGER = "less"; }; programs = { @@ -28,7 +27,72 @@ enableZshIntegration = true; settings = builtins.fromJSON (builtins.unsafeDiscardStringContext (builtins.readFile ./files/beanbag.omp.json)); }; - vim.enable = true; + vim = { + enable = true; + defaultEditor = true; + plugins = with pkgs.vimPlugins; [ + vim-json + vim-snipmate + tabular + vim-snippets + vim-nix + vim-addon-mw-utils + vim-yaml + vim-flog + vim-puppet + tlib_vim + vim-fugitive + vim-airline + vim-airline-themes + vim-ruby + syntastic + ]; + settings = { + background = "dark"; + expandtab = true; + }; + extraConfig = '' + set nocompatible " be iMproved, required + filetype plugin indent on " required for plugins to be able to adjust indent + syntax on " enable syntax highlighting + set encoding=utf-8 + set termencoding=utf-8 + set t_Co=256 " tell vim we have 256 colors to work with + + set autoindent " automatically indent new lines + set backspace=2 " make backspace work like most other programs + set fillchars+=stl:\ ,stlnc:\ " fix added per powerline troubleshooting docs + set laststatus=2 " Always display the status line in all windows + set noshowmode " Hide the default mode text (e.g. -- INSERT -- below the status line) + set smarttab " helps with expanding tabs to spaces (I think) + set statusline+=%{FugitiveStatusline()} " get git info via fugitive plugin + set statusline+=%#warningmsg# " recommended setting from syntastic plugin + set statusline+=%{SyntasticStatuslineFlag()} " recommended setting from syntastic plugin + set statusline+=%* " recommended setting from syntastic plugin + + " This has to come after colorscheme, if defined, to not be masked + highlight ColorColumn ctermbg=232 " set the color to be used for guidelines + let &colorcolumn=join(range(81,999),",") " change the background color of everything beyond 80 characters + + let g:snipMate = { 'snippet_version' : 1 } + + " settings for the syntastic plugin + let g:syntastic_always_populate_loc_list = 1 + let g:syntastic_auto_loc_list = 1 + let g:syntastic_check_on_open = 1 + let g:syntastic_check_on_wq = 0 + let g:syntastic_enable_signs = 1 + let g:syntastic_ruby_checkers = ['rubocop'] + let g:syntastic_quiet_messages = {'level': 'warnings'} + + " don't wrap text in markdown files + let g:vim_markdown_folding_disabled = 1 + + " settings for vim-airline + let g:airline_theme='badwolf' + let g:airline_powerline_fonts = 1 + ''; + }; zsh = { enable = true; enableCompletion = true; From f6f9bdba8d1493aaaa574d6f278922a0a523aef1 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Tue, 12 Sep 2023 00:07:51 -0400 Subject: [PATCH 06/22] Enable git delta --- modules/home-manager/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index 07d4292..0812718 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -13,6 +13,7 @@ gh.enable = true; git = { enable = true; + delta.enable = true; lfs.enable = true; }; go = { From 5507d25639f7e4b64afc7246d7860d2e3ea6a550 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Fri, 8 Sep 2023 16:49:45 -0400 Subject: [PATCH 07/22] Setup Homebrew stuff for macOS --- flake.nix | 4 +- modules/darwin/default.nix | 111 ++++++++++++++++++++++++++++--------- 2 files changed, 89 insertions(+), 26 deletions(-) diff --git a/flake.nix b/flake.nix index 575a9d0..2ae8573 100644 --- a/flake.nix +++ b/flake.nix @@ -66,7 +66,9 @@ home-manager = { useGlobalPkgs = true; useUserPackages = true; - users."gene.liverman".imports = [ ./modules/home-manager ]; + users."gene.liverman".imports = [ + ./modules/home-manager + ]; }; } ]; # end modules diff --git a/modules/darwin/default.nix b/modules/darwin/default.nix index a02e0f3..0f9427d 100644 --- a/modules/darwin/default.nix +++ b/modules/darwin/default.nix @@ -1,23 +1,6 @@ { pkgs, ... }: { - nix.extraOptions = '' - # Generated by https://github.com/DeterminateSystems/nix-installer, version 0.11.0. - extra-nix-path = nixpkgs=flake:nixpkgs - experimental-features = nix-command flakes auto-allocate-uids - build-users-group = nixbld - bash-prompt-prefix = (nix:$name)\040 - ''; - - fonts.fontDir.enable = false; # True will uninstall other fonts, false installs, but doesn't uninstall - fonts.fonts = [ (pkgs.nerdfonts.override { fonts = [ - "Hack" - "SourceCodePro" - ]; }) ]; - - programs.zsh.enable = true; - - services.nix-daemon.enable = true; system.stateVersion = 4; - users.users."gene.liverman".home = "/Users/gene.liverman"; + environment = { shells = with pkgs; [ bash zsh ]; loginShell = pkgs.zsh; @@ -27,23 +10,19 @@ ]; systemPackages = with pkgs; [ coreutils - #adr-tools chart-testing colordiff dog dos2unix - # dust - + du-dust subversion # git-svn - gotop # helm hub hugo - kopia - # kubernetes-cli + # kubectl kubectx mas mtr @@ -57,5 +36,87 @@ yq ]; }; -} + fonts.fontDir.enable = false; # True will uninstall other fonts, false installs, but doesn't uninstall + fonts.fonts = [ (pkgs.nerdfonts.override { fonts = [ + "Hack" + "SourceCodePro" + ]; }) ]; + + homebrew = { + enable = true; + onActivation = { + autoUpdate = true; + cleanup = "zap"; + upgrade = true; + }; + taps = [ + "hashicorp/tap" + # "homebrew/bundle" + # "homebrew/cask-fonts" + # "jandedobbeleer/oh-my-posh" + "null-dev/firefox-profile-switcher" + "puppetlabs/puppet" + ]; + brews = [ + "adr-tools" + ]; + casks = [ + "1password" + "amethyst" + "audacity" + "cakebrew" + "elgato-stream-deck" + "firefox" + # "font-hack-nerd-font" + # "font-inconsolata-g-for-powerline" + # "font-source-code-pro-for-powerline" + "google-drive" + "iterm2" + "keepingyouawake" + "kopiaui" + "libreoffice" + "logseq" + "meld" + "nextcloud" + "obs" + "onlyoffice" + "pdk" + "puppet-bolt" + "qmk-toolbox" + "raycast" + "signal" + "slack" + "tailscale" + "thunderbird" + "vagrant" + "virtualbox" + "visual-studio-code" + "vivaldi" + "vlc" + "whatsapp" + "zenmap" + "zoom" + ]; + }; + + nix = { + settings = { + bash-prompt-prefix = "(nix:$name)\040"; + build-users-group = "nixbld"; + experimental-features = [ + "auto-allocate-uids" + "flakes" + "nix-command" + ]; + }; + extraOptions = '' + # Generated by https://github.com/DeterminateSystems/nix-installer, version 0.11.0. + extra-nix-path = nixpkgs=flake:nixpkgs + ''; + }; + + services.nix-daemon.enable = true; + + users.users."gene.liverman".home = "/Users/gene.liverman"; +} From 62588aba262765c388e671f39aa5d40e32921028 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Tue, 12 Sep 2023 11:47:17 -0400 Subject: [PATCH 08/22] Fixing macOS environment and fonts --- flake.lock | 44 +++++++++++++++++++------------------- flake.nix | 6 +++--- modules/darwin/default.nix | 21 +++++++++--------- 3 files changed, 35 insertions(+), 36 deletions(-) diff --git a/flake.lock b/flake.lock index ae02214..95114bf 100644 --- a/flake.lock +++ b/flake.lock @@ -17,26 +17,6 @@ "type": "github" } }, - "darwin": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1692248770, - "narHash": "sha256-tZeFpETKQGbgnaSIO1AGWD27IyTcBm4D+A9d7ulQ4NM=", - "owner": "lnl7", - "repo": "nix-darwin", - "rev": "511177ffe8226c78c9cf6a92a7b5f2df3684956b", - "type": "github" - }, - "original": { - "owner": "lnl7", - "repo": "nix-darwin", - "type": "github" - } - }, "flake-utils": { "inputs": { "systems": "systems" @@ -76,6 +56,26 @@ } }, "nix-darwin": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1694497842, + "narHash": "sha256-z03v/m0OwcLBok97KcUgMl8ZFw5Xwsi2z+n6nL7JdXY=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "4496ab26628c5f43d2a5c577a06683c753e32fe2", + "type": "github" + }, + "original": { + "owner": "lnl7", + "repo": "nix-darwin", + "type": "github" + } + }, + "nix-darwin_2": { "inputs": { "nixpkgs": "nixpkgs" }, @@ -97,7 +97,7 @@ "inputs": { "brew-src": "brew-src", "flake-utils": "flake-utils", - "nix-darwin": "nix-darwin", + "nix-darwin": "nix-darwin_2", "nixpkgs": "nixpkgs_2" }, "locked": { @@ -160,8 +160,8 @@ }, "root": { "inputs": { - "darwin": "darwin", "home-manager": "home-manager", + "nix-darwin": "nix-darwin", "nix-homebrew": "nix-homebrew", "nixpkgs": "nixpkgs_3" } diff --git a/flake.nix b/flake.nix index 2ae8573..8052e07 100644 --- a/flake.nix +++ b/flake.nix @@ -6,7 +6,7 @@ nixpkgs.url = "github:nixos/nixpkgs"; # Controls system level software and settings including fonts - darwin = { + nix-darwin = { url = "github:lnl7/nix-darwin"; inputs.nixpkgs.follows = "nixpkgs"; }; @@ -21,7 +21,7 @@ nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew"; }; # end inputs - outputs = { self, nixpkgs, darwin, home-manager, nix-homebrew, ... }: { + outputs = { self, nixpkgs, nix-darwin, home-manager, nix-homebrew, ... }: { nixosConfigurations.rainbow-planet = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ @@ -41,7 +41,7 @@ }; # end nixosConfigurations # This is only set to work with x86 macOS right now... that will need to be updated - darwinConfigurations.Blue-Rock = darwin.lib.darwinSystem { + darwinConfigurations.Blue-Rock = nix-darwin.lib.darwinSystem { system = "x86_64-darwin"; pkgs = import nixpkgs { system = "x86_64-darwin"; }; modules = [ diff --git a/modules/darwin/default.nix b/modules/darwin/default.nix index 0f9427d..00a04b0 100644 --- a/modules/darwin/default.nix +++ b/modules/darwin/default.nix @@ -37,12 +37,6 @@ ]; }; - fonts.fontDir.enable = false; # True will uninstall other fonts, false installs, but doesn't uninstall - fonts.fonts = [ (pkgs.nerdfonts.override { fonts = [ - "Hack" - "SourceCodePro" - ]; }) ]; - homebrew = { enable = true; onActivation = { @@ -53,7 +47,7 @@ taps = [ "hashicorp/tap" # "homebrew/bundle" - # "homebrew/cask-fonts" + "homebrew/cask-fonts" # "jandedobbeleer/oh-my-posh" "null-dev/firefox-profile-switcher" "puppetlabs/puppet" @@ -68,9 +62,9 @@ "cakebrew" "elgato-stream-deck" "firefox" - # "font-hack-nerd-font" - # "font-inconsolata-g-for-powerline" - # "font-source-code-pro-for-powerline" + "font-hack-nerd-font" + "font-inconsolata-g-for-powerline" + "font-source-code-pro-for-powerline" "google-drive" "iterm2" "keepingyouawake" @@ -116,7 +110,12 @@ ''; }; + programs.zsh.enable = true; + services.nix-daemon.enable = true; - users.users."gene.liverman".home = "/Users/gene.liverman"; + users.users."gene.liverman" = { + home = "/Users/gene.liverman"; + shell = pkgs.zsh; + }; } From 0535cba83b9d42d9443c07c5c278144e8c5c41e4 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Tue, 12 Sep 2023 11:48:11 -0400 Subject: [PATCH 09/22] Further limit "result" symlink from git --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index fc8a062..f7e442f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /.vagrant/ /.vscode/ /result/ +/result /vendor/ .dccache From 645524c898dc55b2fd8585b39c0dab25c7d5077b Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Tue, 12 Sep 2023 15:13:24 -0400 Subject: [PATCH 10/22] More macOS true up work --- modules/darwin/default.nix | 18 +++++++++++++----- modules/home-manager/default.nix | 7 ++++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/modules/darwin/default.nix b/modules/darwin/default.nix index 00a04b0..928f47c 100644 --- a/modules/darwin/default.nix +++ b/modules/darwin/default.nix @@ -15,19 +15,17 @@ dog dos2unix du-dust - subversion - # git-svn + element-desktop gotop - # helm hub hugo kopia - # kubectl kubectx mas mtr nmap - # node + nodejs + nodePackages.npm openjdk rename tree @@ -54,6 +52,8 @@ ]; brews = [ "adr-tools" + "helm" + "kubernetes-cli" ]; casks = [ "1password" @@ -92,6 +92,14 @@ "zenmap" "zoom" ]; + masApps = { + "1Password for Safari" = 1569813296; + "BetterSnapTool" = 417375580; + "Home Assistant" = 1099568401; + "HomeCam" = 1292995895; + "MeetingBar" = 1532419400; + "Microsoft Remote Desktop" = 1295203466; + }; }; nix = { diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index 0812718..ee8f1fc 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -1,8 +1,8 @@ { pkgs, ... }: { home.stateVersion = "23.11"; - # home.packages = with pkgs; [ - # - # ]; + home.packages = with pkgs; [ + subversion + ]; home.sessionVariables = { CLICLOLOR = 1; PAGER = "less"; @@ -15,6 +15,7 @@ enable = true; delta.enable = true; lfs.enable = true; + package = pkgs.gitAndTools.gitFull; }; go = { enable = true; From dc9a8d6ca825a9072ea38080e77ab78e052db65f Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Tue, 12 Sep 2023 15:30:06 -0400 Subject: [PATCH 11/22] Install VS Code via Nix --- flake.nix | 5 ++++- modules/darwin/default.nix | 1 - modules/home-manager/default.nix | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 8052e07..4d354fe 100644 --- a/flake.nix +++ b/flake.nix @@ -43,7 +43,10 @@ # This is only set to work with x86 macOS right now... that will need to be updated darwinConfigurations.Blue-Rock = nix-darwin.lib.darwinSystem { system = "x86_64-darwin"; - pkgs = import nixpkgs { system = "x86_64-darwin"; }; + pkgs = import nixpkgs { + system = "x86_64-darwin"; + config.allowUnfree = true; + }; modules = [ nix-homebrew.darwinModules.nix-homebrew { diff --git a/modules/darwin/default.nix b/modules/darwin/default.nix index 928f47c..7e7f24b 100644 --- a/modules/darwin/default.nix +++ b/modules/darwin/default.nix @@ -85,7 +85,6 @@ "thunderbird" "vagrant" "virtualbox" - "visual-studio-code" "vivaldi" "vlc" "whatsapp" diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index ee8f1fc..14b8804 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -95,6 +95,9 @@ let g:airline_powerline_fonts = 1 ''; }; + vscode = { + enable = true; + }; zsh = { enable = true; enableCompletion = true; From 0c9459d351e777e30204d67f1a0d8e31c3431087 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Tue, 12 Sep 2023 16:31:47 -0400 Subject: [PATCH 12/22] Use variables for my name --- flake.nix | 100 +++++++++++++++++--------------- modules/darwin/default.nix | 9 ++- modules/nixos/configuration.nix | 15 ++--- 3 files changed, 68 insertions(+), 56 deletions(-) diff --git a/flake.nix b/flake.nix index 4d354fe..fccc0eb 100644 --- a/flake.nix +++ b/flake.nix @@ -22,59 +22,67 @@ }; # end inputs outputs = { self, nixpkgs, nix-darwin, home-manager, nix-homebrew, ... }: { - nixosConfigurations.rainbow-planet = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./modules/nixos/configuration.nix - home-manager.nixosModules.home-manager - { - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - users."gene".imports = [ - ./modules/home-manager - ./modules/nixos/dconf.nix - ]; - }; - } - ]; + nixosConfigurations = let + user = "gene"; + in { + rainbow-planet = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./modules/nixos/configuration.nix + home-manager.nixosModules.home-manager + { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + users.${user}.imports = [ + ./modules/home-manager + ./modules/nixos/dconf.nix + ]; + }; + } + ]; + }; # end rainbow-planet }; # end nixosConfigurations # This is only set to work with x86 macOS right now... that will need to be updated - darwinConfigurations.Blue-Rock = nix-darwin.lib.darwinSystem { - system = "x86_64-darwin"; - pkgs = import nixpkgs { + darwinConfigurations = let + user = "gene.liverman"; + in { + Blue-Rock = nix-darwin.lib.darwinSystem { system = "x86_64-darwin"; - config.allowUnfree = true; - }; - modules = [ - nix-homebrew.darwinModules.nix-homebrew - { - nix-homebrew = { - # Install Homebrew under the default prefix - enable = true; + pkgs = import nixpkgs { + system = "x86_64-darwin"; + config.allowUnfree = true; + }; + modules = [ + nix-homebrew.darwinModules.nix-homebrew + { + nix-homebrew = { + # Install Homebrew under the default prefix + enable = true; - # User owning the Homebrew prefix - user = "gene.liverman"; + # User owning the Homebrew prefix + user = "${user}"; - # Automatically migrate existing Homebrew installations - autoMigrate = true; - }; - } + # Automatically migrate existing Homebrew installations + autoMigrate = true; + }; + } - ./modules/darwin + ./modules/darwin - home-manager.darwinModules.home-manager - { - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - users."gene.liverman".imports = [ - ./modules/home-manager - ]; - }; - } - ]; # end modules - }; # end of darwinConfigurations.Blue-Rock + home-manager.darwinModules.home-manager + { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + users.${user}.imports = [ + ./modules/home-manager + ]; + }; + } + ]; # end modules + }; # end Blue-Rock + }; # end darwinConfigurations }; } diff --git a/modules/darwin/default.nix b/modules/darwin/default.nix index 7e7f24b..fc6a1e5 100644 --- a/modules/darwin/default.nix +++ b/modules/darwin/default.nix @@ -1,4 +1,6 @@ -{ pkgs, ... }: { +{ pkgs, ... }: let + user = "gene.liverman"; +in { system.stateVersion = 4; environment = { @@ -110,6 +112,7 @@ "flakes" "nix-command" ]; + trusted-users = [ "@admin" "${user}" ]; }; extraOptions = '' # Generated by https://github.com/DeterminateSystems/nix-installer, version 0.11.0. @@ -121,8 +124,8 @@ services.nix-daemon.enable = true; - users.users."gene.liverman" = { - home = "/Users/gene.liverman"; + users.users.${user} = { + home = "/Users/${user}"; shell = pkgs.zsh; }; } diff --git a/modules/nixos/configuration.nix b/modules/nixos/configuration.nix index aca022c..b6a491e 100644 --- a/modules/nixos/configuration.nix +++ b/modules/nixos/configuration.nix @@ -2,9 +2,10 @@ # your system. Help is available in the configuration.nix(5) man page # and in the NixOS manual (accessible by running ‘nixos-help’). -{ config, pkgs, ... }: - -{ +{ config, pkgs, ... }:let + user = "gene"; + hostname = "rainbow-planet"; +in { imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix @@ -14,7 +15,7 @@ boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; - networking.hostName = "rainbow-planet"; # Define your hostname. + networking.hostName = "${hostname}"; # Define your hostname. # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. # Configure network proxy if necessary @@ -83,7 +84,7 @@ # services.xserver.libinput.enable = true; # Define a user account. Don't forget to set a password with ‘passwd’. - users.users.gene = { + users.users.${user} = { isNormalUser = true; description = "Gene Liverman"; extraGroups = [ "networkmanager" "wheel" "dialout" ]; @@ -139,7 +140,7 @@ enable = true; # Certain features, including CLI integration and system authentication support, # require enabling PolKit integration on some desktop environments (e.g. Plasma). - polkitPolicyOwners = [ "gene" ]; + polkitPolicyOwners = [ "${user}" ]; }; # List services that you want to enable: @@ -160,7 +161,7 @@ # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). system.stateVersion = "23.05"; # Did you read the comment? - nix.settings.allowed-users = [ "gene" ]; + nix.settings.allowed-users = [ "${user}" ]; nix.settings.experimental-features = [ "flakes" "nix-command" From ed81cb1d3421070be38a6cb917526db3b7e6ec8c Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Tue, 12 Sep 2023 21:15:53 -0400 Subject: [PATCH 13/22] Nomalize packages between systems --- modules/darwin/default.nix | 21 --------------------- modules/home-manager/default.nix | 25 +++++++++++++++++++++++++ modules/nixos/configuration.nix | 20 +------------------- 3 files changed, 26 insertions(+), 40 deletions(-) diff --git a/modules/darwin/default.nix b/modules/darwin/default.nix index fc6a1e5..84a7aae 100644 --- a/modules/darwin/default.nix +++ b/modules/darwin/default.nix @@ -13,27 +13,14 @@ in { systemPackages = with pkgs; [ coreutils chart-testing - colordiff - dog - dos2unix - du-dust - element-desktop - gotop - hub hugo kopia kubectx mas - mtr nmap nodejs nodePackages.npm openjdk - rename - tree - watch - wget - yq ]; }; @@ -58,12 +45,10 @@ in { "kubernetes-cli" ]; casks = [ - "1password" "amethyst" "audacity" "cakebrew" "elgato-stream-deck" - "firefox" "font-hack-nerd-font" "font-inconsolata-g-for-powerline" "font-source-code-pro-for-powerline" @@ -71,9 +56,7 @@ in { "iterm2" "keepingyouawake" "kopiaui" - "libreoffice" "logseq" - "meld" "nextcloud" "obs" "onlyoffice" @@ -82,16 +65,12 @@ in { "qmk-toolbox" "raycast" "signal" - "slack" - "tailscale" "thunderbird" "vagrant" "virtualbox" - "vivaldi" "vlc" "whatsapp" "zenmap" - "zoom" ]; masApps = { "1Password for Safari" = 1569813296; diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index 14b8804..9c21ca1 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -1,7 +1,31 @@ { pkgs, ... }: { home.stateVersion = "23.11"; home.packages = with pkgs; [ + _1password + _1password-gui + colordiff + dog + dos2unix + du-dust + element-desktop + gotop + htop + hub + jq + libreoffice + meld + mtr + nix-zsh-completions + rename + slack subversion + tailscale + tree + vivaldi + watch + wget + yq + zoom-us ]; home.sessionVariables = { CLICLOLOR = 1; @@ -10,6 +34,7 @@ programs = { bat.enable = true; eza.enable = true; + firefox.enable = true; gh.enable = true; git = { enable = true; diff --git a/modules/nixos/configuration.nix b/modules/nixos/configuration.nix index b6a491e..ec2cc64 100644 --- a/modules/nixos/configuration.nix +++ b/modules/nixos/configuration.nix @@ -89,9 +89,7 @@ in { description = "Gene Liverman"; extraGroups = [ "networkmanager" "wheel" "dialout" ]; packages = with pkgs; [ - firefox - slack - # thunderbird + tailscale-systray ]; }; @@ -103,29 +101,13 @@ in { # List packages installed in system profile. To search, run: # $ nix search wget environment.systemPackages = with pkgs; [ - _1password - _1password-gui - bat - colordiff dconf2nix - dog - dos2unix gnomeExtensions.appindicator gnomeExtensions.caffeine gnomeExtensions.dash-to-panel gnomeExtensions.user-themes - gotop - htop - hub - mtr neofetch - nix-zsh-completions tilix - tree - vivaldi - watch - wget - jq ]; # Some programs need SUID wrappers, can be configured further or are From 5abdc2521dddc5dcf0006405f50be2d02d94afc1 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Tue, 12 Sep 2023 21:26:18 -0400 Subject: [PATCH 14/22] Set theme in bat --- modules/home-manager/default.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index 9c21ca1..8d7ade1 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -32,7 +32,12 @@ PAGER = "less"; }; programs = { - bat.enable = true; + bat = { + enable = true; + config = { + theme = "Dracula"; + }; + }; eza.enable = true; firefox.enable = true; gh.enable = true; From 25aafe96d48f085a9cbd91d75bb2e2564ecfefdf Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Wed, 13 Sep 2023 08:44:47 -0400 Subject: [PATCH 15/22] Turns out some apps needed adjusting on macOS With the exception of 1Password, the changes here are for apps not available on darwin. 1Password was changed around because it must be installed directly in /Applications to run. I filed this bug report about the issue: https://github.com/NixOS/nixpkgs/issues/254944 --- modules/darwin/default.nix | 5 +++++ modules/home-manager/default.nix | 5 ----- modules/nixos/configuration.nix | 5 +++++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/darwin/default.nix b/modules/darwin/default.nix index 84a7aae..5a57faf 100644 --- a/modules/darwin/default.nix +++ b/modules/darwin/default.nix @@ -45,10 +45,13 @@ in { "kubernetes-cli" ]; casks = [ + "1password" + "1password-cli" "amethyst" "audacity" "cakebrew" "elgato-stream-deck" + "firefox" "font-hack-nerd-font" "font-inconsolata-g-for-powerline" "font-source-code-pro-for-powerline" @@ -56,6 +59,7 @@ in { "iterm2" "keepingyouawake" "kopiaui" + "libreoffice" "logseq" "nextcloud" "obs" @@ -67,6 +71,7 @@ in { "signal" "thunderbird" "vagrant" + "vivaldi" "virtualbox" "vlc" "whatsapp" diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index 8d7ade1..f65845f 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -1,8 +1,6 @@ { pkgs, ... }: { home.stateVersion = "23.11"; home.packages = with pkgs; [ - _1password - _1password-gui colordiff dog dos2unix @@ -12,7 +10,6 @@ htop hub jq - libreoffice meld mtr nix-zsh-completions @@ -21,7 +18,6 @@ subversion tailscale tree - vivaldi watch wget yq @@ -39,7 +35,6 @@ }; }; eza.enable = true; - firefox.enable = true; gh.enable = true; git = { enable = true; diff --git a/modules/nixos/configuration.nix b/modules/nixos/configuration.nix index ec2cc64..afcdbed 100644 --- a/modules/nixos/configuration.nix +++ b/modules/nixos/configuration.nix @@ -101,13 +101,18 @@ in { # List packages installed in system profile. To search, run: # $ nix search wget environment.systemPackages = with pkgs; [ + _1password + _1password-gui dconf2nix + firefox gnomeExtensions.appindicator gnomeExtensions.caffeine gnomeExtensions.dash-to-panel gnomeExtensions.user-themes + libreoffice neofetch tilix + vivaldi ]; # Some programs need SUID wrappers, can be configured further or are From a91b4a84ea6f9b57302356941e90ff5e7a2054e0 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Wed, 13 Sep 2023 12:58:11 -0400 Subject: [PATCH 16/22] Use brew version of Tailscale on macOS The Nix version doesn't include the gui bits. --- modules/darwin/default.nix | 1 + modules/home-manager/default.nix | 1 - modules/nixos/configuration.nix | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/darwin/default.nix b/modules/darwin/default.nix index 5a57faf..36a6819 100644 --- a/modules/darwin/default.nix +++ b/modules/darwin/default.nix @@ -69,6 +69,7 @@ in { "qmk-toolbox" "raycast" "signal" + "tailscale" "thunderbird" "vagrant" "vivaldi" diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index f65845f..8c7f2ef 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -16,7 +16,6 @@ rename slack subversion - tailscale tree watch wget diff --git a/modules/nixos/configuration.nix b/modules/nixos/configuration.nix index afcdbed..bbde47d 100644 --- a/modules/nixos/configuration.nix +++ b/modules/nixos/configuration.nix @@ -111,6 +111,7 @@ in { gnomeExtensions.user-themes libreoffice neofetch + tailscale tilix vivaldi ]; From badf0988a255fa5df84a3d2805859c956d7b6fa3 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Wed, 13 Sep 2023 14:13:08 -0400 Subject: [PATCH 17/22] Remove folder and (most) OS icons, clean up colors Now, the OS icon is only rendered when in a WSL environment as it isn't that useful or easy to read the rest of the time. The folder icon was removed from the path part of the prompt because it, too, was hard to read and served no helpful purpose. Colors were cleaned up so that names are used everywhere and unused bits were removed. --- modules/home-manager/files/beanbag.omp.json | 36 ++++++++------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/modules/home-manager/files/beanbag.omp.json b/modules/home-manager/files/beanbag.omp.json index b0297c6..4b5a2a7 100755 --- a/modules/home-manager/files/beanbag.omp.json +++ b/modules/home-manager/files/beanbag.omp.json @@ -17,14 +17,10 @@ "kubectl-bg": "transparent", "status-fg-okay": "#00ff00", "status-fg-error": "#D81E5B", + "tooltip-fg": "#E0DEF4", + "tooltip-az-bg": "#4B95E9", "secondary-fg": "#00ff00", - - - - "blue": "#4B95E9", - "orange": "#F07623", - "white": "#E0DEF4", - "yellow": "#F3AE35" + "orange-text": "#ff8800" }, "blocks": [ { @@ -46,24 +42,18 @@ "type": "session", "style": "plain", "foreground": "p:hostname", - "template": " {{ (split \".\" .HostName)._0 }}(" + "template": " {{ (split \".\" .HostName)._0 }}" }, { "type": "os", "style": "plain", - "template": "{{ if .WSL }}WSL {{ end }}{{.Icon}}" - }, - { - "type": "session", - "style": "plain", - "foreground": "p:hostname", - "template": "):" + "template": "{{ if .WSL }}(WSL {{.Icon}}){{ end }}" }, { "type": "path", "style": "plain", "foreground": "p:pwd", - "template": " \uea83 {{ path .Path .Location }}", + "template": " {{ path .Path .Location }}", "properties": { "folder_separator_icon": "/", "style": "full" @@ -75,7 +65,7 @@ "powerline_symbol": "\uE0B0", "foreground": "p:kubectl-fg", "background": "p:kubectl-bg", - "template": " <#ff8800>(\uFD31 {{.Context}}{{if .Namespace}} :: {{.Namespace}}{{end}}<#ff8800>)" + "template": " (\uFD31 {{.Context}}{{if .Namespace}} :: {{.Namespace}}{{end}})" }, { "type": "git", @@ -87,7 +77,7 @@ "{{ if gt .Ahead 0 }}p:git-fg-ahead{{ end }}", "{{ if gt .Behind 0 }}p:git-fg-behind{{ end }}" ], - "template": " <#ff8800>on {{ if .UpstreamURL }}{{ url .UpstreamIcon .UpstreamURL }} {{ end }}{{ url .HEAD .Kraken }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }}", + "template": " on {{ if .UpstreamURL }}{{ url .UpstreamIcon .UpstreamURL }} {{ end }}{{ url .HEAD .Kraken }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }}", "properties": { "branch_max_length": 25, "fetch_stash_count": true, @@ -102,7 +92,7 @@ "foreground_templates": [ "{{ if (.Working.Changed) }}p:svn-fg-changed{{ end }}" ], - "template": " <#ff8800>on svn \ue0a0{{.Branch}} r{{.BaseRev}}{{ if .Working.Changed }} \uf044 {{.Working.String}}{{ end }}", + "template": " on svn \ue0a0{{.Branch}} r{{.BaseRev}}{{ if .Working.Changed }} \uf044 {{.Working.String}}{{ end }}", "properties": { "fetch_status": true } @@ -142,8 +132,8 @@ "aws" ], "style": "diamond", - "foreground": "p:white", - "background": "p:orange", + "foreground": "p:tooltip-fg", + "background": "p:orange-text", "leading_diamond": "\ue0b0", "trailing_diamond": "\ue0b4", "template": " \ue7ad {{ .Profile }}{{ if .Region }}@{{ .Region }}{{ end }} ", @@ -157,8 +147,8 @@ "az" ], "style": "diamond", - "foreground": "p:white", - "background": "p:blue", + "foreground": "p:tooltip-fg", + "background": "p:tooltip-az-bg", "leading_diamond": "\ue0b0", "trailing_diamond": "\ue0b4", "template": " \uebd8 {{ .Name }} ", From 180b8494ba28e49715ce7cb16c98496216e6f681 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Wed, 13 Sep 2023 23:03:22 -0400 Subject: [PATCH 18/22] Pull oh-my-posh theme from its own repository With help from others, I can now pull the theme file from the repo it lives in instead of embedding it here! --- flake.lock | 17 ++ flake.nix | 9 +- modules/home-manager/default.nix | 4 +- modules/home-manager/files/beanbag.omp.json | 164 -------------------- 4 files changed, 27 insertions(+), 167 deletions(-) delete mode 100755 modules/home-manager/files/beanbag.omp.json diff --git a/flake.lock b/flake.lock index 95114bf..41383f5 100644 --- a/flake.lock +++ b/flake.lock @@ -35,6 +35,22 @@ "type": "github" } }, + "genebean-omp-themes": { + "flake": false, + "locked": { + "lastModified": 1694629194, + "narHash": "sha256-k1HqpsW5buBGe3rgugQvoKw5nPu/zBWiT8blb5eHc0w=", + "owner": "genebean", + "repo": "my-oh-my-posh-themes", + "rev": "eb6ba507c2f37accc926c65bac1b88293a71eb9c", + "type": "github" + }, + "original": { + "owner": "genebean", + "repo": "my-oh-my-posh-themes", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -160,6 +176,7 @@ }, "root": { "inputs": { + "genebean-omp-themes": "genebean-omp-themes", "home-manager": "home-manager", "nix-darwin": "nix-darwin", "nix-homebrew": "nix-homebrew", diff --git a/flake.nix b/flake.nix index fccc0eb..c35ec5e 100644 --- a/flake.nix +++ b/flake.nix @@ -20,8 +20,14 @@ # Manage Homebrew itself nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew"; + # My oh-my-posh theme + genebean-omp-themes = { + url = "github:genebean/my-oh-my-posh-themes"; + flake = false; + }; + }; # end inputs - outputs = { self, nixpkgs, nix-darwin, home-manager, nix-homebrew, ... }: { + outputs = { self, nixpkgs, nix-darwin, home-manager, nix-homebrew, genebean-omp-themes, ... }: { nixosConfigurations = let user = "gene"; in { @@ -79,6 +85,7 @@ users.${user}.imports = [ ./modules/home-manager ]; + extraSpecialArgs = { inherit genebean-omp-themes; }; }; } ]; # end modules diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index 8c7f2ef..7e0e7cf 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: { +{ pkgs, genebean-omp-themes, ... }: { home.stateVersion = "23.11"; home.packages = with pkgs; [ colordiff @@ -51,7 +51,7 @@ oh-my-posh = { enable = true; enableZshIntegration = true; - settings = builtins.fromJSON (builtins.unsafeDiscardStringContext (builtins.readFile ./files/beanbag.omp.json)); + settings = builtins.fromJSON (builtins.unsafeDiscardStringContext (builtins.readFile (genebean-omp-themes + "/beanbag.omp.json"))); }; vim = { enable = true; diff --git a/modules/home-manager/files/beanbag.omp.json b/modules/home-manager/files/beanbag.omp.json deleted file mode 100755 index 4b5a2a7..0000000 --- a/modules/home-manager/files/beanbag.omp.json +++ /dev/null @@ -1,164 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", - "version": 2, - "final_space": true, - "palette": { - "line-connector": "#00ff00", - "hostname": "#62c0ff", - "pwd": "#ffff00", - "git-fg-clean": "#62c0ff", - "git-fg-changed": "#6287ff", - "git-fg-ahead-and-behind": "#7f62ff", - "git-fg-ahead": "#9962ff", - "git-fg-behind": "#c062ff", - "svn-fg-clean": "#62c0ff", - "svn-fg-changed": "#6287ff", - "kubectl-fg": "#62c0ff", - "kubectl-bg": "transparent", - "status-fg-okay": "#00ff00", - "status-fg-error": "#D81E5B", - "tooltip-fg": "#E0DEF4", - "tooltip-az-bg": "#4B95E9", - "secondary-fg": "#00ff00", - "orange-text": "#ff8800" - }, - "blocks": [ - { - "type": "prompt", - "alignment": "left", - "segments": [ - { - "type": "text", - "style": "plain", - "foreground": "p:line-connector", - "template": "\u2554" - }, - { - "type": "text", - "style": "plain", - "template": " \u2615 " - }, - { - "type": "session", - "style": "plain", - "foreground": "p:hostname", - "template": " {{ (split \".\" .HostName)._0 }}" - }, - { - "type": "os", - "style": "plain", - "template": "{{ if .WSL }}(WSL {{.Icon}}){{ end }}" - }, - { - "type": "path", - "style": "plain", - "foreground": "p:pwd", - "template": " {{ path .Path .Location }}", - "properties": { - "folder_separator_icon": "/", - "style": "full" - } - }, - { - "type": "kubectl", - "style": "powerline", - "powerline_symbol": "\uE0B0", - "foreground": "p:kubectl-fg", - "background": "p:kubectl-bg", - "template": " (\uFD31 {{.Context}}{{if .Namespace}} :: {{.Namespace}}{{end}})" - }, - { - "type": "git", - "style": "plain", - "foreground": "p:git-fg-clean", - "foreground_templates": [ - "{{ if or (.Working.Changed) (.Staging.Changed) }}p:git-fg-changed{{ end }}", - "{{ if and (gt .Ahead 0) (gt .Behind 0) }}p:git-fg-ahead-and-behind{{ end }}", - "{{ if gt .Ahead 0 }}p:git-fg-ahead{{ end }}", - "{{ if gt .Behind 0 }}p:git-fg-behind{{ end }}" - ], - "template": " on {{ if .UpstreamURL }}{{ url .UpstreamIcon .UpstreamURL }} {{ end }}{{ url .HEAD .Kraken }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }}", - "properties": { - "branch_max_length": 25, - "fetch_stash_count": true, - "fetch_status": true, - "fetch_upstream_icon": true - } - }, - { - "type": "svn", - "style": "plain", - "foreground": "p:svn-fg-clean", - "foreground_templates": [ - "{{ if (.Working.Changed) }}p:svn-fg-changed{{ end }}" - ], - "template": " on svn \ue0a0{{.Branch}} r{{.BaseRev}}{{ if .Working.Changed }} \uf044 {{.Working.String}}{{ end }}", - "properties": { - "fetch_status": true - } - }, - { - "type": "status", - "style": "diamond", - "foreground": "p:status-fg-okay", - "foreground_templates": [ - "{{ if gt .Code 0 }}p:status-fg-error{{ end }}" - ], - "template": " (exit code {{ .Code }})", - "properties": { - "always_enabled": false - } - } - ] - }, - { - "type": "prompt", - "alignment": "left", - "newline": true, - "segments": [ - { - "foreground": "p:line-connector", - "style": "plain", - "template": "\u255A\u1405", - "type": "text" - } - ] - } - ], - "tooltips": [ - { - "type": "aws", - "tips": [ - "aws" - ], - "style": "diamond", - "foreground": "p:tooltip-fg", - "background": "p:orange-text", - "leading_diamond": "\ue0b0", - "trailing_diamond": "\ue0b4", - "template": " \ue7ad {{ .Profile }}{{ if .Region }}@{{ .Region }}{{ end }} ", - "properties": { - "display_default": true - } - }, - { - "type": "az", - "tips": [ - "az" - ], - "style": "diamond", - "foreground": "p:tooltip-fg", - "background": "p:tooltip-az-bg", - "leading_diamond": "\ue0b0", - "trailing_diamond": "\ue0b4", - "template": " \uebd8 {{ .Name }} ", - "properties": { - "display_default": true - } - } - ], - "secondary_prompt": { - "foreground": "p:secondary-fg", - "template": " " - } -} From f38ff62b7b0198a697529df2bdc55730d7dd4b41 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Wed, 13 Sep 2023 23:23:16 -0400 Subject: [PATCH 19/22] Pass new input to NixOS home-manager too --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index c35ec5e..b2210fc 100644 --- a/flake.nix +++ b/flake.nix @@ -44,6 +44,7 @@ ./modules/home-manager ./modules/nixos/dconf.nix ]; + extraSpecialArgs = { inherit genebean-omp-themes; }; }; } ]; From 240d729487161acd96c41baca6d282c34bedde72 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Wed, 13 Sep 2023 23:37:29 -0400 Subject: [PATCH 20/22] Clean up NixOS config --- modules/nixos/configuration.nix | 117 +++++++++++--------------------- 1 file changed, 38 insertions(+), 79 deletions(-) diff --git a/modules/nixos/configuration.nix b/modules/nixos/configuration.nix index bbde47d..8755bdb 100644 --- a/modules/nixos/configuration.nix +++ b/modules/nixos/configuration.nix @@ -1,8 +1,4 @@ -# 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, ... }:let +{ config, pkgs, ... }: let user = "gene"; hostname = "rainbow-planet"; in { @@ -11,40 +7,42 @@ in { ./hardware-configuration.nix ]; + system.stateVersion = "23.05"; + # Bootloader. boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; - networking.hostName = "${hostname}"; # Define your hostname. - # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + networking = { + hostName = "${hostname}"; + networkmanager.enable = true; + }; - # Configure network proxy if necessary - # networking.proxy.default = "http://user:password@proxy:port/"; - # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; - - # Enable networking - networking.networkmanager.enable = true; - - # Set your time zone. time.timeZone = "America/New_York"; # Select internationalisation properties. - i18n.defaultLocale = "en_US.UTF-8"; - - i18n.extraLocaleSettings = { - LC_ADDRESS = "en_US.UTF-8"; - LC_IDENTIFICATION = "en_US.UTF-8"; - LC_MEASUREMENT = "en_US.UTF-8"; - LC_MONETARY = "en_US.UTF-8"; - LC_NAME = "en_US.UTF-8"; - LC_NUMERIC = "en_US.UTF-8"; - LC_PAPER = "en_US.UTF-8"; - LC_TELEPHONE = "en_US.UTF-8"; - LC_TIME = "en_US.UTF-8"; + i18n = { + defaultLocale = "en_US.UTF-8"; + extraLocaleSettings = { + LC_ADDRESS = "en_US.UTF-8"; + LC_IDENTIFICATION = "en_US.UTF-8"; + LC_MEASUREMENT = "en_US.UTF-8"; + LC_MONETARY = "en_US.UTF-8"; + LC_NAME = "en_US.UTF-8"; + LC_NUMERIC = "en_US.UTF-8"; + LC_PAPER = "en_US.UTF-8"; + LC_TELEPHONE = "en_US.UTF-8"; + LC_TIME = "en_US.UTF-8"; + }; }; - # Enable the X11 windowing system. - services.xserver.enable = true; + services.xserver = { + enable = true; # Enable the X11 windowing system. + + # Configure keymap in X11 + layout = "us"; + xkbVariant = ""; + }; # Enable the GNOME Desktop Environment. services.xserver.displayManager.gdm.enable = true; @@ -54,12 +52,6 @@ in { gnome.gnome-settings-daemon ]; - # Configure keymap in X11 - services.xserver = { - layout = "us"; - xkbVariant = ""; - }; - # Enable CUPS to print documents. services.printing.enable = true; @@ -72,12 +64,6 @@ in { alsa.enable = true; alsa.support32Bit = true; pulse.enable = true; - # If you want to use JACK applications, uncomment this - #jack.enable = true; - - # use the example session manager (no others are packaged yet so this is enabled by default, - # no need to redefine it in your config for now) - #media-session.enable = true; }; # Enable touchpad support (enabled default in most desktopManager). @@ -93,6 +79,10 @@ in { ]; }; + environment.shells = with pkgs; [ bash zsh ]; + users.defaultUserShell = pkgs.zsh; + programs.zsh.enable = true; + security.sudo.wheelNeedsPassword = false; # Allow unfree packages @@ -101,8 +91,6 @@ in { # List packages installed in system profile. To search, run: # $ nix search wget environment.systemPackages = with pkgs; [ - _1password - _1password-gui dconf2nix firefox gnomeExtensions.appindicator @@ -116,13 +104,6 @@ in { vivaldi ]; - # 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; - # }; programs._1password.enable = true; programs._1password-gui = { enable = true; @@ -130,40 +111,18 @@ in { # require enabling PolKit integration on some desktop environments (e.g. Plasma). polkitPolicyOwners = [ "${user}" ]; }; - # List services that you want to enable: - # Enable the OpenSSH daemon. - # services.openssh.enable = true; + nix.settings = { + allowed-users = [ "${user}" ]; + experimental-features = [ + "flakes" + "nix-command" + ]; + }; - # Open ports in the firewall. - # networking.firewall.allowedTCPPorts = [ ... ]; - # networking.firewall.allowedUDPPorts = [ ... ]; - # Or disable the firewall altogether. - # networking.firewall.enable = false; - - # This value determines the NixOS release from which the default - # settings for stateful data, like file locations and database versions - # on your system were taken. It‘s perfectly fine and recommended to leave - # this value at the release version of the first install of this system. - # Before changing this value read the documentation for this option - # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). - system.stateVersion = "23.05"; # Did you read the comment? - - nix.settings.allowed-users = [ "${user}" ]; - nix.settings.experimental-features = [ - "flakes" - "nix-command" - ]; - - programs.zsh.enable = true; fonts.fontDir.enable = false; fonts.packages = [ (pkgs.nerdfonts.override { fonts = [ "Hack" "SourceCodePro" ]; }) ]; - - environment.shells = with pkgs; [ bash zsh ]; - users.defaultUserShell = pkgs.zsh; - - } From 49e67c64fbfa2b76d2557e689c051772e4bd8eed Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Wed, 13 Sep 2023 23:40:35 -0400 Subject: [PATCH 21/22] Standardize naming --- flake.nix | 2 +- modules/nixos/{configuration.nix => default.nix} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename modules/nixos/{configuration.nix => default.nix} (100%) diff --git a/flake.nix b/flake.nix index b2210fc..b85d13f 100644 --- a/flake.nix +++ b/flake.nix @@ -34,7 +34,7 @@ rainbow-planet = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ - ./modules/nixos/configuration.nix + ./modules/nixos home-manager.nixosModules.home-manager { home-manager = { diff --git a/modules/nixos/configuration.nix b/modules/nixos/default.nix similarity index 100% rename from modules/nixos/configuration.nix rename to modules/nixos/default.nix From cc0efcfdde6880437ff08bb33db90534115fe7fc Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Thu, 14 Sep 2023 00:01:31 -0400 Subject: [PATCH 22/22] Update repo structure as part of nixification --- README.md | 176 +++--------------- {ansible => legacy/.bundle/ansible}/README.md | 0 .../.bundle/ansible}/ansible_hosts.yaml | 0 .../.bundle/ansible}/bigboy.yaml | 0 .../.bundle/ansible}/blue-rock.yaml | 0 .../.bundle/ansible}/carbonbean.yaml | 0 .../.bundle/ansible}/server-zsh.yaml | 0 {.bundle => legacy/.bundle}/config | 0 {.github => legacy/.github}/dependabot.yml | 0 .../.github}/workflows/ansible-lint.yml | 0 .../.github}/workflows/ruby.yml | 0 .puppet-lint.rc => legacy/.puppet-lint.rc | 0 .rspec => legacy/.rspec | 0 .rubocop.yml => legacy/.rubocop.yml | 0 .../DevelopmentPlan.md | 0 Gemfile => legacy/Gemfile | 0 Gemfile.lock => legacy/Gemfile.lock | 0 legacy/README.md | 159 ++++++++++++++++ Rakefile => legacy/Rakefile | 0 {bin => legacy/bin}/bootstrap.sh | 0 {bin => legacy/bin}/bootstrap/bootstrap_el.sh | 0 .../bin}/bootstrap/bootstrap_mac.sh | 0 .../bin}/bootstrap/bootstrap_mint.sh | 0 {bin => legacy/bin}/casks.sh | 0 {bin => legacy/bin}/dots.rb | 0 {bin => legacy/bin}/dotutils.rb | 0 {bin => legacy/bin}/rake_tasks.rb | 0 {bin => legacy/bin}/sclbundle | 0 {bin => legacy/bin}/sclruby | 0 {bin => legacy/bin}/shell-setup.sh | 0 {copy => legacy/copy}/mac/gitconfig | 0 {copy => legacy/copy}/puppetforge.yml | 0 .../puppet}/production/Puppetfile | 0 .../puppet}/production/environment.conf | 0 .../puppet}/production/hiera.yaml | 0 .../puppet}/production/hieradata/common.yaml | 0 .../hieradata/nodes/YellowBadger.yaml | 0 .../production/hieradata/nodes/bowl.yaml | 0 .../production/hieradata/nodes/gene.yaml | 0 .../hieradata/nodes/mintstring.yaml | 0 .../puppet}/production/manifests/site.pp | 0 .../production/scripts/config_version.rb | 0 .../production/scripts/config_version.sh | 0 .../site/custom_libs/lib/facter/os_release.rb | 0 .../lib/puppet/functions/find_group.rb | 0 .../lib/puppet/functions/find_owner.rb | 0 .../lib/puppet/functions/homedir_to_user.rb | 0 .../production/site/profile/manifests/base.pp | 0 .../site/profile/manifests/linux.pp | 0 .../site/profile/manifests/linux/debian.pp | 0 .../site/profile/manifests/linux/el.pp | 0 .../manifests/linux/el/docker_repos.pp | 0 .../production/site/profile/manifests/mac.pp | 0 .../production/site/role/manifests/server.pp | 0 .../site/role/manifests/workstation.pp | 0 r10k.yaml => legacy/r10k.yaml | 0 56 files changed, 181 insertions(+), 154 deletions(-) rename {ansible => legacy/.bundle/ansible}/README.md (100%) rename {ansible => legacy/.bundle/ansible}/ansible_hosts.yaml (100%) rename {ansible => legacy/.bundle/ansible}/bigboy.yaml (100%) rename {ansible => legacy/.bundle/ansible}/blue-rock.yaml (100%) rename {ansible => legacy/.bundle/ansible}/carbonbean.yaml (100%) rename {ansible => legacy/.bundle/ansible}/server-zsh.yaml (100%) rename {.bundle => legacy/.bundle}/config (100%) rename {.github => legacy/.github}/dependabot.yml (100%) rename {.github => legacy/.github}/workflows/ansible-lint.yml (100%) rename {.github => legacy/.github}/workflows/ruby.yml (100%) rename .puppet-lint.rc => legacy/.puppet-lint.rc (100%) rename .rspec => legacy/.rspec (100%) rename .rubocop.yml => legacy/.rubocop.yml (100%) rename DevelopmentPlan.md => legacy/DevelopmentPlan.md (100%) rename Gemfile => legacy/Gemfile (100%) rename Gemfile.lock => legacy/Gemfile.lock (100%) create mode 100644 legacy/README.md rename Rakefile => legacy/Rakefile (100%) rename {bin => legacy/bin}/bootstrap.sh (100%) rename {bin => legacy/bin}/bootstrap/bootstrap_el.sh (100%) rename {bin => legacy/bin}/bootstrap/bootstrap_mac.sh (100%) rename {bin => legacy/bin}/bootstrap/bootstrap_mint.sh (100%) rename {bin => legacy/bin}/casks.sh (100%) rename {bin => legacy/bin}/dots.rb (100%) rename {bin => legacy/bin}/dotutils.rb (100%) rename {bin => legacy/bin}/rake_tasks.rb (100%) rename {bin => legacy/bin}/sclbundle (100%) rename {bin => legacy/bin}/sclruby (100%) rename {bin => legacy/bin}/shell-setup.sh (100%) rename {copy => legacy/copy}/mac/gitconfig (100%) rename {copy => legacy/copy}/puppetforge.yml (100%) rename {puppet => legacy/puppet}/production/Puppetfile (100%) rename {puppet => legacy/puppet}/production/environment.conf (100%) rename {puppet => legacy/puppet}/production/hiera.yaml (100%) rename {puppet => legacy/puppet}/production/hieradata/common.yaml (100%) rename {puppet => legacy/puppet}/production/hieradata/nodes/YellowBadger.yaml (100%) rename {puppet => legacy/puppet}/production/hieradata/nodes/bowl.yaml (100%) rename {puppet => legacy/puppet}/production/hieradata/nodes/gene.yaml (100%) rename {puppet => legacy/puppet}/production/hieradata/nodes/mintstring.yaml (100%) rename {puppet => legacy/puppet}/production/manifests/site.pp (100%) rename {puppet => legacy/puppet}/production/scripts/config_version.rb (100%) rename {puppet => legacy/puppet}/production/scripts/config_version.sh (100%) rename {puppet => legacy/puppet}/production/site/custom_libs/lib/facter/os_release.rb (100%) rename {puppet => legacy/puppet}/production/site/custom_libs/lib/puppet/functions/find_group.rb (100%) rename {puppet => legacy/puppet}/production/site/custom_libs/lib/puppet/functions/find_owner.rb (100%) rename {puppet => legacy/puppet}/production/site/custom_libs/lib/puppet/functions/homedir_to_user.rb (100%) rename {puppet => legacy/puppet}/production/site/profile/manifests/base.pp (100%) rename {puppet => legacy/puppet}/production/site/profile/manifests/linux.pp (100%) rename {puppet => legacy/puppet}/production/site/profile/manifests/linux/debian.pp (100%) rename {puppet => legacy/puppet}/production/site/profile/manifests/linux/el.pp (100%) rename {puppet => legacy/puppet}/production/site/profile/manifests/linux/el/docker_repos.pp (100%) rename {puppet => legacy/puppet}/production/site/profile/manifests/mac.pp (100%) rename {puppet => legacy/puppet}/production/site/role/manifests/server.pp (100%) rename {puppet => legacy/puppet}/production/site/role/manifests/workstation.pp (100%) rename r10k.yaml => legacy/r10k.yaml (100%) diff --git a/README.md b/README.md index a5c11af..baeaed4 100644 --- a/README.md +++ b/README.md @@ -1,159 +1,27 @@ -# dots +# Dots -[![Ansible Lint](https://github.com/genebean/dots/actions/workflows/ansible-lint.yml/badge.svg)](https://github.com/genebean/dots/actions/workflows/ansible-lint.yml) -[![Ruby](https://github.com/genebean/dots/actions/workflows/ruby.yml/badge.svg)](https://github.com/genebean/dots/actions/workflows/ruby.yml) +This repo historically contained my dot files and is now transitioning to being a Nix flake that manages my dot files and the things that consume them. Things are changing a lot right now, but historically symlinked files are still in `link/`. Most all the other old stuff is now tucked away under `legacy/` to get it out of the way until I decide what is and isn't needed. -> **NOTICE:** this repo is undergoing a transformation. Historically it has been centered around using Puppet and r10k as ruby gems. I love Puppet for managing servers, but running it unprivledged as a gem has proven more than a little challenging in this specific use case. As a result, I am transitioning to using Ansible for the adhoc work that is needed here. Also, the `dots` tool and associated rake tasks will almost certainly be moved to Python 3 as it is universally available without some of the hastles of a bundler based setup. - -This repo contains my dot files and a tool to deploy them, and the programs that use them, to various OS's. Some additional tools that I consider part of my baseline setup are also installed and, if possible, configured by dots. - -Dots is written in ruby and utilizes bundler to keep all its dependancies -as self-contained as possible. Installation of programs and management of git -repositories is handled by way of the -[Puppet gem](https://rubygems.org/gems/puppet). - -Everything about dots macOS assumes you are running it as a normal user, -not as root. Strange and unexpected things could well happen if you run any part -of it as root or via sudo while on macOS. That said, sudo is required on Debian -due to there not being an equivalent to homebrew as you need sudo to use apt. - - -## Currently Supported OS's - -* macOS -* Linux Mint 18.2 - - -## Initial Setup +The new Nix bits are driven by `flake.nix` which pulls in things under `modules/`. Initial support is for both x86 macOS and NixOS. New stuff is structured like so, at least for now: ```bash -git clone git@github.com:genebean/dots.git ~/.dotfiles -cd ~/.dotfiles -bin/bootstrap.sh -This script takes care of getting dots ready to use -Enter the number of the task you want to perform: -1) Mac setup -2) EL setup -3) Mint setup -4) Quit -Task: +$ tree . -I legacy* -I link* +. +├── flake.lock +├── flake.nix +├── LICENSE +├── modules +│ ├── darwin +│ │ └── default.nix +│ ├── home-manager +│ │ └── default.nix +│ ├── linux +│ └── nixos +│ ├── dconf.nix +│ ├── default.nix +│ └── hardware-configuration.nix +├── README.md +└── Vagrantfile + +6 directories, 10 files ``` - -After you run the setup for your OS you will want to make sure that -[puppet/production/hieradata/nodes/](puppet/production/hieradata/nodes/) -contains a file matching the hostname of your machine. That file needs to -contain at least the following: - -```yaml ---- -homedir: '/Users/johndoe' -``` - -Naturally, you will want to adjust the entry to match the real path to your -home directory. On a Mac this is generally in `/Users/` or `/home/` on Linux. - - -## Running dots - -The primary way to interact with dots is via `bundle exec rake dots`. -This will run an interactive cli program like so: - -``` -$ bundle exec rake dots -/usr/local/Cellar/ruby/2.4.1_1/bin/ruby bin/dots.rb -It seems you are on macOS 10.12.5 -What would you like to do? (Use arrow keys, press Enter to select) -‣ copy - link - install -``` - -If not on macOS then you will need to use sudo for the install step: - -``` -$ sudo bundle exec rake dots -``` - -Additional tasks are available in the -dots namespace. You can see all the available tasks via -`bundle exec rake -T`. - - -## Notes - -#### Running Puppet - -```bash -# Any of these will work: -bundle exec rake dots:run_puppet -bundle exec rake dots:run_puppet_noop -bundle exec puppet apply --environmentpath ~/.dotfiles/puppet ~/.dotfiles/puppet/production/manifests/site.pp -``` - -As mentioned above, when not on macOS you will need to prefix bundle with sudo. - - -#### Installed Homebrew packages - -To see what has been installed (not the deps) run `brew leaves` - - -## Project structure - -* `bin/`: this is where the "application" bits live -* `bin/bootstrap`: platform specific helpers called by `bin/bootstrap.sh` -* `copy/`: files directly in this directory are copied to all hosts -* `copy/mac/`: files in here get copied to Macs -* `copy/nix/`: files in here get copied to all Posix systems -* `link/`: files directly in this directory are symlinked on all hosts. - * all symlinks are prefixed with a dot. Ex: `link/gemrc` becomes `~/.gemrc` -* `link/linux/`: files in here get symlinked on all Linux distros -* `link/mac/`: files in here get symlinked on all Macs -* `link/nix/`: files in here get symlinked on all Posix systems -* `link/ssh/`: these files get symlinked under `~/.ssh/` on all Posix systems -* `puppet/`: this is basically a control repo modified to suit this setup -* `puppet/production/`: items from an environment's branch in a control repo - * this setup assumes Puppet 4 and Hiera 5. Hiera's config is parsed as part of - the environment rather than from a global config file. -* `spec/`: unit tests go here - - -## Adding Packages - -To add additional pacakages to be installed and managed by dots you will need to -edit the associated Puppet manifest. Currently, this consists of the following: - -```bash -puppet/production/site/profile/manifests/ -├── base.pp -├── linux -│   └── debian.pp -├── linux.pp -└── mac.pp -``` - -On macOS you can easily install packages and casks from homebrew or Python -modules from pip. On Linux Mint you can easily use any package provider -that supports Debian or Ubuntu since all installs are done via sudo. On both -platforms you can also use custom exec's to to work around limitations. For -example, an exec is used on Mint to set the shell to zsh and on both platforms -to install or update the powerline fonts. - - -## Puppet Customizations - -This repo also contains some custom facts and functions under -`puppet/production/site/custom_libs`: - -### Facts - -* `os_release`: this creates a structured fact out of the contents of - /etc/os-release on Linux systems. This info is needed on Mint to determine - what version of Ubuntu it is based on. - -### Functions - -* `find_group`: returns the owning group's GID as a string for the file or - folder at a given path -* `find_owner`: returns the owning user's UID as a string for the file or - folder at a given path diff --git a/ansible/README.md b/legacy/.bundle/ansible/README.md similarity index 100% rename from ansible/README.md rename to legacy/.bundle/ansible/README.md diff --git a/ansible/ansible_hosts.yaml b/legacy/.bundle/ansible/ansible_hosts.yaml similarity index 100% rename from ansible/ansible_hosts.yaml rename to legacy/.bundle/ansible/ansible_hosts.yaml diff --git a/ansible/bigboy.yaml b/legacy/.bundle/ansible/bigboy.yaml similarity index 100% rename from ansible/bigboy.yaml rename to legacy/.bundle/ansible/bigboy.yaml diff --git a/ansible/blue-rock.yaml b/legacy/.bundle/ansible/blue-rock.yaml similarity index 100% rename from ansible/blue-rock.yaml rename to legacy/.bundle/ansible/blue-rock.yaml diff --git a/ansible/carbonbean.yaml b/legacy/.bundle/ansible/carbonbean.yaml similarity index 100% rename from ansible/carbonbean.yaml rename to legacy/.bundle/ansible/carbonbean.yaml diff --git a/ansible/server-zsh.yaml b/legacy/.bundle/ansible/server-zsh.yaml similarity index 100% rename from ansible/server-zsh.yaml rename to legacy/.bundle/ansible/server-zsh.yaml diff --git a/.bundle/config b/legacy/.bundle/config similarity index 100% rename from .bundle/config rename to legacy/.bundle/config diff --git a/.github/dependabot.yml b/legacy/.github/dependabot.yml similarity index 100% rename from .github/dependabot.yml rename to legacy/.github/dependabot.yml diff --git a/.github/workflows/ansible-lint.yml b/legacy/.github/workflows/ansible-lint.yml similarity index 100% rename from .github/workflows/ansible-lint.yml rename to legacy/.github/workflows/ansible-lint.yml diff --git a/.github/workflows/ruby.yml b/legacy/.github/workflows/ruby.yml similarity index 100% rename from .github/workflows/ruby.yml rename to legacy/.github/workflows/ruby.yml diff --git a/.puppet-lint.rc b/legacy/.puppet-lint.rc similarity index 100% rename from .puppet-lint.rc rename to legacy/.puppet-lint.rc diff --git a/.rspec b/legacy/.rspec similarity index 100% rename from .rspec rename to legacy/.rspec diff --git a/.rubocop.yml b/legacy/.rubocop.yml similarity index 100% rename from .rubocop.yml rename to legacy/.rubocop.yml diff --git a/DevelopmentPlan.md b/legacy/DevelopmentPlan.md similarity index 100% rename from DevelopmentPlan.md rename to legacy/DevelopmentPlan.md diff --git a/Gemfile b/legacy/Gemfile similarity index 100% rename from Gemfile rename to legacy/Gemfile diff --git a/Gemfile.lock b/legacy/Gemfile.lock similarity index 100% rename from Gemfile.lock rename to legacy/Gemfile.lock diff --git a/legacy/README.md b/legacy/README.md new file mode 100644 index 0000000..a5c11af --- /dev/null +++ b/legacy/README.md @@ -0,0 +1,159 @@ +# dots + +[![Ansible Lint](https://github.com/genebean/dots/actions/workflows/ansible-lint.yml/badge.svg)](https://github.com/genebean/dots/actions/workflows/ansible-lint.yml) +[![Ruby](https://github.com/genebean/dots/actions/workflows/ruby.yml/badge.svg)](https://github.com/genebean/dots/actions/workflows/ruby.yml) + +> **NOTICE:** this repo is undergoing a transformation. Historically it has been centered around using Puppet and r10k as ruby gems. I love Puppet for managing servers, but running it unprivledged as a gem has proven more than a little challenging in this specific use case. As a result, I am transitioning to using Ansible for the adhoc work that is needed here. Also, the `dots` tool and associated rake tasks will almost certainly be moved to Python 3 as it is universally available without some of the hastles of a bundler based setup. + +This repo contains my dot files and a tool to deploy them, and the programs that use them, to various OS's. Some additional tools that I consider part of my baseline setup are also installed and, if possible, configured by dots. + +Dots is written in ruby and utilizes bundler to keep all its dependancies +as self-contained as possible. Installation of programs and management of git +repositories is handled by way of the +[Puppet gem](https://rubygems.org/gems/puppet). + +Everything about dots macOS assumes you are running it as a normal user, +not as root. Strange and unexpected things could well happen if you run any part +of it as root or via sudo while on macOS. That said, sudo is required on Debian +due to there not being an equivalent to homebrew as you need sudo to use apt. + + +## Currently Supported OS's + +* macOS +* Linux Mint 18.2 + + +## Initial Setup + +```bash +git clone git@github.com:genebean/dots.git ~/.dotfiles +cd ~/.dotfiles +bin/bootstrap.sh +This script takes care of getting dots ready to use +Enter the number of the task you want to perform: +1) Mac setup +2) EL setup +3) Mint setup +4) Quit +Task: +``` + +After you run the setup for your OS you will want to make sure that +[puppet/production/hieradata/nodes/](puppet/production/hieradata/nodes/) +contains a file matching the hostname of your machine. That file needs to +contain at least the following: + +```yaml +--- +homedir: '/Users/johndoe' +``` + +Naturally, you will want to adjust the entry to match the real path to your +home directory. On a Mac this is generally in `/Users/` or `/home/` on Linux. + + +## Running dots + +The primary way to interact with dots is via `bundle exec rake dots`. +This will run an interactive cli program like so: + +``` +$ bundle exec rake dots +/usr/local/Cellar/ruby/2.4.1_1/bin/ruby bin/dots.rb +It seems you are on macOS 10.12.5 +What would you like to do? (Use arrow keys, press Enter to select) +‣ copy + link + install +``` + +If not on macOS then you will need to use sudo for the install step: + +``` +$ sudo bundle exec rake dots +``` + +Additional tasks are available in the +dots namespace. You can see all the available tasks via +`bundle exec rake -T`. + + +## Notes + +#### Running Puppet + +```bash +# Any of these will work: +bundle exec rake dots:run_puppet +bundle exec rake dots:run_puppet_noop +bundle exec puppet apply --environmentpath ~/.dotfiles/puppet ~/.dotfiles/puppet/production/manifests/site.pp +``` + +As mentioned above, when not on macOS you will need to prefix bundle with sudo. + + +#### Installed Homebrew packages + +To see what has been installed (not the deps) run `brew leaves` + + +## Project structure + +* `bin/`: this is where the "application" bits live +* `bin/bootstrap`: platform specific helpers called by `bin/bootstrap.sh` +* `copy/`: files directly in this directory are copied to all hosts +* `copy/mac/`: files in here get copied to Macs +* `copy/nix/`: files in here get copied to all Posix systems +* `link/`: files directly in this directory are symlinked on all hosts. + * all symlinks are prefixed with a dot. Ex: `link/gemrc` becomes `~/.gemrc` +* `link/linux/`: files in here get symlinked on all Linux distros +* `link/mac/`: files in here get symlinked on all Macs +* `link/nix/`: files in here get symlinked on all Posix systems +* `link/ssh/`: these files get symlinked under `~/.ssh/` on all Posix systems +* `puppet/`: this is basically a control repo modified to suit this setup +* `puppet/production/`: items from an environment's branch in a control repo + * this setup assumes Puppet 4 and Hiera 5. Hiera's config is parsed as part of + the environment rather than from a global config file. +* `spec/`: unit tests go here + + +## Adding Packages + +To add additional pacakages to be installed and managed by dots you will need to +edit the associated Puppet manifest. Currently, this consists of the following: + +```bash +puppet/production/site/profile/manifests/ +├── base.pp +├── linux +│   └── debian.pp +├── linux.pp +└── mac.pp +``` + +On macOS you can easily install packages and casks from homebrew or Python +modules from pip. On Linux Mint you can easily use any package provider +that supports Debian or Ubuntu since all installs are done via sudo. On both +platforms you can also use custom exec's to to work around limitations. For +example, an exec is used on Mint to set the shell to zsh and on both platforms +to install or update the powerline fonts. + + +## Puppet Customizations + +This repo also contains some custom facts and functions under +`puppet/production/site/custom_libs`: + +### Facts + +* `os_release`: this creates a structured fact out of the contents of + /etc/os-release on Linux systems. This info is needed on Mint to determine + what version of Ubuntu it is based on. + +### Functions + +* `find_group`: returns the owning group's GID as a string for the file or + folder at a given path +* `find_owner`: returns the owning user's UID as a string for the file or + folder at a given path diff --git a/Rakefile b/legacy/Rakefile similarity index 100% rename from Rakefile rename to legacy/Rakefile diff --git a/bin/bootstrap.sh b/legacy/bin/bootstrap.sh similarity index 100% rename from bin/bootstrap.sh rename to legacy/bin/bootstrap.sh diff --git a/bin/bootstrap/bootstrap_el.sh b/legacy/bin/bootstrap/bootstrap_el.sh similarity index 100% rename from bin/bootstrap/bootstrap_el.sh rename to legacy/bin/bootstrap/bootstrap_el.sh diff --git a/bin/bootstrap/bootstrap_mac.sh b/legacy/bin/bootstrap/bootstrap_mac.sh similarity index 100% rename from bin/bootstrap/bootstrap_mac.sh rename to legacy/bin/bootstrap/bootstrap_mac.sh diff --git a/bin/bootstrap/bootstrap_mint.sh b/legacy/bin/bootstrap/bootstrap_mint.sh similarity index 100% rename from bin/bootstrap/bootstrap_mint.sh rename to legacy/bin/bootstrap/bootstrap_mint.sh diff --git a/bin/casks.sh b/legacy/bin/casks.sh similarity index 100% rename from bin/casks.sh rename to legacy/bin/casks.sh diff --git a/bin/dots.rb b/legacy/bin/dots.rb similarity index 100% rename from bin/dots.rb rename to legacy/bin/dots.rb diff --git a/bin/dotutils.rb b/legacy/bin/dotutils.rb similarity index 100% rename from bin/dotutils.rb rename to legacy/bin/dotutils.rb diff --git a/bin/rake_tasks.rb b/legacy/bin/rake_tasks.rb similarity index 100% rename from bin/rake_tasks.rb rename to legacy/bin/rake_tasks.rb diff --git a/bin/sclbundle b/legacy/bin/sclbundle similarity index 100% rename from bin/sclbundle rename to legacy/bin/sclbundle diff --git a/bin/sclruby b/legacy/bin/sclruby similarity index 100% rename from bin/sclruby rename to legacy/bin/sclruby diff --git a/bin/shell-setup.sh b/legacy/bin/shell-setup.sh similarity index 100% rename from bin/shell-setup.sh rename to legacy/bin/shell-setup.sh diff --git a/copy/mac/gitconfig b/legacy/copy/mac/gitconfig similarity index 100% rename from copy/mac/gitconfig rename to legacy/copy/mac/gitconfig diff --git a/copy/puppetforge.yml b/legacy/copy/puppetforge.yml similarity index 100% rename from copy/puppetforge.yml rename to legacy/copy/puppetforge.yml diff --git a/puppet/production/Puppetfile b/legacy/puppet/production/Puppetfile similarity index 100% rename from puppet/production/Puppetfile rename to legacy/puppet/production/Puppetfile diff --git a/puppet/production/environment.conf b/legacy/puppet/production/environment.conf similarity index 100% rename from puppet/production/environment.conf rename to legacy/puppet/production/environment.conf diff --git a/puppet/production/hiera.yaml b/legacy/puppet/production/hiera.yaml similarity index 100% rename from puppet/production/hiera.yaml rename to legacy/puppet/production/hiera.yaml diff --git a/puppet/production/hieradata/common.yaml b/legacy/puppet/production/hieradata/common.yaml similarity index 100% rename from puppet/production/hieradata/common.yaml rename to legacy/puppet/production/hieradata/common.yaml diff --git a/puppet/production/hieradata/nodes/YellowBadger.yaml b/legacy/puppet/production/hieradata/nodes/YellowBadger.yaml similarity index 100% rename from puppet/production/hieradata/nodes/YellowBadger.yaml rename to legacy/puppet/production/hieradata/nodes/YellowBadger.yaml diff --git a/puppet/production/hieradata/nodes/bowl.yaml b/legacy/puppet/production/hieradata/nodes/bowl.yaml similarity index 100% rename from puppet/production/hieradata/nodes/bowl.yaml rename to legacy/puppet/production/hieradata/nodes/bowl.yaml diff --git a/puppet/production/hieradata/nodes/gene.yaml b/legacy/puppet/production/hieradata/nodes/gene.yaml similarity index 100% rename from puppet/production/hieradata/nodes/gene.yaml rename to legacy/puppet/production/hieradata/nodes/gene.yaml diff --git a/puppet/production/hieradata/nodes/mintstring.yaml b/legacy/puppet/production/hieradata/nodes/mintstring.yaml similarity index 100% rename from puppet/production/hieradata/nodes/mintstring.yaml rename to legacy/puppet/production/hieradata/nodes/mintstring.yaml diff --git a/puppet/production/manifests/site.pp b/legacy/puppet/production/manifests/site.pp similarity index 100% rename from puppet/production/manifests/site.pp rename to legacy/puppet/production/manifests/site.pp diff --git a/puppet/production/scripts/config_version.rb b/legacy/puppet/production/scripts/config_version.rb similarity index 100% rename from puppet/production/scripts/config_version.rb rename to legacy/puppet/production/scripts/config_version.rb diff --git a/puppet/production/scripts/config_version.sh b/legacy/puppet/production/scripts/config_version.sh similarity index 100% rename from puppet/production/scripts/config_version.sh rename to legacy/puppet/production/scripts/config_version.sh diff --git a/puppet/production/site/custom_libs/lib/facter/os_release.rb b/legacy/puppet/production/site/custom_libs/lib/facter/os_release.rb similarity index 100% rename from puppet/production/site/custom_libs/lib/facter/os_release.rb rename to legacy/puppet/production/site/custom_libs/lib/facter/os_release.rb diff --git a/puppet/production/site/custom_libs/lib/puppet/functions/find_group.rb b/legacy/puppet/production/site/custom_libs/lib/puppet/functions/find_group.rb similarity index 100% rename from puppet/production/site/custom_libs/lib/puppet/functions/find_group.rb rename to legacy/puppet/production/site/custom_libs/lib/puppet/functions/find_group.rb diff --git a/puppet/production/site/custom_libs/lib/puppet/functions/find_owner.rb b/legacy/puppet/production/site/custom_libs/lib/puppet/functions/find_owner.rb similarity index 100% rename from puppet/production/site/custom_libs/lib/puppet/functions/find_owner.rb rename to legacy/puppet/production/site/custom_libs/lib/puppet/functions/find_owner.rb diff --git a/puppet/production/site/custom_libs/lib/puppet/functions/homedir_to_user.rb b/legacy/puppet/production/site/custom_libs/lib/puppet/functions/homedir_to_user.rb similarity index 100% rename from puppet/production/site/custom_libs/lib/puppet/functions/homedir_to_user.rb rename to legacy/puppet/production/site/custom_libs/lib/puppet/functions/homedir_to_user.rb diff --git a/puppet/production/site/profile/manifests/base.pp b/legacy/puppet/production/site/profile/manifests/base.pp similarity index 100% rename from puppet/production/site/profile/manifests/base.pp rename to legacy/puppet/production/site/profile/manifests/base.pp diff --git a/puppet/production/site/profile/manifests/linux.pp b/legacy/puppet/production/site/profile/manifests/linux.pp similarity index 100% rename from puppet/production/site/profile/manifests/linux.pp rename to legacy/puppet/production/site/profile/manifests/linux.pp diff --git a/puppet/production/site/profile/manifests/linux/debian.pp b/legacy/puppet/production/site/profile/manifests/linux/debian.pp similarity index 100% rename from puppet/production/site/profile/manifests/linux/debian.pp rename to legacy/puppet/production/site/profile/manifests/linux/debian.pp diff --git a/puppet/production/site/profile/manifests/linux/el.pp b/legacy/puppet/production/site/profile/manifests/linux/el.pp similarity index 100% rename from puppet/production/site/profile/manifests/linux/el.pp rename to legacy/puppet/production/site/profile/manifests/linux/el.pp diff --git a/puppet/production/site/profile/manifests/linux/el/docker_repos.pp b/legacy/puppet/production/site/profile/manifests/linux/el/docker_repos.pp similarity index 100% rename from puppet/production/site/profile/manifests/linux/el/docker_repos.pp rename to legacy/puppet/production/site/profile/manifests/linux/el/docker_repos.pp diff --git a/puppet/production/site/profile/manifests/mac.pp b/legacy/puppet/production/site/profile/manifests/mac.pp similarity index 100% rename from puppet/production/site/profile/manifests/mac.pp rename to legacy/puppet/production/site/profile/manifests/mac.pp diff --git a/puppet/production/site/role/manifests/server.pp b/legacy/puppet/production/site/role/manifests/server.pp similarity index 100% rename from puppet/production/site/role/manifests/server.pp rename to legacy/puppet/production/site/role/manifests/server.pp diff --git a/puppet/production/site/role/manifests/workstation.pp b/legacy/puppet/production/site/role/manifests/workstation.pp similarity index 100% rename from puppet/production/site/role/manifests/workstation.pp rename to legacy/puppet/production/site/role/manifests/workstation.pp diff --git a/r10k.yaml b/legacy/r10k.yaml similarity index 100% rename from r10k.yaml rename to legacy/r10k.yaml