diff --git a/flake.nix b/flake.nix index c0e7a652..327541eb 100644 --- a/flake.nix +++ b/flake.nix @@ -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 ]; }; }; + }; } diff --git a/home-manager/modules/fish.nix b/home-manager/modules/fish.nix index 0ebd3e0c..d2235d33 100644 --- a/home-manager/modules/fish.nix +++ b/home-manager/modules/fish.nix @@ -1,4 +1,4 @@ -{ pkgs, lib, ... }: +{ pkgs, lib, vars, ... }: let inherit (pkgs) stdenv; inherit (stdenv) isLinux; @@ -33,6 +33,8 @@ in { }]; shellAliases = { + copy = vars.copyCmd; + paste = vars.pasteCmd; cat = "bat"; gogit = "cd ~/git"; "!!" = "eval \\$history[1]"; diff --git a/home-manager/modules/git.nix b/home-manager/modules/git.nix index ee93ecc3..31ebb513 100644 --- a/home-manager/modules/git.nix +++ b/home-manager/modules/git.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ pkgs, vars, ... }: let inherit (pkgs) git stdenv; inherit (stdenv) isLinux; @@ -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 = { diff --git a/lib/vars.nix b/lib/vars.nix index 8ff55bb4..aef75b41 100644 --- a/lib/vars.nix +++ b/lib/vars.nix @@ -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"; }