From 0229df9b97657b38b8d1d9a8f71f269e25605ad0 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 14 Jun 2022 19:03:16 -0400 Subject: [PATCH] merge darwin and nixos rebuild function --- Makefile | 3 --- modules/darwin/utilities.nix | 7 ------- modules/editor/dotfiles.nix | 19 +++++++++++++++---- 3 files changed, 15 insertions(+), 14 deletions(-) delete mode 100644 Makefile diff --git a/Makefile b/Makefile deleted file mode 100644 index 45779bd..0000000 --- a/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -nix: - git add -A - doas nixos-rebuild switch --flake . diff --git a/modules/darwin/utilities.nix b/modules/darwin/utilities.nix index 7e3d61d..f085c32 100644 --- a/modules/darwin/utilities.nix +++ b/modules/darwin/utilities.nix @@ -37,13 +37,6 @@ xdg.configFile.hammerspoon = { source = ./hammerspoon; }; - programs.fish = { - shellAbbrs = { - nr = - "sudo darwin-rebuild switch --flake ${config.dotfilesPath}#macbook"; - }; - }; - }; system.activationScripts.hammerspoon.text = '' diff --git a/modules/editor/dotfiles.nix b/modules/editor/dotfiles.nix index 8cb5ec3..aab77c2 100644 --- a/modules/editor/dotfiles.nix +++ b/modules/editor/dotfiles.nix @@ -16,10 +16,21 @@ }; - programs.fish = { - shellAbbrs = { - nr = lib.mkIf pkgs.stdenv.isLinux - "doas nixos-rebuild switch --flake ${config.dotfilesPath}"; + programs.fish = let + system = if pkgs.stdenv.isDarwin then "darwin" else "nixos"; + sudo = if pkgs.stdenv.isDarwin then "doas" else "sudo"; + in { + shellAbbrs = { nr = lib.mkIf pkgs.stdenv.isLinux "rebuild-${system}"; }; + functions = { + rebuild-nixos = { + body = '' + pushd ${config.dotfilesPath} + git add --all + popd + echo "${sudo} ${system}-rebuild switch --flake ${config.dotfilesPath}" + ${sudo} ${system}-rebuild switch --flake ${config.dotfilesPath} + ''; + }; }; };