Skip to content

Commit

Permalink
feat(nix,fish): Create copy/paste shell aliases for each platform
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjones2014 committed Sep 5, 2023
1 parent 2bf0005 commit 558ad8c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 32 deletions.
56 changes: 29 additions & 27 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,38 @@
};
};

outputs = inputs@{ self, nixpkgs, home-manager, ... }:
let
vars = import ./lib/vars.nix;
specialArgs = {
inherit inputs;
inherit vars;
};
in {
nixosConfigurations = {
pc = nixpkgs.lib.nixosSystem {
inherit specialArgs;
system = "x86_64-linux";
modules = [
./nixos-modules/common.nix
./hosts/pc/default.nix
home-manager.nixosModules.home-manager
{
home-manager.useUserPackages = true;
home-manager.users.mat = import ./home-manager/home.nix;
home-manager.extraSpecialArgs = specialArgs;
}
];
outputs = inputs@{ self, nixpkgs, home-manager, ... }: {
nixosConfigurations = {
pc = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs;
vars = (import ./lib/vars.nix) { isDarwin = false; };
};
system = "x86_64-linux";
modules = [
./nixos-modules/common.nix
./hosts/pc/default.nix
home-manager.nixosModules.home-manager
{
home-manager.useUserPackages = true;
home-manager.users.mat = import ./home-manager/home.nix;
home-manager.extraSpecialArgs = {
inherit inputs;
vars = (import ./lib/vars.nix) { isDarwin = false; };
};
}
];
};
homeConfigurations = {
"mac" = home-manager.lib.homeManagerConfiguration {
extraSpecialArgs = specialArgs;
pkgs = nixpkgs.legacyPackages.aarch64-darwin;
modules = [ ./home-manager/home.nix ];
};
homeConfigurations = {
"mac" = home-manager.lib.homeManagerConfiguration {
extraSpecialArgs = {
inherit inputs;
vars = (import ./lib/vars.nix) { isDarwin = true; };
};
pkgs = nixpkgs.legacyPackages.aarch64-darwin;
modules = [ ./home-manager/home.nix ];
};
};
};
}
4 changes: 3 additions & 1 deletion home-manager/modules/fish.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, lib, ... }:
{ pkgs, lib, vars, ... }:
let
inherit (pkgs) stdenv;
inherit (stdenv) isLinux;
Expand Down Expand Up @@ -33,6 +33,8 @@ in {
}];

shellAliases = {
copy = vars.copyCmd;
paste = vars.pasteCmd;
cat = "bat";
gogit = "cd ~/git";
"!!" = "eval \\$history[1]";
Expand Down
6 changes: 2 additions & 4 deletions home-manager/modules/git.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, ... }:
{ pkgs, vars, ... }:
let
inherit (pkgs) git stdenv;
inherit (stdenv) isLinux;
Expand Down Expand Up @@ -30,9 +30,7 @@ in {
ch = "!${git_checkout_fzf_script}";
add-ignore-whitespace =
"!git diff --ignore-all-space | git apply --cached";
copy-branch = "!git branch --show-current | ${
if isLinux then "xclip -sel clip" else "pbcopy"
}";
copy-branch = "!git branch --show-current | ${vars.copyCmd}";
pending = "!git log $(git describe --tags --abbrev=0)..HEAD --oneline";
};
extraConfig = {
Expand Down
3 changes: 3 additions & 0 deletions lib/vars.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{ isDarwin }:
let usePantheon = false;
in {
inherit usePantheon;
useGnome = !usePantheon;
copyCmd = if isDarwin then "pbcopy" else "xclip -selection clipboard";
pasteCmd = if isDarwin then "pbpaste" else "xlip -o -selection clipboard";
}

0 comments on commit 558ad8c

Please sign in to comment.