From 81bb8b446a8fa3ef03e7e066b6689d174d6eef58 Mon Sep 17 00:00:00 2001 From: "Jip J. Dekker" Date: Mon, 11 Dec 2023 17:26:39 +1100 Subject: [PATCH] Update configuration to first deployed version --- darwin/casks.nix | 2 -- darwin/default.nix | 18 ++++++++++ darwin/files.nix | 7 ++-- darwin/home-manager.nix | 14 +++++--- flake.lock | 62 ++++++++++++++++++++++++-------- flake.nix | 62 +++++++++++++++++++++----------- nixos/default.nix | 6 ++-- nixos/files.nix | 12 +++---- nixos/home-manager.nix | 6 ++-- shared/default.nix | 7 ++-- shared/files.nix | 3 +- shared/home-manager.nix | 79 ++++++++++++++++++++++++++++++++++++++--- shared/packages.nix | 7 ++-- 13 files changed, 218 insertions(+), 67 deletions(-) diff --git a/darwin/casks.nix b/darwin/casks.nix index 3bf4b57..8a05312 100644 --- a/darwin/casks.nix +++ b/darwin/casks.nix @@ -11,13 +11,11 @@ # Communication Tools "discord" - "signal" "zoom" "zulip" # Utility Tools "calibre" - "mirrorop" # Productivity Tools "alfred" diff --git a/darwin/default.nix b/darwin/default.nix index e143d2b..abc7620 100644 --- a/darwin/default.nix +++ b/darwin/default.nix @@ -12,6 +12,24 @@ let user = "dekker1"; in # Auto upgrade nix package and the daemon service. services.nix-daemon.enable = true; + # Setup user, packages, programs + nix = { + package = pkgs.nixUnstable; + settings.trusted-users = [ "@admin" "${user}" ]; + + gc = { + user = "root"; + automatic = true; + interval = { Weekday = 0; Hour = 2; Minute = 0; }; + options = "--delete-older-than 30d"; + }; + + # Turn this on to make command line easier + extraOptions = '' + experimental-features = nix-command flakes + ''; + }; + # Turn off NIX_PATH warnings now that we're using flakes system.checks.verifyNixPath = false; diff --git a/darwin/files.nix b/darwin/files.nix index 2396a8f..9f27c6a 100644 --- a/darwin/files.nix +++ b/darwin/files.nix @@ -2,6 +2,7 @@ let xdg_configHome = "${config.users.users.${user}.home}/.config"; - xdg_dataHome = "${config.users.users.${user}.home}/.local/share"; - xdg_stateHome = "${config.users.users.${user}.home}/.local/state"; in -{} + xdg_dataHome = "${config.users.users.${user}.home}/.local/share"; + xdg_stateHome = "${config.users.users.${user}.home}/.local/state"; +in +{ } diff --git a/darwin/home-manager.nix b/darwin/home-manager.nix index ccf3267..9e46c41 100644 --- a/darwin/home-manager.nix +++ b/darwin/home-manager.nix @@ -14,8 +14,12 @@ in shell = pkgs.zsh; }; - homebrew.enable = false; - homebrew.casks = pkgs.callPackage ./casks.nix {}; + homebrew.enable = true; + homebrew.casks = pkgs.callPackage ./casks.nix { }; + homebrew.brews = [ + "yabai" + "skhd" + ]; # These app IDs are from using the mas CLI app # mas = mac app store @@ -47,15 +51,15 @@ in # Enable home-manager home-manager = { useGlobalPkgs = true; - users.${user} = { pkgs, config, lib, ... }:{ + users.${user} = { pkgs, config, lib, ... }: { home.enableNixpkgsReleaseCheck = false; - home.packages = pkgs.callPackage ./packages.nix {}; + home.packages = pkgs.callPackage ./packages.nix { }; home.file = lib.mkMerge [ sharedFiles additionalFiles ]; home.stateVersion = "21.11"; - programs = {} // import ../shared/home-manager.nix { inherit config pkgs lib; }; + programs = { } // import ../shared/home-manager.nix { inherit config pkgs lib; }; }; }; } diff --git a/flake.lock b/flake.lock index 67fa694..d4396ef 100644 --- a/flake.lock +++ b/flake.lock @@ -61,11 +61,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1702195734, - "narHash": "sha256-MvQa1qT+10dqJyMKtACCpFOcFYIv9i/REek1bHaIhS4=", + "lastModified": 1702203126, + "narHash": "sha256-4BhN2Vji19MzRC7SUfPZGmtZ2WZydQeUk/ogfRBIZMs=", "owner": "nix-community", "repo": "home-manager", - "rev": "9a00befa13126e318fa4b895adeb84d383c9ab3f", + "rev": "defbb9c5857e157703e8fc7cf3c2ceb01cb95883", "type": "github" }, "original": { @@ -93,11 +93,11 @@ "homebrew-cask": { "flake": false, "locked": { - "lastModified": 1702174207, - "narHash": "sha256-P7mCkLiuqnnjfle3mDc0oFhQreubAnCP0DWKt3ksLDs=", + "lastModified": 1702255628, + "narHash": "sha256-Q46Mgw3oLVafoo2mRzDdR6IQ9hdCnfk59uaWoiaAnjE=", "owner": "homebrew", "repo": "homebrew-cask", - "rev": "f9965c0cadc974f2b8706ecab78c5ff0972cd5a9", + "rev": "204e8eea0c0f3f1a26bf6f3f238595fdd3fc869c", "type": "github" }, "original": { @@ -106,14 +106,30 @@ "type": "github" } }, + "homebrew-cask-fonts": { + "flake": false, + "locked": { + "lastModified": 1702265088, + "narHash": "sha256-pU63NGMzYZ/4m4JWu5HmxZCU9pKJoUK++W46awmGtdc=", + "owner": "homebrew", + "repo": "homebrew-cask-fonts", + "rev": "a7fb1a6146ccd9a8d164c4c7f529da56d56310e9", + "type": "github" + }, + "original": { + "owner": "homebrew", + "repo": "homebrew-cask-fonts", + "type": "github" + } + }, "homebrew-core": { "flake": false, "locked": { - "lastModified": 1702193388, - "narHash": "sha256-fqUIwK1YXIYGu3ZU1g/gRmfaOy8ZKyUgJhGSvSsYAyU=", + "lastModified": 1702252550, + "narHash": "sha256-QMPC/VNrE706F1sWXokP5k5npM7blXMLc8g8R0iqvHA=", "owner": "homebrew", "repo": "homebrew-core", - "rev": "75ca7b621f326dcafe2ff834e9cde10d354d7080", + "rev": "fe91ea92d9b89f099209ab8252623c337ac13cd7", "type": "github" }, "original": { @@ -122,6 +138,22 @@ "type": "github" } }, + "homebrew-koekeishiya": { + "flake": false, + "locked": { + "lastModified": 1699812011, + "narHash": "sha256-1pXKOdZz1KADlAU3410afYq97Icxq0At5c9HClwLeFo=", + "owner": "koekeishiya", + "repo": "homebrew-formulae", + "rev": "d4c95802ca991ea41512320af412072e775c1eb7", + "type": "github" + }, + "original": { + "owner": "koekeishiya", + "repo": "homebrew-formulae", + "type": "github" + } + }, "nix-darwin": { "inputs": { "nixpkgs": "nixpkgs_2" @@ -150,13 +182,13 @@ "locked": { "lastModified": 1695057498, "narHash": "sha256-wn3j7u5tOgLLbNxZC542rJiP5iX323m+CoGPMgPOxp4=", - "owner": "zhaofengli-wip", + "owner": "zhaofengli", "repo": "nix-homebrew", "rev": "6ab33c5e9249e74401144a7c667d96a757c5d341", "type": "github" }, "original": { - "owner": "zhaofengli-wip", + "owner": "zhaofengli", "repo": "nix-homebrew", "type": "github" } @@ -208,11 +240,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1701718080, - "narHash": "sha256-6ovz0pG76dE0P170pmmZex1wWcQoeiomUZGggfH9XPs=", + "lastModified": 1702151865, + "narHash": "sha256-9VAt19t6yQa7pHZLDbil/QctAgVsA66DLnzdRGqDisg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "2c7f3c0fb7c08a0814627611d9d7d45ab6d75335", + "rev": "666fc80e7b2afb570462423cb0e1cf1a3a34fedd", "type": "github" }, "original": { @@ -228,7 +260,9 @@ "home-manager": "home-manager", "homebrew-bundle": "homebrew-bundle", "homebrew-cask": "homebrew-cask", + "homebrew-cask-fonts": "homebrew-cask-fonts", "homebrew-core": "homebrew-core", + "homebrew-koekeishiya": "homebrew-koekeishiya", "nix-homebrew": "nix-homebrew", "nixpkgs": "nixpkgs_4" } diff --git a/flake.nix b/flake.nix index bce9c14..42f1166 100644 --- a/flake.nix +++ b/flake.nix @@ -1,4 +1,3 @@ - { description = "Starter Configuration for NixOS and MacOS"; @@ -10,22 +9,41 @@ inputs.nixpkgs.follows = "nixpkgs"; }; nix-homebrew = { - url = "github:zhaofengli-wip/nix-homebrew"; + url = "github:zhaofengli/nix-homebrew"; }; homebrew-bundle = { url = "github:homebrew/homebrew-bundle"; flake = false; }; - homebrew-core = { - url = "github:homebrew/homebrew-core"; - flake = false; - }; homebrew-cask = { url = "github:homebrew/homebrew-cask"; flake = false; }; + homebrew-cask-fonts = { + url = "github:homebrew/homebrew-cask-fonts"; + flake = false; + }; + homebrew-core = { + url = "github:homebrew/homebrew-core"; + flake = false; + }; + homebrew-koekeishiya = { + url = "github:koekeishiya/homebrew-formulae"; + flake = false; + }; }; - outputs = { self, darwin, nix-homebrew, homebrew-bundle, homebrew-core, homebrew-cask, home-manager, nixpkgs } @inputs: + outputs = + { self + , darwin + , home-manager + , homebrew-bundle + , homebrew-cask + , homebrew-cask-fonts + , homebrew-core + , homebrew-koekeishiya + , nix-homebrew + , nixpkgs + } @inputs: let user = "dekker1"; linuxSystems = [ "x86_64-linux" "aarch64-linux" ]; @@ -33,16 +51,17 @@ forAllLinuxSystems = f: nixpkgs.lib.genAttrs linuxSystems (system: f system); forAllDarwinSystems = f: nixpkgs.lib.genAttrs darwinSystems (system: f system); forAllSystems = f: nixpkgs.lib.genAttrs (linuxSystems ++ darwinSystems) (system: f system); - devShell = system: let - pkgs = nixpkgs.legacyPackages.${system}; - in - { - default = with pkgs; mkShell { - nativeBuildInputs = with pkgs; [ bashInteractive git ]; - shellHook = with pkgs; '' + devShell = system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + { + default = with pkgs; mkShell { + nativeBuildInputs = with pkgs; [ bashInteractive git ]; + shellHook = with pkgs; '' ''; + }; }; - }; in { devShells = forAllSystems devShell; @@ -55,12 +74,14 @@ home-manager.darwinModules.home-manager { nix-homebrew = { - enable = false; + enable = true; user = "${user}"; taps = { "homebrew/homebrew-core" = homebrew-core; "homebrew/homebrew-cask" = homebrew-cask; - "homebrew/homebrew-bundle" = homebrew-bundle; + "homebrew/homebrew-cask-fonts" = homebrew-cask-fonts; + "homebrew/homebrew-bundle" = homebrew-bundle; + "koekeishiya/homebrew-formulae" = homebrew-koekeishiya; }; mutableTaps = false; autoMigrate = true; @@ -74,13 +95,14 @@ system = system; specialArgs = inputs; modules = [ - home-manager.nixosModules.home-manager { + home-manager.nixosModules.home-manager + { home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; home-manager.users.${user} = import ./nixos/home-manager.nix; } ./nixos ]; - }); - }; + }); + }; } diff --git a/nixos/default.nix b/nixos/default.nix index 9a8c19c..f4ec691 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -1,7 +1,9 @@ { config, inputs, pkgs, ... }: -let user = "dekker1"; - keys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICwXNVel0w1f4nbmu2iJsqCoeiUsENzTLyhCZjSL+jT+" ]; in +let + user = "dekker1"; + keys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICwXNVel0w1f4nbmu2iJsqCoeiUsENzTLyhCZjSL+jT+" ]; +in { imports = [ ../shared diff --git a/nixos/files.nix b/nixos/files.nix index e2c2aaf..173b272 100644 --- a/nixos/files.nix +++ b/nixos/files.nix @@ -1,9 +1,9 @@ -{ user, ... }: +{ user, pkgs, ... }: let - home = builtins.getEnv "HOME"; + home = builtins.getEnv "HOME"; xdg_configHome = "${home}/.config"; - xdg_dataHome = "${home}/.local/share"; - xdg_stateHome = "${home}/.local/state"; in -{ -} + xdg_dataHome = "${home}/.local/share"; + xdg_stateHome = "${home}/.local/state"; +in +{ } diff --git a/nixos/home-manager.nix b/nixos/home-manager.nix index 8ff2c9b..2b8425b 100644 --- a/nixos/home-manager.nix +++ b/nixos/home-manager.nix @@ -2,7 +2,7 @@ let user = "dekker1"; - xdg_configHome = "/home/${user}/.config"; + xdg_configHome = "/home/${user}/.config"; shared-programs = import ../shared/home-manager.nix { inherit config pkgs lib; }; shared-files = import ../shared/files.nix { inherit config pkgs; }; in @@ -11,11 +11,11 @@ in enableNixpkgsReleaseCheck = false; username = "${user}"; homeDirectory = "/home/${user}"; - packages = pkgs.callPackage ./packages.nix {}; + packages = pkgs.callPackage ./packages.nix { }; file = shared-files // import ./files.nix { inherit user; }; stateVersion = "21.05"; }; - programs = shared-programs // {}; + programs = shared-programs // { }; } diff --git a/shared/default.nix b/shared/default.nix index b2f57e4..bcaa49f 100644 --- a/shared/default.nix +++ b/shared/default.nix @@ -14,8 +14,9 @@ # Apply each overlay found in the /overlays directory let path = ../overlays; in with builtins; map (n: import (path + ("/" + n))) - (filter (n: match ".*\\.nix" n != null || - pathExists (path + ("/" + n + "/default.nix"))) - (attrNames (readDir path))); + (filter + (n: match ".*\\.nix" n != null || + pathExists (path + ("/" + n + "/default.nix"))) + (attrNames (readDir path))); }; } diff --git a/shared/files.nix b/shared/files.nix index dbaa756..c4fdb94 100644 --- a/shared/files.nix +++ b/shared/files.nix @@ -1,4 +1,3 @@ { pkgs, config, ... }: -{ -} +{ } diff --git a/shared/home-manager.nix b/shared/home-manager.nix index 54c5881..7cc0642 100644 --- a/shared/home-manager.nix +++ b/shared/home-manager.nix @@ -1,8 +1,10 @@ { config, pkgs, lib, ... }: -let name = "Jip J. Dekker"; - user = "dekker1"; - email = "jip@dekker.one"; in +let + name = "Jip J. Dekker"; + user = "dekker1"; + email = "jip@dekker.one"; +in { git = { @@ -37,7 +39,7 @@ let name = "Jip J. Dekker"; pull.ff = true; push.default = "simple"; rebase.autoStash = true; - + credential.helper = "osxkeychain"; commit.gpgsign = true; @@ -50,6 +52,75 @@ let name = "Jip J. Dekker"; # Shared shell configuration nushell = { enable = true; + shellAliases = { + edit = "^($env.VISUAL)"; + start = "^open"; + less = "bat"; + set-light-theme = "kitty +kitten themes Catppuccin-Latte"; + set-dark-theme = "kitty +kitten themes Night Owl"; + brew-backup = "brew bundle dump --global --no-lock --formula --cask --mas --tap --force"; + brew-cleanup = "brew bundle cleanup --global --no-lock --force --zap"; + brew-restore = "brew bundle install --global --no-lock"; + }; + environmentVariables = { + # Set default editor + EDITOR = ''"nvim"''; + VISUAL = ''"codium"''; + # DISABLE VI INDICATORS + PROMPT_INDICATOR_VI_INSERT = ''""''; + PROMPT_INDICATOR_VI_NORMAL = ''""''; + # Alias for Monash compute cluster + OPTCLUSTER = ''"compute.optimisation-2020.cloud.edu.au"''; + # CMake settings + CMAKE_EXPORT_COMPILE_COMMANDS = ''"1"''; # output compile-commands.json for clangd + CMAKE_GENERATOR = ''"Ninja Multi-Config"''; # use Ninja generator by default + CMAKE_C_COMPILER_LAUNCHER = ''"ccache"''; + CMAKE_CXX_COMPILER_LAUNCHER = ''"ccache"''; + # Homebrew shell setup (brew shellenv) + HOMEBREW_PREFIX = ''"/opt/homebrew"''; + HOMEBREW_CELLAR = ''"/opt/homebrew/Cellar"''; + HOMEBREW_REPOSITORY = ''"/opt/homebrew"''; + INFOPATH = ''"/opt/homebrew/share/info"''; + # Set MANPATH + MANPATH = ''"/usr/share/man:/usr/local/share/man:/Library/TeX/Distributions/.DefaultTeX/Contents/Man:/opt/homebrew/share/man"''; + NIX_PROFILES = ''$"/nix/var/nix/profiles/default:($env.HOME)/.nix-profile"''; + }; + envFile.text = '' + if not 'config' in $env { + $env.config = ([] | into record) + } + $env.config = ($env.config | upsert show_banner false) + $env.config = ($env.config | upsert rm.always_trash true) + $env.config = ($env.config | upsert edit_mode vi) + $env.config = ($env.config | upsert history.max_size 100000) + $env.config = ($env.config | upsert footer_mode auto) + $env.config = ($env.config | upsert history.file_format "sqlite") + ''; + configFile.text = '' + # Specifies how environment variables are: + # - converted from a string to a value on Nushell startup (from_string) + # - converted from a value back to a string when running external commands (to_string) + # Note: The conversions happen *after* config.nu is loaded + $env.ENV_CONVERSIONS = { + "PATH": { + from_string: { |s| $s | split row (char esep) | path expand --no-symlink } + to_string: { |v| $v | path expand --no-symlink | str join (char esep) } + } + } + + # Add entries to PATH: + # From MacOS helper (/usr/libexec/path_helper) + $env.PATH = ($env.PATH | split row (char esep) | append $"($env.HOME)/.nix-profile/bin") + $env.PATH = ($env.PATH | split row (char esep) | append "/nix/var/nix/profiles/default/bin") + $env.PATH = ($env.PATH | split row (char esep) | append "/Library/TeX/texbin") + $env.PATH = ($env.PATH | split row (char esep) | append "/Library/Apple/usr/bin") + $env.PATH = ($env.PATH | split row (char esep) | append "/opt/homebrew/bin") + $env.PATH = ($env.PATH | split row (char esep) | append "/opt/homebrew/sbin") + $env.PATH = ($env.PATH | split row (char esep) | append "/usr/local/bin") + # Other package managers + $env.PATH = ($env.PATH | split row (char esep) | prepend $"($env.HOME)/.local/bin") + $env.PATH = ($env.PATH | split row (char esep) | prepend $"($env.HOME)/.cargo/bin") + ''; }; starship = { diff --git a/shared/packages.nix b/shared/packages.nix index 72f7f29..38aebf8 100644 --- a/shared/packages.nix +++ b/shared/packages.nix @@ -17,15 +17,12 @@ with pkgs; [ # Text and terminal utilities bat - eza neovim zoxide # C(++) development tools - bison ccache cmake - flex llvm ninja @@ -38,6 +35,10 @@ with pkgs; [ gecode # or-tools + # Nix development tools + nixpkgs-fmt + nixd + # Node.js development tools nodePackages.prettier nodePackages.npm # globally install npm